/* =============================================================================
   LOGIN - Sostum v3
   Split screen: panel de marca (degradado azul -> verde del isotipo) a la
   izquierda y formulario sobre fondo claro a la derecha.
   Depende de base.css solo por el reset; no usa .container de base.
   ============================================================================= */

:root {
    --azul-900: #101a4d;
    --azul-700: #1d3286;
    --azul-500: #2b46ad;
    --verde-500: #46a05e;
    --verde-400: #5bb873;

    --texto: #16192b;
    --texto-suave: #5b6178;
    --borde: #d8dce7;
    --superficie: #ffffff;
    --fondo: #f5f6fa;

    --radio: 10px;
    --transicion: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

body.auth {
    min-height: 100vh;
    background: var(--fondo);
    color: var(--texto);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto,
        'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.auth-layout {
    display: grid;
    grid-template-columns: 55fr 45fr;
    min-height: 100vh;
}

/* --- Panel de marca ------------------------------------------------------- */

.auth-brand {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 56px;
    color: #ffffff;
    background: linear-gradient(145deg,
        var(--azul-900) 0%,
        var(--azul-700) 38%,
        #276b7d 72%,
        var(--verde-500) 100%);
}

/* Isotipo ampliado y recortado por el borde: identidad, no adorno */
.auth-brand::before {
    content: "";
    position: absolute;
    right: -18%;
    bottom: -32%;
    width: 88%;
    aspect-ratio: 1;
    background: var(--marca-url) no-repeat center / contain;
    opacity: 0.05;
    filter: grayscale(1) brightness(3);
    pointer-events: none;
}

.auth-brand > * {
    position: relative;
}

.auth-brand__logo {
    width: 132px;
    height: auto;
    /* El isotipo es azul/verde: sobre el degradado se resuelve en blanco */
    filter: brightness(0) invert(1);
    opacity: 0.96;
}

.auth-brand__titulo {
    max-width: 20ch;
    margin-top: 40px;
    font-size: clamp(1.9rem, 2.6vw, 2.6rem);
    font-weight: 600;
    line-height: 1.18;
    letter-spacing: -0.02em;
}

.auth-brand__texto {
    max-width: 42ch;
    margin-top: 18px;
    font-size: 1.02rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.78);
}

.auth-brand__pie {
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.55);
}

/* --- Columna del formulario ----------------------------------------------- */

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 32px;
    background: var(--superficie);
}

.auth-form {
    width: 100%;
    max-width: 368px;
    /* Entrada breve al cargar: señal de que la app respondió */
    animation: auth-entrada 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-form__titulo {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.auth-form__subtitulo {
    margin-top: 8px;
    font-size: 0.95rem;
    color: var(--texto-suave);
}

.auth-form form {
    margin-top: 34px;
}

.campo + .campo {
    margin-top: 20px;
}

.campo label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.69rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--texto-suave);
}

.campo input {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--texto);
    background: #fbfbfd;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    transition: border-color var(--transicion), box-shadow var(--transicion),
        background-color var(--transicion);
}

.campo input::placeholder {
    color: #a4aabc;
}

.campo input:hover {
    border-color: #bcc3d4;
}

.campo input:focus {
    outline: none;
    background: var(--superficie);
    border-color: var(--azul-500);
    box-shadow: 0 0 0 3px rgba(43, 70, 173, 0.14);
}

/* Campo de contraseña con botón de visibilidad */
.campo--password {
    position: relative;
}

.campo--password input {
    padding-right: 46px;
}

.toggle-password {
    position: absolute;
    right: 6px;
    bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--texto-suave);
    background: none;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: color var(--transicion), background-color var(--transicion);
}

.toggle-password:hover {
    color: var(--azul-700);
    background: #eef0f7;
}

.toggle-password:focus-visible {
    outline: 2px solid var(--azul-500);
    outline-offset: 1px;
}

.toggle-password svg {
    width: 18px;
    height: 18px;
}

/* El icono activo lo decide el estado del botón */
.toggle-password .icono-off { display: none; }
.toggle-password[aria-pressed="true"] .icono-on { display: none; }
.toggle-password[aria-pressed="true"] .icono-off { display: block; }

/* --- Botón ---------------------------------------------------------------- */

.btn-auth {
    width: 100%;
    margin-top: 28px;
    padding: 13px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #ffffff;
    background: linear-gradient(120deg, var(--azul-700), var(--azul-500));
    border: none;
    border-radius: var(--radio);
    cursor: pointer;
    transition: filter var(--transicion), box-shadow var(--transicion),
        transform var(--transicion);
}

.btn-auth:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 18px rgba(29, 50, 134, 0.26);
}

.btn-auth:active {
    transform: translateY(1px);
}

.btn-auth:focus-visible {
    outline: 2px solid var(--azul-500);
    outline-offset: 2px;
}

.btn-auth[disabled] {
    cursor: progress;
    filter: saturate(0.6) brightness(0.95);
    box-shadow: none;
}

/* --- Mensajes ------------------------------------------------------------- */

.auth-mensajes {
    margin-top: 24px;
}

.auth-alerta {
    padding: 11px 13px;
    font-size: 0.87rem;
    line-height: 1.45;
    border: 1px solid transparent;
    border-radius: var(--radio);
}

.auth-alerta + .auth-alerta {
    margin-top: 8px;
}

.auth-alerta--error {
    color: #8a1c26;
    background: #fdf0f1;
    border-color: #f4ccd0;
}

.auth-alerta--success {
    color: #14532d;
    background: #f0faf3;
    border-color: #c6e9d2;
}

.auth-alerta--info,
.auth-alerta--warning,
.auth-alerta--debug {
    color: #17427a;
    background: #eff5fd;
    border-color: #c9dcf3;
}

/* --- Animación ------------------------------------------------------------ */

@keyframes auth-entrada {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-form { animation: none; }
    * { transition-duration: 1ms !important; }
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 900px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        min-height: 180px;
        padding: 28px 24px;
        gap: 14px;
    }

    .auth-brand__logo { width: 92px; }

    .auth-brand__titulo {
        margin-top: 0;
        font-size: 1.35rem;
    }

    /* En la franja compacta el texto largo y el pie sobran */
    .auth-brand__texto,
    .auth-brand__pie { display: none; }

    .auth-panel {
        align-items: flex-start;
        padding: 40px 24px 56px;
    }
}

/* =============================================================================
   VERIFICACIÓN 2FA
   Reutiliza el layout y los tokens de la pantalla de login.
   ============================================================================= */

/* El widget del form ya emite class="mfa-input" (ver MFAVerifyForm) */
.mfa-input {
    width: 100%;
    padding: 14px;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: 0.42em;
    /* Compensa el letter-spacing del último carácter para que quede centrado */
    text-indent: 0.42em;
    text-align: center;
    color: var(--texto);
    background: #fbfbfd;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    transition: border-color var(--transicion), box-shadow var(--transicion),
        background-color var(--transicion);
}

.mfa-input::placeholder {
    color: #ccd1de;
    font-weight: 400;
}

.mfa-input:hover {
    border-color: #bcc3d4;
}

.mfa-input:focus {
    outline: none;
    background: var(--superficie);
    border-color: var(--azul-500);
    box-shadow: 0 0 0 3px rgba(43, 70, 173, 0.14);
}

/* --- Temporizador del código TOTP ----------------------------------------- */

.mfa-timer {
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--texto-suave);
}

.mfa-timer__texto {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.mfa-timer__valor {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--texto);
}

.mfa-timer__barra {
    height: 3px;
    margin-top: 7px;
    overflow: hidden;
    background: #e9ecf4;
    border-radius: 999px;
}

.mfa-timer__progreso {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--azul-500), var(--verde-500));
    border-radius: inherit;
    transform-origin: left center;
    transform: scaleX(var(--progreso, 1));
    transition: transform 950ms linear;
}

/* El salto de 0 a 1 al renovarse el código no debe animarse hacia atrás */
.mfa-timer__progreso.sin-transicion {
    transition: none;
}

/* --- Errores de campo ----------------------------------------------------- */

.campo__error {
    margin-top: 8px;
    font-size: 0.84rem;
    line-height: 1.45;
    color: #b3222f;
}

/* --- Ayuda de códigos de respaldo ----------------------------------------- */

.auth-ayuda {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid #edeff5;
    font-size: 0.85rem;
}

.auth-ayuda summary {
    cursor: pointer;
    color: var(--texto-suave);
    list-style: none;
    transition: color var(--transicion);
}

.auth-ayuda summary::-webkit-details-marker { display: none; }

.auth-ayuda summary::before {
    content: "+";
    display: inline-block;
    width: 1.1em;
    font-weight: 600;
}

.auth-ayuda[open] summary::before { content: "\2212"; }

.auth-ayuda summary:hover { color: var(--azul-700); }

.auth-ayuda summary:focus-visible {
    outline: 2px solid var(--azul-500);
    outline-offset: 3px;
    border-radius: 4px;
}

.auth-ayuda p {
    margin-top: 10px;
    padding-left: 1.1em;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--texto-suave);
}

/* --- Volver al login ------------------------------------------------------ */

.auth-volver {
    display: inline-block;
    margin-top: 22px;
    font-size: 0.85rem;
    color: var(--texto-suave);
    text-decoration: none;
    transition: color var(--transicion);
}

.auth-volver:hover {
    color: var(--azul-700);
    text-decoration: underline;
}

.auth-volver:focus-visible {
    outline: 2px solid var(--azul-500);
    outline-offset: 3px;
    border-radius: 4px;
}
