/*
 * IDSwift v2 — shared login overlay styles.
 *
 * Paleta de marca v2 (assets/css/idswift-ui.css): crema de fondo, tarjeta
 * blanca, verde de interfaz --brand. Cada color va como token CON valor
 * literal de respaldo, porque este fichero se carga también sin
 * idswift-ui.css (el configurador, setup/index.html, no lo enlaza) y, en
 * el portal, ANTES que él.
 *
 * Two modes (data-mode attribute on the overlay root):
 *   minimal — just a centred spinner, no card chrome. Used while we
 *             check an existing session. Logged-in users with valid
 *             access never see the full UI.
 *   full    — branded card with hotel logo, name, app badge, form
 *             (or denial state). Used when we actually need the user
 *             to act.
 *
 * Loaded by every v2 app HTML in <head> together with auth-ui.js.
 */

#idsw-auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    /* Centrado con margin:auto en la tarjeta (no align-items:center): si
       la tarjeta es más alta que la ventana (alta MFA con QR, móvil) se
       puede hacer scroll hasta arriba en vez de quedar cortada. */
    padding: 1.5rem;
    background: var(--bg, #fdf9f1);
    font-family: var(--idsw-font, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Inter, Arial, sans-serif);
    color: var(--ink, #0e3d36);
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
    transition: opacity 0.15s ease;
}

#idsw-auth-overlay[data-state="ready"] {
    opacity: 0;
    pointer-events: none;
}

/* Belt-and-braces: my `display: flex` rules below have higher specificity
   than the browser's default `[hidden] { display: none }`, which makes the
   `hidden` HTML attribute a no-op. Without this rule, _setBusy(false)
   would never visually hide the spinner-wrap (since it's display:flex by
   default). */
#idsw-auth-overlay [hidden] {
    display: none !important;
}

/* Minimal mode: only the spinner is visible — no card chrome at all.
   Used during an existing-session check; logged-in users with valid
   access never expand to the full card. */
#idsw-auth-overlay[data-mode="minimal"] .idsw-card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

#idsw-auth-overlay[data-mode="minimal"] .idsw-logo-wrap,
#idsw-auth-overlay[data-mode="minimal"] .idsw-title,
#idsw-auth-overlay[data-mode="minimal"] .idsw-app-badge,
#idsw-auth-overlay[data-mode="minimal"] .idsw-lang,
#idsw-auth-overlay[data-mode="minimal"] form,
#idsw-auth-overlay[data-mode="minimal"] .idsw-error,
#idsw-auth-overlay[data-mode="minimal"] .idsw-secondary,
#idsw-auth-overlay[data-mode="minimal"] .idsw-mfa,
#idsw-auth-overlay[data-mode="minimal"] .idsw-footer {
    display: none !important;
}

/* Full mode card. */
#idsw-auth-overlay .idsw-card {
    position: relative;
    margin: auto;
    width: 100%;
    max-width: 26rem;
    background: var(--paper, #ffffff);
    border: 1px solid var(--line, #d8d1c6);
    border-radius: 16px;
    padding: 2rem 1.75rem 1.75rem;
    box-shadow: 0 12px 32px rgba(14, 61, 54, 0.08);
    letter-spacing: 0.02em;
}

/* ES | EN — esquina superior derecha de la tarjeta. Solo en el login
   inicial: cuando el overlay se relanza con la app ya abierta (MFA a
   mitad de sesión, step-up) el idioma lo manda la cabecera de la app. */
#idsw-auth-overlay .idsw-lang {
    position: absolute;
    top: 0.75rem;
    right: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.72rem;
    color: var(--muted-2, #8a9a96);
}

#idsw-auth-overlay[data-reshow="1"] .idsw-lang { display: none; }

#idsw-auth-overlay .idsw-lang button {
    background: none;
    border: none;
    padding: 0.2rem 0.3rem;
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--muted, #53706b);
    cursor: pointer;
    border-radius: var(--radius, 4px);
}

#idsw-auth-overlay .idsw-lang button:hover { color: var(--ink, #0e3d36); }

#idsw-auth-overlay .idsw-lang button[aria-pressed="true"] {
    color: var(--ink, #0e3d36);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#idsw-auth-overlay .idsw-lang button:focus-visible {
    outline: 2px solid var(--brand, #0e3d36);
    outline-offset: 1px;
}

#idsw-auth-overlay .idsw-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 96px;
    margin-bottom: 1rem;
}

#idsw-auth-overlay .idsw-logo {
    max-height: 96px;
    max-width: 220px;
    object-fit: contain;
}

#idsw-auth-overlay .idsw-logo-placeholder {
    width: 96px;
    height: 96px;
    border-radius: 14px;
    background: var(--brand, #0e3d36);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--brand-text, #f1ece0);
    letter-spacing: 0.02em;
}

#idsw-auth-overlay .idsw-title {
    margin: 0 0 0.25rem 0;
    font-size: 1.35rem;
    font-weight: 600;
    text-align: center;
    color: var(--ink, #0e3d36);
    line-height: 1.25;
}

/* Píldora neutra con punto «en servicio». */
#idsw-auth-overlay .idsw-app-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: fit-content;
    margin: 0.35rem auto 1.5rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: var(--line-soft, #ece7dc);
    font-size: 0.72rem;
    color: var(--ink-soft, #2a4e47);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

#idsw-auth-overlay .idsw-app-badge:empty { display: none; }

#idsw-auth-overlay .idsw-app-badge::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok, #1b7f55);
}

#idsw-auth-overlay form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

#idsw-auth-overlay label {
    display: block;
    font-size: 0.72rem;
    color: var(--ink-soft, #2a4e47);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

#idsw-auth-overlay input[type="email"],
#idsw-auth-overlay input[type="password"] {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--line, #d8d1c6);
    background: var(--paper, #ffffff);
    color: var(--ink, #0e3d36);
    font-size: 0.95rem;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

#idsw-auth-overlay input[type="email"]:focus,
#idsw-auth-overlay input[type="password"]:focus {
    outline: none;
    border-color: var(--brand, #0e3d36);
    background: var(--paper, #ffffff);
    box-shadow: 0 0 0 3px rgba(14, 61, 54, 0.15);
}

#idsw-auth-overlay input::placeholder { color: var(--muted-2, #8a9a96); }

#idsw-auth-overlay button[type="submit"] {
    margin-top: 0.6rem;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    border: none;
    background: var(--brand, #0e3d36);
    color: var(--brand-text, #f1ece0);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s, opacity 0.15s,
        transform 0.05s;
}

#idsw-auth-overlay button[type="submit"]:hover:not(:disabled) {
    background: var(--brand-2, #0a2f2a);
    box-shadow: 0 4px 14px rgba(14, 61, 54, 0.14);
}

#idsw-auth-overlay button[type="submit"]:active:not(:disabled) {
    transform: translateY(1px);
}

#idsw-auth-overlay button[type="submit"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#idsw-auth-overlay .idsw-error {
    min-height: 1.2rem;
    margin-top: 0.5rem;
    color: var(--err, #c4473d);
    font-size: 0.85rem;
    text-align: center;
    line-height: 1.35;
}

#idsw-auth-overlay .idsw-error[hidden] { display: none; }

#idsw-auth-overlay .idsw-spinner-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 0 0.25rem;
}

#idsw-auth-overlay .idsw-spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--line-soft, #ece7dc);
    border-top-color: var(--brand, #0e3d36);
    animation: idsw-spin 0.8s linear infinite;
}

#idsw-auth-overlay .idsw-spinner-label {
    font-size: 0.85rem;
    color: var(--muted, #53706b);
}

@keyframes idsw-spin { to { transform: rotate(360deg); } }

#idsw-auth-overlay .idsw-footer {
    margin-top: 1.4rem;
    text-align: center;
    font-size: 0.7rem;
    color: var(--muted-2, #8a9a96);
    letter-spacing: 0.04em;
}

#idsw-auth-overlay .idsw-secondary {
    margin-top: 0.85rem;
    text-align: center;
}

#idsw-auth-overlay .idsw-secondary button {
    background: none;
    border: none;
    color: var(--brand, #0e3d36);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    padding: 0.25rem 0.5rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}

#idsw-auth-overlay .idsw-secondary button:hover { color: var(--brand-2, #0a2f2a); }

/* ---- MFA (verificación en dos pasos) ---------------------------- */

#idsw-auth-overlay .idsw-mfa {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    text-align: center;
}

#idsw-auth-overlay .idsw-mfa-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink, #0e3d36);
}

#idsw-auth-overlay .idsw-mfa-sub {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted, #53706b);
    line-height: 1.45;
}

#idsw-auth-overlay .idsw-mfa-qr {
    width: 180px;
    height: 180px;
    margin: 0.35rem auto;
    padding: 0;
    background: #ffffff;   /* el QR necesita blanco puro, no el token */
    border: 1px solid var(--line, #d8d1c6);
    border-radius: 10px;
    overflow: hidden;
}

#idsw-auth-overlay .idsw-mfa-qr svg {
    width: 100%;
    height: 100%;
    display: block;
}

#idsw-auth-overlay .idsw-mfa-secret-label {
    margin: 0.2rem 0 0;
    font-size: 0.72rem;
    color: var(--ink-soft, #2a4e47);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

#idsw-auth-overlay .idsw-mfa-secret {
    display: inline-block;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    background: var(--bg, #fdf9f1);
    border: 1px dashed var(--line, #d8d1c6);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: var(--ink, #0e3d36);
    user-select: all;
    word-break: break-all;
}

#idsw-auth-overlay input.idsw-mfa-code {
    width: 9.5rem;
    padding: 0.65rem 0.5rem;
    border-radius: 10px;
    border: 1px solid var(--line, #d8d1c6);
    background: var(--paper, #ffffff);
    color: var(--ink, #0e3d36);
    font-size: 1.35rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    text-align: center;
    letter-spacing: 0.45em;
    box-sizing: border-box;
}

#idsw-auth-overlay input.idsw-mfa-code:focus {
    outline: none;
    border-color: var(--brand, #0e3d36);
    box-shadow: 0 0 0 3px rgba(14, 61, 54, 0.15);
}

#idsw-auth-overlay input.idsw-mfa-code::placeholder { color: var(--muted-2, #8a9a96); }

#idsw-auth-overlay button.idsw-mfa-verify {
    min-width: 9.5rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: none;
    background: var(--brand, #0e3d36);
    color: var(--brand-text, #f1ece0);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
}

#idsw-auth-overlay button.idsw-mfa-verify:hover:not(:disabled) { background: var(--brand-2, #0a2f2a); }
#idsw-auth-overlay button.idsw-mfa-verify:disabled { opacity: 0.55; cursor: not-allowed; }

/* Llave de seguridad: segundo camino dentro de la misma pantalla MFA.
   Botón secundario (contorno) para que el código siga siendo el primario
   cuando el usuario tiene ambos factores. */
#idsw-auth-overlay .idsw-mfa-key-sep {
    margin: 0.9rem 0 0.55rem;
    color: var(--muted-2, #8a9a96);
    font-size: 0.8rem;
    text-align: center;
}

#idsw-auth-overlay button.idsw-mfa-key-btn {
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--brand, #0e3d36);
    background: var(--paper, #ffffff);
    color: var(--brand, #0e3d36);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
}

#idsw-auth-overlay button.idsw-mfa-key-btn:hover:not(:disabled) { background: var(--line-soft, #ece7dc); }
#idsw-auth-overlay button.idsw-mfa-key-btn:disabled { opacity: 0.55; cursor: not-allowed; }

#idsw-auth-overlay .idsw-mfa-key-hint {
    margin: 0.45rem 0 0;
    color: var(--muted, #53706b);
    font-size: 0.8rem;
    line-height: 1.35;
    text-align: center;
}

#idsw-auth-overlay .idsw-mfa-error {
    margin: 0;
    min-height: 1.1rem;
    color: var(--err, #c4473d);
    font-size: 0.85rem;
    line-height: 1.35;
}

@media (max-width: 480px) {
    #idsw-auth-overlay .idsw-card {
        padding: 1.5rem 1.25rem 1.25rem;
        border-radius: 12px;
    }
    #idsw-auth-overlay .idsw-title { font-size: 1.2rem; }
    #idsw-auth-overlay .idsw-lang { top: 0.5rem; right: 0.6rem; }
}

/* «He olvidado mi contraseña» — enlace discreto bajo el botón de entrar.
 * Oculto salvo que la página pase sendPasswordResetEmail (auth-ui.js). */
#idsw-auth-overlay .idsw-forgot {
    display: block;
    margin: 10px auto 0;
    background: none;
    border: none;
    color: var(--muted, #53706b);
    font-size: 12.5px;
    text-decoration: underline;
    cursor: pointer;
    font-family: inherit;
}
#idsw-auth-overlay .idsw-forgot:hover { color: var(--brand, #0e3d36); }
#idsw-auth-overlay .idsw-forgot[hidden] { display: none; }
#idsw-auth-overlay .idsw-forgot:disabled { opacity: .5; cursor: default; }

/* Step-up (comprobante de un uso): botón de cancelar bajo el código */
#idsw-auth-overlay .idsw-mfa-cancel { margin-top: 10px; background: none; border: 0; color: var(--muted, #53706b); text-decoration: underline; cursor: pointer; font: inherit; }
#idsw-auth-overlay .idsw-mfa-cancel:hover { color: var(--brand, #0e3d36); }

/* Salidas de la pantalla del código (portal/configurador) */
.idsw-mfa-exit { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-top: 14px; }
.idsw-mfa-link { background: none; border: 0; padding: 0; color: var(--brand, #0e3d36); font-size: 12.5px; cursor: pointer; text-decoration: underline; font-family: inherit; }
.idsw-mfa-link:hover { color: var(--brand-2, #0a2f2a); }
.brand-lockup--small .brand-lockup__product { font-size: 13px; }
