/* KS Home Manager — Auth Gate — v2.0
   Nessun blur/lock, nessun exit overlay custom (usato beforeunload nativo).
   Tutti i selettori usano il prefisso ks- per i nuovi elementi. */

/* ── Gate di registrazione (inline nel pannello) ── */
.ks-register-gate {
    padding: 20px 24px 24px;
    border-top: 1px solid rgba(218, 234, 245, 0.80);
}

/* Animazione entrata */
.ks-register-gate:not([hidden]) {
    animation: ks-gate-in 300ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes ks-gate-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ks-register-gate[hidden] { display: none !important; }

/* ── Headline e sub ──────────────────────────────── */
.ks-gate-headline {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    color: #162660;
    letter-spacing: -0.02em;
}

.ks-gate-sub {
    margin: 0 0 18px;
    font-size: 13px;
    color: #5a7290;
    line-height: 1.45;
}

/* ── Pulsante Google ─────────────────────────────── */
.ks-google-wrap { margin-bottom: 0; }

.ks-btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 65px;
    border: 1.5px solid #DAEAF5;
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #1A2A4F;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.ks-btn-google:hover {
    border-color: #4285F4;
    background: #f8fbff;
    box-shadow: 0 2px 10px rgba(66, 133, 244, 0.15);
}

.ks-btn-google:active { background: #f0f6ff; }

.ks-btn-google.ks-loading {
    opacity: 0.65;
    pointer-events: none;
}

/* ── Divisore ────────────────────────────────────── */
.ks-gate-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0 10px;
    font-size: 11px;
    color: #b0c4d4;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ks-gate-divider::before,
.ks-gate-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #DAEAF5;
}

/* ── Link toggle email ───────────────────────────── */
.ks-toggle-email-btn {
    display: block;
    width: 100%;
    margin-bottom: 0;
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 12px;
    color: #8fa5b8;
    text-align: center;
    cursor: pointer;
    transition: color 150ms ease;
}

.ks-toggle-email-btn:hover { color: #0063FA; }
.ks-toggle-email-btn[hidden] { display: none !important; }

/* ── Campi email + password (slide-down) ─────────── */
.ks-email-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

input#ks-gate-email {
    height: 65px;
}

.ks-email-fields[hidden] { display: none !important; }

/* ── Input generici del gate ─────────────────────── */
.ks-gate-input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1.5px solid #DAEAF5;
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    color: #1A2A4F;
    outline: none;
    transition: border-color 180ms ease, box-shadow 180ms ease;
    box-sizing: border-box;
}

.ks-gate-input:focus {
    border-color: #0063FA;
    box-shadow: 0 0 0 3px rgba(0, 99, 250, 0.12);
}

.ks-gate-input::placeholder { color: #b0c4d4; }

/* ── Wrapper password (per eventuale toggle show/hide) */
.ks-password-wrap { position: relative; }

/* ── Errore ─────────────────────────────────────── */
.ks-gate-error {
    margin: 0;
    padding: 8px 12px;
    border-radius: 6px;
    background: #fff3f3;
    border-left: 3px solid #e53e3e;
    font-size: 12px;
    color: #c53030;
    font-weight: 500;
    animation: ks-gate-in 200ms ease;
}

.ks-gate-error[hidden] { display: none !important; }

/* ── Pulsante primario ───────────────────────────── */
.ks-btn-primary {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #162660 0%, #0063FA 100%);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 180ms ease, transform 130ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ks-btn-primary:hover  { opacity: 0.90; transform: translateY(-1px); }
.ks-btn-primary:active { opacity: 1;    transform: translateY(0); }

.ks-btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* Spinner caricamento */
.ks-btn-primary.ks-loading {
    pointer-events: none;
    opacity: 0.72;
}

.ks-btn-primary.ks-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ks-spin 600ms linear infinite;
    margin-left: 8px;
}

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

/* ── Nota privacy ────────────────────────────────── */
.ks-gate-note {
    margin: 14px 0 0;
    font-size: 11px;
    color: #5a7290;
    text-align: center;
    line-height: 1.5;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
    .ks-register-gate { padding: 18px 20px 22px; }
}

/* ════════════════════════════════════════════════════
   v2.1 — Gate integrato nel Blocco A (step 4)
   ════════════════════════════════════════════════════ */

/* Il gate ora vive dentro kshm-ba-panel, usa stesso padding */
#kshm-field-a4 .ks-register-gate {
    padding: 0 0 8px;
}

/* ── Link-style button (Accedi / Torna a registrazione) ── */
.ks-gate-link {
    display: inline-block;
    margin-top: 10px;
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 12px;
    color: #8fa5b8;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 150ms ease;
    line-height: 1.4;
}

.ks-gate-link:hover { color: #0063FA; }

/* ── Input OTP — grande, centrato, mono ─────────────── */
.ks-gate-input--otp {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.25em;
    height: 56px;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
    margin-top: 8px;
}

/* ── Hint OTP (es. "Abbiamo inviato a ...") ─────────── */
.ks-gate-otp-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: #5a7290;
    line-height: 1.5;
}

.ks-gate-otp-hint strong {
    color: #162660;
    word-break: break-all;
}

/* ── Form container — gap verticale uniforme ─────────── */
#ks-gate-form-register,
#ks-gate-form-otp,
#ks-gate-form-login {
    display: flex;
    flex-direction: column;
}

#ks-gate-form-register[hidden],
#ks-gate-form-otp[hidden],
#ks-gate-form-login[hidden] { display: none !important; }

/* ── Google button — fallback statico pre-GIS ─────────── */
#ks-login-google.ks-btn-google {
    /* GIS sostituirà il contenuto quando configurato.
       Nel frattempo il pulsante statico è visivamente coerente. */
    cursor: pointer;
}

/* ── Note toggle (Hai già un account / Non hai un account) ── */
#ks-gate-note-register[hidden],
#ks-gate-note-login[hidden] { display: none !important; }

/* ── Responsive gate step 4 ─────────────────────────── */
@media (max-width: 480px) {
    .ks-gate-input--otp {
        font-size: 22px;
        letter-spacing: 0.18em;
        height: 50px;
    }
}

/* ── 2026-10-11 — Gate "contatto" (Impostazioni → Percorso valutazione) ── */
.ks-gate-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.4;
    color: #3a4a66;
    cursor: pointer;
    text-align: left;
}
.ks-gate-check input {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    accent-color: #0063FA;
}
.ks-gate-form-contact .ks-gate-note a { color: inherit; text-decoration: underline; }
#ks-gate-account[hidden],
.ks-gate-form-contact[hidden] { display: none !important; }
