/* ============================================================
   Demo Auth — Login, register, account modals
   ============================================================ */

/* ============================================================
   AUTH MODALS — With branding header
   ============================================================ */

.auth-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.auth-modal-overlay.active { display: flex; }

.auth-modal {
    background: var(--c-bg-elevated);
    border-radius: 20px;
    padding: 32px;
    width: 90%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn var(--dur-normal) var(--ease-spring);
    position: relative;
}

.auth-modal-wide { max-width: 460px; }

.auth-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--c-text-muted);
    cursor: pointer;
    transition: background var(--dur-fast), color var(--dur-fast);
    z-index: 1;
}

.auth-modal-close:hover {
    background: var(--c-bg-warm);
    color: var(--c-text);
}

/* ---- Branding header ---- */

.auth-modal-branding {
    text-align: center;
    margin-bottom: 28px;
    padding-top: 4px;
}

.auth-branding-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border-light);
    color: var(--c-primary);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.auth-branding-icon-warning {
    background: var(--c-bg-card);
    border-color: rgba(220, 38, 38, 0.3);
    color: var(--c-danger);
}

.auth-modal-branding h2 {
    font-family: var(--f-display);
    font-size: 1.5rem;
    font-weight: 500;
    font-style: italic;
    color: var(--c-text);
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin-bottom: 6px;
}

.auth-branding-subtitle {
    font-size: 0.88rem;
    color: var(--c-text-secondary);
    line-height: 1.5;
}

/* ---- Form elements ---- */

.auth-modal-body {
    display: flex;
    flex-direction: column;
}

.auth-form-group {
    margin-bottom: 14px;
}

.auth-form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--c-text-secondary);
    margin-bottom: 4px;
}

.auth-form-group input,
.auth-form-group select,
.auth-form-group textarea,
.auth-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    font-family: var(--f-body);
    font-size: 16px;
    color: var(--c-text);
    background: var(--c-bg-card);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

/* iOS : <input type="date"> garde une largeur NATIVE intrinsèque (-webkit-appearance)
   qui ignore width:100% / box-sizing → débordement à droite (ex. ligne 2 colonnes
   « Date de naissance » du formulaire animal, ou carnet de santé). On neutralise
   l'apparence native pour qu'il respecte son conteneur ; le sélecteur de date natif
   s'ouvre toujours au tap. */
.auth-input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
    /* iOS : un <input type=date> VIDE + appearance:none n'a pas de hauteur de contenu →
       il se rend tout petit tant qu'on ne l'a pas focus/rempli. On force une hauteur
       explicite alignée sur les autres champs pour éviter le « saut » au tap. */
    box-sizing: border-box;
    min-height: 44px;
}

.auth-form-group input:focus,
.auth-form-group select:focus,
.auth-form-group textarea:focus,
.auth-input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: var(--focus-ring);
    background: var(--c-bg-elevated);
}

.auth-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--c-text-muted);
    margin-top: 3px;
}

.auth-remember-group {
    margin: -4px 0 14px;
}

.auth-remember-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--c-text-secondary);
    user-select: none;
    -webkit-user-select: none;
}

.auth-remember-checkbox {
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin: 0;
    accent-color: var(--c-primary);
    cursor: pointer;
}

.auth-form-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 6px 0 14px;
    font-size: 0.82rem;
    color: var(--c-text-secondary);
    line-height: 1.45;
}

.auth-form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin: 2px 0 0;
    accent-color: var(--c-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.auth-form-checkbox label {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.auth-form-checkbox a {
    color: var(--c-primary);
    text-decoration: underline;
}

.auth-form-checkbox a:hover {
    color: var(--c-primary-soft, var(--c-primary));
}

.auth-error {
    font-size: 0.82rem;
    color: var(--c-danger);
    min-height: 0;
    margin-bottom: 4px;
}

.auth-error:empty { display: none; }

.auth-turnstile {
    display: flex;
    justify-content: center;
    margin: 12px 0;
    min-height: 0;
}
.auth-turnstile:empty { display: none; }

.auth-submit-btn {
    display: block;
    width: 100%;
    padding: 13px 16px;
    border: none;
    border-radius: var(--r-md);
    background: var(--c-text);
    color: var(--c-bg-card);
    font-family: var(--f-body);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: -0.005em;
    transition: background var(--dur-fast), transform var(--dur-fast);
    box-shadow: var(--shadow-sm);
}

.auth-submit-btn:hover { background: var(--c-primary); }
.auth-submit-btn:active { transform: scale(0.98); }

.auth-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.auth-cancel-btn {
    display: block;
    padding: 11px 16px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    background: transparent;
    color: var(--c-text-secondary);
    font-family: var(--f-body);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}

.auth-cancel-btn:hover {
    background: var(--c-bg-warm);
    border-color: var(--c-text-secondary);
    color: var(--c-text);
}

.auth-danger-btn {
    display: block;
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--c-danger);
    border-radius: var(--r-md);
    background: transparent;
    color: var(--c-danger);
    font-family: var(--f-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--dur-fast), color var(--dur-fast);
}

.auth-danger-btn:hover {
    background: var(--c-danger);
    color: white;
}

.auth-switch {
    text-align: center;
    font-size: 0.82rem;
    color: var(--c-text-muted);
    margin-top: 16px;
}

.auth-switch a {
    color: var(--c-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(27, 85, 92, 0.4);
    text-decoration-thickness: 1px;
    font-weight: 600;
    transition: text-decoration-color var(--dur-fast);
}

/* Séparateur + bouton inscription secondaire sous le formulaire de connexion */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 18px 0 12px;
    font-size: 0.8rem;
    color: var(--c-text-muted);
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--c-border-light);
}

.auth-secondary-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--c-primary);
    border-radius: var(--r-md);
    background: transparent;
    color: var(--c-primary);
    font-family: var(--f-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: -0.005em;
    transition: background var(--dur-fast), color var(--dur-fast);
}

.auth-secondary-btn:hover {
    background: var(--c-primary);
    color: var(--c-text-inverse);
}

.auth-switch a:hover {
    text-decoration-color: var(--c-primary);
}

/* Forgot password link (sous le bouton login) */
.auth-forgot {
    text-align: center;
    margin-top: 12px;
    margin-bottom: 0;
}

.forgot-password-link {
    font-size: 0.82rem;
    color: var(--c-text-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(0, 0, 0, 0.15);
    text-decoration-thickness: 1px;
    transition: color var(--dur-fast), text-decoration-color var(--dur-fast);
}

.forgot-password-link:hover {
    color: var(--c-primary);
    text-decoration-color: var(--c-primary);
}

/* Visually hidden (accessible label) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   ACCOUNT MODAL SECTIONS
   ============================================================ */

.account-section {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--c-border-light);
}

.account-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.account-section-title {
    font-family: var(--f-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-text);
    letter-spacing: -0.005em;
    margin-bottom: 14px;
}

.danger-zone { border-color: rgba(220, 38, 38, 0.2); }
.danger-zone .account-section-title { color: var(--c-danger); }

/* #13 — Connexions sociales liées (Mon compte → Connexions) */
.account-connections {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.account-connection {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    background: var(--c-bg-warm);
    border: 1px solid var(--c-border-light);
    border-radius: 12px;
}
.account-connection-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.account-connection-name {
    font-weight: 600;
    color: var(--c-text);
}
.account-connection-email {
    font-size: 12px;
    color: var(--c-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}
.account-unlink-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-danger);
    background: transparent;
    border: 1px solid rgba(220, 38, 38, 0.28);
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.account-unlink-btn:hover { background: rgba(220, 38, 38, 0.08); }
.account-unlink-reauth {
    flex-basis: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.account-unlink-reauth-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.account-unlink-reauth-actions .auth-secondary-btn,
.account-unlink-reauth-actions .auth-danger-btn {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
}

/* ============================================================
   ACCOUNT MODAL — Password input + show/hide toggle + live rules
   (aligné sur templates/pages/auth/reset_password.twig)
   ============================================================ */

.account-input-wrap {
    position: relative;
}

.account-input-wrap .auth-input {
    padding-right: 44px;
}

.account-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 7px;
    color: var(--c-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: color 0.15s, background-color 0.15s;
}

.account-toggle:hover {
    color: var(--c-primary);
    background-color: var(--c-bg);
}

.account-toggle:focus-visible {
    outline: 2px solid var(--c-primary-soft);
    outline-offset: 1px;
}

.account-toggle svg {
    width: 18px;
    height: 18px;
    display: block;
}

.account-rules {
    list-style: none;
    margin: 4px 0 14px;
    padding: 12px 14px;
    font-size: 0.82rem;
    color: var(--c-text-muted);
    background: var(--c-bg);
    border-radius: 10px;
}

.account-rule {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 5px;
    transition: color 0.2s;
}

.account-rule:last-child {
    margin-bottom: 0;
}

.account-rule.valid {
    color: var(--c-success);
}

.account-rule-icon {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.account-rule-icon svg {
    width: 10px;
    height: 10px;
    opacity: 0;
    transition: opacity 0.15s;
}

.account-rule.valid .account-rule-icon {
    background-color: var(--c-success);
    border-color: var(--c-success);
    color: var(--c-text-inverse);
}

.account-rule.valid .account-rule-icon svg {
    opacity: 1;
}

/* ============================================================
   RESPONSIVE — Auth
   ============================================================ */

/* Mobile (< 768px) */
@media (max-width: 767px) {
    /* Auth modals: full screen on mobile */
    .auth-modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: 24px 20px;
    }

    .auth-modal-wide { max-width: 100%; }
}

/* [V3.5] Menu compte — overlay + bottom-sheet (sous v2-skin). Réutilise modalIn (desktop)
   et v2SheetUp (mobile, keyframe globale définie dans demo-settings.css). */
.account-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.account-menu-overlay.active { display: flex; }
.account-menu {
    background: var(--c-bg-elevated);
    border-radius: 20px;
    padding: 18px;
    width: 90%;
    max-width: 380px;
    box-shadow: var(--shadow-xl);
    animation: modalIn var(--dur-normal) var(--ease-spring);
}
.account-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--c-border-light);
    margin-bottom: 8px;
}
.account-menu-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--c-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}
.account-menu-name {
    font-weight: 500;
    color: var(--c-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-menu-list { display: flex; flex-direction: column; gap: 2px; }
.account-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 10px;
    border: none;
    background: transparent;
    color: var(--c-text);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    border-radius: var(--r-md);
}
.account-menu-item:hover { background: var(--c-bg-warm); }
.account-menu-item svg { flex-shrink: 0; color: var(--c-text-muted); }
.account-menu-item.danger { color: var(--c-danger); }
.account-menu-item.danger svg { color: var(--c-danger); }
/* Les items togglés par openAccountMenu (login/register vs account/logout) le sont via
   l'attribut [hidden] ; sans cette règle, .account-menu-item{display:flex} l'écrase →
   « Se connecter » / « S'inscrire » restaient visibles même connecté. */
.account-menu-item[hidden],
.account-menu-header[hidden] { display: none; }
.account-menu-lang {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
}
.account-menu-lang-btn {
    min-width: 40px;
    padding: 6px 10px;
    border: 1px solid var(--c-border);
    background: var(--c-bg-card);
    color: var(--c-text-secondary);
    border-radius: var(--r-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.account-menu-lang-btn.active {
    background: var(--c-primary-light);
    border-color: var(--c-primary);
    color: var(--c-primary);
}
.sheet-grab { display: none; }
@media (max-width: 767px) {
    body.v2-skin .account-menu-overlay { align-items: flex-end; }
    body.v2-skin .account-menu {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        animation: v2SheetUp var(--dur-normal) var(--ease-out);
    }
    body.v2-skin .sheet-grab {
        display: block;
        width: 36px;
        height: 5px;
        border-radius: 999px;
        background: var(--c-border);
        margin: 0 auto 14px;
    }
}

/* [V2-SKIN] Account + Limit en bottom-sheet (Atelier-iOS). Login/Register/Forgot RESTENT
   fullscreen (formulaires à clavier → un sheet draggable = dismiss accidentel pendant la
   frappe). Scopé par ID d'overlay (spécificité > le fullscreen .auth-modal ci-dessus).
   v2SheetUp défini dans demo-settings.css (keyframe globale). CSS only. [V2.5] */
@media (max-width: 767px) {
    body.v2-skin #accountOverlay,
    body.v2-skin #limitOverlay { align-items: flex-end; }
    body.v2-skin #accountOverlay .auth-modal,
    body.v2-skin #limitOverlay .auth-modal {
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        padding: 14px 24px max(24px, env(safe-area-inset-bottom));
        animation: v2SheetUp var(--dur-normal) var(--ease-out);
    }
    body.v2-skin #accountOverlay .auth-modal::before,
    body.v2-skin #limitOverlay .auth-modal::before {
        content: "";
        display: block;
        width: 36px;
        height: 5px;
        border-radius: 999px;
        background: var(--c-border);
        margin: 0 auto 14px;
    }
}

/* ------------------------------------------------------------------ */
/* Login social (Apple / Google) — boutons SSO en tête des modales    */
/* ------------------------------------------------------------------ */
.auth-sso {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 4px;
}
.auth-sso-slot {
    display: flex;
    justify-content: center;
    /* Réserve la hauteur du bouton GIS (40px) AVANT son arrivée async : sans ça, toute la
       modale saute quand l'iframe se charge, puis re-swap générique → personnalisé
       (utilisateur déjà connecté à Google) — scintillement vécu. */
    min-height: 40px;
}
/* Squelette pilule discret tant que le slot est vide (chargement GIS) — même gabarit que
   le bouton final (miroir GIS #747775, cf. .auth-sso-btn). */
.auth-sso-slot:empty::before {
    content: '';
    width: 100%;
    max-width: 400px;
    height: 40px;
    border: 1px solid #747775;
    border-radius: 20px;
    opacity: 0.3;
}
/* Bouton "maison" (Apple web + shell, Google natif dans le shell) — HARMONISÉ avec
   l'iframe GIS du bouton Google web, qui n'est PAS stylable (thème outline figé par
   Google : hauteur 40px, pilule, bordure #747775, texte #1f1f1f, label 14px/500).
   On copie EXACTEMENT ces métriques pour que la paire soit jumelle. Les couleurs sont
   volontairement en dur : elles miroitent l'iframe GIS, PAS la palette Woopets — ne
   jamais les migrer vers var(--c-*). Apple blanc + bordure = variante officielle HIG. */
.auth-sso-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 400px; /* = plafond width du renderButton GIS */
    margin: 0 auto;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #747775;
    border-radius: 20px;
    background: #fff;
    color: #1f1f1f;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.auth-sso-btn:hover { background: #f5f5f5; }
.auth-sso-btn:active { background: #ececec; }
.auth-sso-btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.auth-sso-btn svg { flex-shrink: 0; }
.auth-sso-error {
    color: var(--c-danger);
    font-size: 13px;
    text-align: center;
}
.auth-sso-error:empty { display: none; }
/* #11 : microcopy CGU/confidentialité sous les boutons SSO (consentement au clic, discret). */
.auth-sso-terms {
    margin: 10px 2px 2px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--c-text-muted);
    text-align: center;
}
.auth-sso-terms a {
    color: var(--c-text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.auth-sso-terms a:hover { color: var(--c-primary); }
/* Le diviseur "ou" reprend .auth-divider ; petit espacement propre au bloc SSO. */
.auth-sso-or { margin: 6px 0 2px; }

@media (hover: none) and (pointer: coarse) {
    .auth-sso-btn:hover { background: #fff; }
}
