/* ============================================================
   EKKLESIA CONNECT - PAGES AUTH (connexion / inscription)
   Design system partagé avec la landing (landing.css = tokens).
   ============================================================ */

/* ---------- 1. LAYOUT GLOBAL ---------- */
.auth-page {
    min-height: 100vh;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

/* ---------- 2. PANNEAU MARQUE ---------- */
.auth-brand {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(40px, 6vw, 72px);
    background: var(--navy);
    color: #fff;
}

.auth-brand-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 470px;
}

.auth-brand-logo {
    color: #fff;
}

.auth-brand-logo .brand-name {
    color: #fff;
}

.auth-brand-logo .brand-accent {
    color: #7ba7ee;
}

.auth-brand-title {
    margin-top: 30px;
    font-size: clamp(1.65rem, 3vw, 2.35rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.16;
    color: #fff;
}

.auth-brand-sub {
    margin-top: 16px;
    font-size: 1.02rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.75);
}

.auth-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
}

.auth-stat {
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.auth-stat strong {
    color: #fff;
    font-weight: 800;
}

.auth-rank {
    margin-top: 32px;
    padding: 20px 22px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--r-lg);
    background: rgba(255, 255, 255, 0.05);
}

.auth-rank-kicker {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #7ba7ee;
    margin-bottom: 12px;
}

.auth-rank-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
}

.auth-rank-row + .auth-rank-row {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-rank-pos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 800;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.auth-rank-pos--top {
    background: #c99a35;
}

.auth-rank-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-rank-church {
    margin-left: auto;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-rank-pts {
    font-weight: 800;
    font-size: 0.9rem;
    color: #e2b556;
    min-width: 64px;
    text-align: right;
}

.auth-trust {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 32px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.65);
}

.auth-trust-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e2b556;
}

/* ---------- 3. ZONE FORMULAIRE ---------- */
.auth-main {
    display: flex;
    flex-direction: column;     /* la carte, puis les liens légaux dessous (jamais côte à côte) */
    gap: 24px;
    align-items: center;
    justify-content: center;
    padding: clamp(28px, 6vw, 64px);
    background: var(--bg);
}

/* Retour vers l'accueil, au-dessus de la carte (aligné sur sa largeur) */
.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: center;
    width: 100%;
    max-width: 460px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-soft);
    text-decoration: none;
    transition: color 0.2s var(--ease);
}

.auth-back:hover,
.auth-back:focus-visible {
    color: var(--accent);
}

.auth-back svg {
    transition: transform 0.2s var(--ease);
}

.auth-back:hover svg {
    transform: translateX(-3px);
}

/* Liens légaux sous le formulaire : une ligne qui passe à la ligne sur petit écran */
.auth-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 18px;
    max-width: 460px;
    font-size: 0.85rem;
}

.auth-legal a {
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-legal a:hover,
.auth-legal a:focus-visible {
    color: var(--accent);
}

.auth-card {
    width: 100%;
    max-width: 460px;
    animation: auth-enter 0.7s var(--ease) both;
}

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

.auth-mobile-brand {
    display: none;
    margin-bottom: 28px;
}

.auth-title {
    font-size: clamp(1.7rem, 3vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text);
}

.auth-sub {
    margin-top: 8px;
    font-size: 1rem;
    color: var(--text-soft);
}

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

/* ---------- 4. CHAMPS ---------- */
.field {
    margin-top: 22px;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.field-control {
    position: relative;
    display: flex;
    align-items: center;
}

.field-icon {
    position: absolute;
    left: 16px;
    display: inline-flex;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s var(--ease);
}

.field-input {
    width: 100%;
    padding: 14px 16px 14px 46px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}

.field-input::placeholder {
    color: var(--text-muted);
}

select.field-input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 44px;
    cursor: pointer;
}

.field-caret {
    position: absolute;
    right: 16px;
    display: inline-flex;
    color: var(--text-muted);
    pointer-events: none;
}

.field-input[type="password"] {
    padding-right: 52px;
}

.field-control:focus-within .field-input {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(61, 123, 217, 0.16);
}

.field-control:focus-within .field-icon {
    color: var(--accent);
}

.field-action {
    position: absolute;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.field-action:hover {
    background: var(--surface-2);
    color: var(--text);
}

.field-action .eye--closed {
    display: none;
}

.field-action.is-visible .eye--open {
    display: none;
}

.field-action.is-visible .eye--closed {
    display: block;
}

.field-help {
    margin-top: 8px;
    min-height: 18px;
    font-size: 0.82rem;
    color: var(--text-muted);
    transition: color 0.2s var(--ease);
}

.field.is-valid .field-input {
    border-color: #2ea479;
}

.field.is-invalid .field-input {
    border-color: #e5484d;
    box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.13);
}

.field.is-invalid .field-icon {
    color: #e5484d;
}

.field.is-invalid .field-help {
    color: #e5484d;
    font-weight: 600;
}

.field-help.has-meaning {
    color: var(--accent);
    font-weight: 600;
}

@keyframes auth-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}

.field.shake {
    animation: auth-shake 0.5s var(--ease);
}

/* ---------- 5. OPTIONS (rester connecté / oublié) ---------- */
.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 22px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

.checkbox-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: #fff;
    transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.checkbox-box svg {
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.checkbox input:checked + .checkbox-box {
    background: var(--grad-primary);
    border-color: transparent;
}

.checkbox input:checked + .checkbox-box svg {
    opacity: 1;
    transform: scale(1);
}

.checkbox input:focus-visible + .checkbox-box {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.checkbox-label {
    font-size: 0.9rem;
    color: var(--text-soft);
}

.auth-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    transition: color 0.2s var(--ease);
}

.auth-link:hover {
    color: var(--text);
}

/* ---------- 6. BOUTON SOUMISSION ---------- */
.auth-submit {
    position: relative;
    margin-top: 26px;
    width: 100%;
}

.btn-block {
    width: 100%;
}

.auth-submit .btn-loader {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

.auth-submit.is-loading .btn-loader {
    display: inline-block;
}

.auth-submit:disabled {
    cursor: wait;
    opacity: 0.85;
}

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

/* ---------- 7. BASCULE (compte déjà / pas encore) ---------- */
.auth-switch {
    margin-top: 26px;
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-soft);
}

.auth-switch-link {
    font-weight: 700;
    color: var(--accent);
    transition: color 0.2s var(--ease);
}

.auth-switch-link:hover {
    color: var(--text);
}

/* ---------- 8. STEADER INSCRIPTION ---------- */
.auth-steps {
    display: flex;
    align-items: center;
    margin: 30px 0 0;
    padding: 0;
    list-style: none;
}

.auth-step {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.auth-step::after {
    content: "";
    flex: 1;
    height: 2px;
    margin: 0 10px;
    border-radius: 2px;
    background: var(--border);
    transition: background-color 0.3s var(--ease);
}

.auth-step:last-child::after {
    display: none;
}

.auth-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 800;
    transition: all 0.3s var(--ease);
}

.auth-step-num svg {
    display: none;
}

.auth-step-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color 0.3s var(--ease);
}

.auth-step.is-active .auth-step-num {
    background: var(--grad-primary);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.auth-step.is-active .auth-step-label {
    color: var(--text);
}

.auth-step.is-done .auth-step-num {
    background: #2ea479;
    border-color: transparent;
    color: #fff;
}

.auth-step.is-done .auth-step-num svg {
    display: block;
}

.auth-step.is-done::after {
    background: #2ea479;
}

.auth-step.is-done .auth-step-label {
    color: var(--text);
}

.auth-progress {
    height: 4px;
    margin-top: 10px;
    border-radius: 4px;
    background: var(--border);
    overflow: hidden;
}

.auth-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: var(--grad-primary);
    transition: width 0.4s var(--ease);
}

/* ---------- 9. PANNEAUX D'ÉTAPES ---------- */
.auth-panel {
    display: none;
}

.auth-panel.is-active {
    display: block;
    animation: auth-panel-in 0.45s var(--ease);
}

@keyframes auth-panel-in {
    from { opacity: 0; transform: translateX(18px); }
    to   { opacity: 1; transform: none; }
}

.auth-panel-head {
    margin-top: 8px;
}

.auth-panel-head h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.auth-panel-head p {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-nav {
    display: flex;
    gap: 12px;
    margin-top: 26px;
}

.auth-nav .btn {
    flex: 1;
}

/* ---------- 10. JAUGE DE ROBUSTESSE ---------- */
.strength {
    margin-top: 10px;
}

.strength-bar {
    display: flex;
    gap: 6px;
}

.strength-seg {
    height: 5px;
    flex: 1;
    border-radius: 999px;
    background: var(--border);
    transition: background-color 0.3s var(--ease);
}

.strength-label {
    display: block;
    margin-top: 7px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.strength[data-level="1"] .strength-seg:nth-child(-n+1) { background: #e5484d; }
.strength[data-level="2"] .strength-seg:nth-child(-n+2) { background: #e2a03b; }
.strength[data-level="3"] .strength-seg:nth-child(-n+3) { background: var(--accent); }
.strength[data-level="4"] .strength-seg:nth-child(-n+4) { background: #2ea479; }

.strength[data-level="1"] .strength-label { color: #e5484d; font-weight: 600; }
.strength[data-level="2"] .strength-label { color: #e2a03b; font-weight: 600; }
.strength[data-level="3"] .strength-label { color: var(--accent); font-weight: 600; }
.strength[data-level="4"] .strength-label { color: #2ea479; font-weight: 600; }

/* ---------- 11. RÉCAPITULATIF ---------- */
.auth-summary {
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}

.auth-summary-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
}

.auth-summary-item + .auth-summary-item {
    border-top: 1px solid var(--border);
}

.auth-summary-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.auth-summary-value {
    font-weight: 700;
    color: var(--text);
    text-align: right;
}

.auth-summary-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ---------- 12. FLASHES ---------- */
.auth-flashes {
    margin-bottom: 24px;
}

.auth-flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: auth-flash-in 0.5s var(--ease);
    transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.auth-flash + .auth-flash {
    margin-top: 10px;
}

.auth-flash--success {
    background: rgba(46, 164, 121, 0.12);
    color: #177a57;
    border: 1px solid rgba(46, 164, 121, 0.3);
}

.auth-flash--danger {
    background: rgba(229, 72, 77, 0.1);
    color: #c52d33;
    border: 1px solid rgba(229, 72, 77, 0.28);
}

.auth-flash--info {
    background: rgba(61, 123, 217, 0.1);
    color: #2b66b3;
    border: 1px solid rgba(61, 123, 217, 0.3);
}

.auth-flash-icon {
    display: inline-flex;
    margin-top: 1px;
    flex-shrink: 0;
}

.auth-flash.is-leaving {
    opacity: 0;
    transform: translateY(-6px);
}

@keyframes auth-flash-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}

[data-theme="dark"] .auth-flash--success { color: #5fd0a3; }
[data-theme="dark"] .auth-flash--danger  { color: #ff8f8f; }
[data-theme="dark"] .auth-flash--info    { color: #92b8f4; }

/* ---------- 13. TOGGLE THÈME ---------- */
.auth-theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 70;
}

/* ---------- 14. RESPONSIVE ---------- */
@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);   /* `1fr` seul laisse le contenu élargir la colonne au-delà de l'écran */
    }

    /* Étapes de l'inscription : sur petit écran, seule l'étiquette de l'étape en cours est visible (les pastilles
       numérotées montrent la progression) ; les autres restent lues par les lecteurs d'écran. */
    .auth-step {
        min-width: 0;
        gap: 8px;
    }

    .auth-step:not(.is-active) .auth-step-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .auth-brand {
        display: none;
    }

    .auth-mobile-brand {
        display: block;
    }

    .auth-main {
        min-height: 100vh;
        padding: 32px 20px;
    }

    .auth-theme-toggle {
        top: 14px;
        right: 14px;
    }
}

/* ---------- 15. ACCESSIBILITÉ : mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
    .auth-card,
    .auth-panel,
    .auth-flash {
        animation: none !important;
    }

    .field.shake {
        animation: none !important;
    }
}

/* Champs sans icône (vérification du téléphone, mot de passe oublié) */
.field-control--plain .field-input {
    padding-left: 16px;
}

/* Deux formulaires successifs sur la même page (envoi puis saisie du code) */
.auth-form + .auth-form {
    margin-top: 28px;
}

/* Pseudo libre : case à cocher sous la liste biblique, champ affiché à la demande */
.auth-custom-toggle {
    margin-top: 10px;
    font-size: 0.9rem;
}

.field[hidden] {
    display: none;
}

.field.is-muted .field-control {
    opacity: 0.55;
}
