/* ============================================================
   Flujo público de firma (/firma): contraseña, biometría (PasoBiometria.razor + componente
   de prueba de vida de AWS) y pantalla de entrega. 2026-11-14. Se carga DESPUÉS de panel-firmas.css y appv18.css para ganarles.
   Colores: navy #0a1533 y cian #00c2cc. Azul brillo solo en detalles. Tipografía Red Hat.
   Lo que NO se puede cambiar: los destellos de colores del reto, la forma del óvalo y el
   indicador "Grabando" (AWS los controla).
   ============================================================ */

.firma-biometria {
    --bio-navy: #0a1533;
    --bio-navy-2: #162d69;
    --bio-cian: #00c2cc;
    --bio-brillo: #2e53b7;
    --bio-badge-bg: var(--bio-navy);
    --bio-badge-fg: #ffffff;
    --bio-ico-bg: var(--bio-navy);
    --bio-ico-fg: var(--bio-cian);
}
html[data-theme="dark"] .firma-biometria { --bio-badge-bg: var(--bio-cian); --bio-badge-fg: var(--bio-navy); --bio-ico-bg: rgba(0,194,204,.14); }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .firma-biometria { --bio-badge-bg: var(--bio-cian); --bio-badge-fg: var(--bio-navy); --bio-ico-bg: rgba(0,194,204,.14); }
}

/* ---------- Encabezado del paso ---------- */
.bio-cab { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.firma-biometria .bio-cab .firma-paso__titulo { font-family: var(--f-display); font-weight: 700; letter-spacing: -0.025em; margin: 0; }
.firma-biometria .bio-cab .firma-paso__sub { margin: 0; }

/* Botones del paso: rectangulares, del alto de los campos (52 px). */
.firma-biometria .bio-btn { height: 52px; border-radius: 12px; font-family: var(--f-texto); font-weight: 600; font-size: 15px; }

/* ---------- 1. Antes de empezar ---------- */
.firma-biometria .firma-biometria__tips { gap: var(--space-2); }
.firma-biometria .firma-biometria__tips li { align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); font-size: 13px; line-height: 1.35; }
.firma-biometria .firma-biometria__tips li strong { display: block; color: var(--text-primary); font-weight: 600; font-size: 13.5px; }
.bio-tip__ico { width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--bio-ico-bg); display: flex; align-items: center; justify-content: center; }
.firma-biometria .firma-biometria__tips .bio-tip__ico .bi { color: var(--bio-ico-fg); font-size: 16px; }

/* ---------- 2. Cámara de AWS ---------- */
.firma-biometria .firma-biometria__camara { border: 1.5px solid var(--bio-navy); box-shadow: 0 10px 28px rgba(10,21,51,.14); margin-bottom: var(--space-3); }

/* Letra Red Hat dentro del componente de Amplify. */
.firma-biometria [data-amplify-theme] {
    --amplify-fonts-default-variable: var(--f-texto);
    --amplify-fonts-default-static: var(--f-texto);
    font-family: var(--f-texto);
}

/* Badge de instrucción ("Acércate", "No te muevas"): navy sólido, Red Hat semibold. */
.firma-biometria .amplify-liveness-toast--primary { background-color: var(--bio-navy) !important; box-shadow: 0 6px 14px rgba(10,21,51,.25); }
.firma-biometria .amplify-liveness-toast__message { font-family: var(--f-texto) !important; font-weight: 600 !important; }

/* Barra de progreso en cian. */
.firma-biometria .amplify-liveness-match-indicator__bar { background: rgba(10,21,51,.15) !important; }
.firma-biometria .amplify-liveness-match-indicator__bar::after,
.firma-biometria .amplify-liveness-match-indicator__pin::after { background: var(--bio-cian) !important; }

/* Escritorio: la X pequeña de AWS se oculta; se usa el botón "Cancelar" de abajo. */
.firma-biometria .amplify-liveness-camera-module:not(.amplify-liveness-camera-module--mobile) .amplify-liveness-cancel-container { display: none !important; }
/* Celular: AWS pone la cámara a pantalla completa y tapa el botón de abajo, así que la X se queda,
   pero como botón cuadrado blanco con esquinas redondeadas. */
.firma-biometria .amplify-liveness-camera-module--mobile .amplify-liveness-cancel-button {
    width: 44px; height: 44px; padding: 0; border-radius: 10px !important; background: #ffffff !important; color: var(--bio-navy) !important; box-shadow: 0 4px 12px rgba(10,21,51,.22);
}

/* ---------- Animación de escaneo ----------
   Capas CSS sobre el video (::before = esquinas de enfoque, ::after = rejilla + línea que barre),
   recortadas a una elipse en el centro, donde AWS dibuja el óvalo. pointer-events: none y no
   tocan el video: AWS recibe la cámara tal cual. */
.firma-biometria .amplify-liveness-video-anchor::before,
.firma-biometria .amplify-liveness-video-anchor::after {
    content: ""; position: absolute; pointer-events: none; z-index: 1; transition: opacity .25s ease;
}
.firma-biometria .amplify-liveness-video-anchor::before {
    inset: 12% 13% 18%;
    --c: var(--bio-cian); --l: 26px; --g: 3px;
    background:
        linear-gradient(var(--c), var(--c)) left top / var(--l) var(--g) no-repeat,
        linear-gradient(var(--c), var(--c)) left top / var(--g) var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) right top / var(--l) var(--g) no-repeat,
        linear-gradient(var(--c), var(--c)) right top / var(--g) var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) left bottom / var(--l) var(--g) no-repeat,
        linear-gradient(var(--c), var(--c)) left bottom / var(--g) var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) right bottom / var(--l) var(--g) no-repeat,
        linear-gradient(var(--c), var(--c)) right bottom / var(--g) var(--l) no-repeat;
    animation: bio-respira 2.6s ease-in-out infinite;
}
.firma-biometria .amplify-liveness-video-anchor::after {
    inset: 0;
    background:
        linear-gradient(to bottom, rgba(0,194,204,0) 0%, rgba(0,194,204,.28) 82%, rgba(0,194,204,.95) 99%, rgba(0,194,204,0) 100%) 0 0 / 100% 18% no-repeat,
        linear-gradient(rgba(0,194,204,.16) 1px, transparent 1px) 0 0 / 16px 16px,
        linear-gradient(90deg, rgba(0,194,204,.16) 1px, transparent 1px) 0 0 / 16px 16px;
    -webkit-mask-image: radial-gradient(ellipse 33% 36% at 50% 46%, #000 92%, transparent 100%);
            mask-image: radial-gradient(ellipse 33% 36% at 50% 46%, #000 92%, transparent 100%);
    animation: bio-barrido 2.6s cubic-bezier(.45,0,.55,1) infinite;
}
@keyframes bio-barrido {
    0%   { background-position: 0 -20%, 0 0, 0 0; }
    50%  { background-position: 0 120%, 0 0, 0 0; }
    100% { background-position: 0 -20%, 0 0, 0 0; }
}
@keyframes bio-respira { 0%, 100% { transform: scale(1); } 50% { transform: scale(.97); } }

/* Durante el reto de luces (AWS muestra su canvas de colores) se esconde el escaneo para no
   interferir con la luz sobre el rostro. */
.firma-biometria .firma-biometria__camara:has(.amplify-liveness-freshness-canvas:not([hidden])) .amplify-liveness-video-anchor::before,
.firma-biometria .firma-biometria__camara:has(.amplify-liveness-freshness-canvas:not([hidden])) .amplify-liveness-video-anchor::after,
.firma-biometria .firma-biometria__camara:has(.amplify-liveness-overlay-opaque) .amplify-liveness-video-anchor::before,
.firma-biometria .firma-biometria__camara:has(.amplify-liveness-overlay-opaque) .amplify-liveness-video-anchor::after { opacity: 0; animation: none; }

/* ---------- 4. Error ---------- */
.bio-error { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-card); }
.bio-error__ico { width: 42px; height: 42px; border-radius: 12px; background: var(--bio-ico-bg); color: var(--bio-ico-fg); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.bio-error h3 { font-family: var(--f-display); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; margin: 0; color: var(--text-primary); }
.bio-error p { margin: 0; font-size: 13.5px; color: var(--text-secondary); }
.bio-error__consejos { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-primary); }
.bio-error__consejos li { display: flex; align-items: center; gap: 8px; }
.bio-error__consejos li::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--bio-cian); flex: none; }

/* ---------- 5. Confirmando ---------- */
.bio-confirma { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: var(--space-6) 0; }
.bio-confirma__anillo { width: 120px; height: 120px; }
.bio-confirma__anillo svg { width: 100%; height: 100%; overflow: visible; }
.bio-confirma__anillo .fondo { fill: var(--bg-card); }
.bio-confirma__anillo .pista { fill: none; stroke: var(--border); stroke-width: 6; }
.bio-confirma__anillo .arco { fill: none; stroke: var(--bio-cian); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327; transform: rotate(-90deg); transform-origin: 60px 60px; animation: bio-arco 3.2s ease-in-out infinite; }
.bio-confirma__anillo .check { fill: none; stroke: var(--text-primary); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: bio-check 3.2s ease-in-out infinite; }
@keyframes bio-arco { 0% { stroke-dashoffset: 327; } 55%, 100% { stroke-dashoffset: 0; } }
@keyframes bio-check { 0%, 55% { stroke-dashoffset: 60; } 75%, 100% { stroke-dashoffset: 0; } }
.bio-confirma h3 { font-family: var(--f-display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; margin: 0; color: var(--text-primary); }
.bio-confirma p { margin: 0; font-size: 13.5px; color: var(--text-secondary); max-width: 30ch; }

/* ============================================================
   Contraseña (PasoContrasena.razor). Solo en /firma: el checkout usa el mismo campo y no cambia.
   ============================================================ */
.firma-clave .checkout-row-2cols { grid-template-columns: 1fr; gap: var(--space-4); }
.firma-clave .ds-input { height: 52px; }
/* Aviso de caracteres permitidos (reemplaza al botón "Generar" en /firma). */
.clave-aviso { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 var(--space-4); padding: 12px 14px; border-radius: 12px; background: #eef1f6; border: 1px solid #d9dfea; color: #0a1533; font-size: 13.5px; line-height: 1.45; }
.clave-aviso > i { color: #2e53b7; font-size: 17px; line-height: 1.2; flex: none; }
.clave-aviso strong { font-weight: 600; }
html[data-theme="dark"] .clave-aviso { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.12); color: #e6eaf2; }
html[data-theme="dark"] .clave-aviso > i { color: #00c2cc; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .clave-aviso { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.12); color: #e6eaf2; }
    html:not([data-theme="light"]) .clave-aviso > i { color: #00c2cc; }
}
.firma-clave .checkout-reglas-clave { margin-top: var(--space-3); }
.firma-clave .ds-btn--primary { height: 52px; border-radius: 12px; font-weight: 600; font-size: 15px; }

/* ============================================================
   Entrega (PasoEntrega.razor): "Tu firma fue enviada" / "¡Todo listo!"
   v5 (2026-11-14): todo sobre el blanco de la tarjeta, sello animado y el correo en un chip; cuerpo blanco
   con dos avisos en filas y los botones.
   ============================================================ */
.firma-paso.firma-entrega { padding: 0; overflow: hidden; text-align: left; display: block; }
.ent-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 36px 24px 8px; }
.ent-sello { width: 76px; height: 76px; margin-bottom: 6px; }
.ent-sello svg { width: 100%; height: 100%; overflow: visible; }
.ent-sello .pista { fill: #e6f9fa; stroke: #ccf3f5; stroke-width: 2; }
.ent-sello .arco { fill: none; stroke: #00c2cc; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 195; stroke-dashoffset: 195; transform: rotate(-90deg); transform-origin: 36px 36px; animation: ent-dibujo .9s ease-out .15s forwards; }
.ent-sello .check { fill: none; stroke: #0a1533; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 44; stroke-dashoffset: 44; animation: ent-dibujo .45s ease-out .95s forwards; }
@keyframes ent-dibujo { to { stroke-dashoffset: 0; } }
.firma-paso.firma-entrega .firma-entrega__titulo { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: clamp(24px, 3.2vw, 30px); letter-spacing: -0.03em; line-height: 1.1; color: var(--text-primary); }
.ent-hero__texto { margin: 0; color: var(--text-secondary); font-size: 14.5px; max-width: 38ch; }
.ent-chip {
    display: inline-flex; align-items: center; gap: 10px; max-width: 100%; margin-top: 4px;
    padding: 10px 16px; border-radius: 10px; background: #eef1f6; border: 1px solid #d9dfea; color: #0a1533;
    font-weight: 700; font-size: 15.5px;
}
.ent-chip i { color: #00a3ab; font-size: 16px; flex: none; }
.ent-chip span { min-width: 0; overflow-wrap: anywhere; }
html[data-theme="dark"] .ent-chip { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #ffffff; }
html[data-theme="dark"] .ent-sello .pista { fill: rgba(0,194,204,.08); stroke: rgba(0,194,204,.25); }
html[data-theme="dark"] .ent-sello .check { stroke: #ffffff; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .ent-chip { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #ffffff; }
    html:not([data-theme="light"]) .ent-sello .pista { fill: rgba(0,194,204,.08); stroke: rgba(0,194,204,.25); }
    html:not([data-theme="light"]) .ent-sello .check { stroke: #ffffff; }
}

.ent-cuerpo { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.ent-filas { display: flex; flex-direction: column; }
.ent-fila { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--border); }
.ent-fila:first-child { border-top: 0; padding-top: 0; }
.ent-fila > i { width: 36px; height: 36px; flex: none; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; background: #eef1f6; color: #0a1533; }
.ent-fila--aviso > i { background: #fff1d6; color: #b36b00; }
.ent-fila p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--text-secondary); }
.ent-fila strong { color: var(--text-primary); font-weight: 600; }
.firma-paso.firma-entrega .firma-entrega__acciones { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: none; margin: 0; }
.firma-paso.firma-entrega .firma-entrega__acciones .ds-btn { width: 100%; height: 52px; border-radius: 12px; font-weight: 600; font-size: 15px; }
html[data-theme="dark"] .ent-fila > i { background: rgba(255,255,255,.06); color: #00c2cc; }
html[data-theme="dark"] .ent-fila--aviso > i { background: rgba(245,165,36,.14); color: #f5a524; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .ent-fila > i { background: rgba(255,255,255,.06); color: #00c2cc; }
    html:not([data-theme="light"]) .ent-fila--aviso > i { background: rgba(245,165,36,.14); color: #f5a524; }
}
@media (max-width: 480px) { .ent-hero { padding: 30px 18px 4px; } .ent-cuerpo { padding: 20px 18px; } }

@media (prefers-reduced-motion: reduce) {
    .ent-sello .arco, .ent-sello .check { animation: none; stroke-dashoffset: 0; }
    .firma-biometria *, .firma-biometria *::before, .firma-biometria *::after { animation: none !important; }
}
