/**
 * Login page styles. Extracted from login.html for SoC/CSP hygiene.
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f8fafc;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s;
}

body.dark-mode {
    background: #0f172a;
}

.login-container {
    background: white;
    padding: 40px;
    /* Encoche / barre de statut : éviter titre collé au bord du card */
    padding-top: max(calc(env(safe-area-inset-top, 0px) + 28px), 44px);
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 24px);
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 450px;
    animation: slideIn 0.4s ease-out;
    transition: background 0.3s, color 0.3s;
    /* APK WebView : empêcher un iframe / couche tierce de capter les taps au-dessus des onglets */
    position: relative;
    isolation: isolate;
}

body.dark-mode .login-container {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 30px;
}

.logo h1 {
    color: #0ea5e9;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 5px;
}

.logo .version {
    color: #999;
    font-size: 14px;
    font-weight: 400;
}

.login-form {
    margin-top: 30px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
    transition: color 0.3s;
}

body.dark-mode .form-group label {
    color: #e6edf3;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s;
    font-family: monospace;
    background: white;
    color: #333;
}

body.dark-mode .form-group input {
    background: #0d1117;
    border-color: #30363d;
    color: #e6edf3;
}

.form-group input:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

body.dark-mode .form-group input:focus {
    border-color: #58a6ff;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: #0ea5e9;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    margin-top: 10px;
}

.btn-login:hover {
    background: #0284c7;
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: #0ea5e9;
    border: 2px solid #0ea5e9;
    margin-top: 12px;
}

body.dark-mode .btn-secondary {
    color: #58a6ff;
    border-color: #58a6ff;
}

/* Social login buttons */
.social-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    position: relative;
    z-index: 0;
}

.btn-social {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    border: 1px solid #e2e8f0;
}

.btn-social:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-social:active {
    transform: translateY(0);
}

.btn-social:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-google {
    background: white;
    color: #333;
}

body.dark-mode .btn-google {
    background: #1e293b;
    color: #e6edf3;
    border-color: #334155;
}


.btn-social svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: #999;
    font-size: 13px;
}

/* Séparateur avant Google (bloc déplacé sous les formulaires sur login.html) */
.login-divider-oauth {
    margin-top: 28px;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

body.dark-mode .divider::before, body.dark-mode .divider::after {
    background: #334155;
}

/* Auth tabs */
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
    position: relative;
    z-index: 10;
    touch-action: manipulation;
    pointer-events: auto;
}

body.dark-mode .auth-tabs {
    border-color: #334155;
}

.auth-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #999;
    cursor: pointer;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    touch-action: manipulation;
}

@media (max-width: 520px) {
    .auth-tab {
        min-height: 48px;
        padding: 12px 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.auth-tab.active {
    color: #0ea5e9;
    border-bottom-color: #0ea5e9;
}

body.dark-mode .auth-tab.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

.auth-tab:hover:not(.active) {
    color: #666;
}

.auth-panel {
    display: none;
}

.auth-panel.active {
    display: block;
}

.register-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: #666;
}

.register-link a {
    color: #0ea5e9;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

body.dark-mode .register-link {
    color: #8b949e;
}

body.dark-mode .register-link a {
    color: #58a6ff;
}

.register-link a:hover {
    text-decoration: underline;
}

.info-box {
    background: #f8f9fa;
    border-left: 4px solid #0ea5e9;
    padding: 15px;
    border-radius: 8px;
    margin-top: 25px;
    font-size: 14px;
    color: #666;
    transition: background 0.3s, color 0.3s;
}

body.dark-mode .info-box {
    background: #161b22;
    color: #8b949e;
}

.info-box strong {
    color: #333;
    display: block;
    margin-bottom: 8px;
}

body.dark-mode .info-box strong {
    color: #e6edf3;
}

.info-box a {
    color: #0ea5e9;
    text-decoration: none;
    font-weight: 500;
}

body.dark-mode .info-box a {
    color: #58a6ff;
}

.info-box a:hover {
    text-decoration: underline;
}

/* P1-4 (V4.8.343) — info-box repliable (info Telegram). Reduit l'encombrement
   du panel login mobile : 12+ lignes a 1 ligne quand replie. */
.info-box-collapsible > summary {
    cursor: pointer;
    font-weight: 600;
    color: #333;
    list-style: none;
    padding: 4px 0;
    user-select: none;
}
.info-box-collapsible > summary::-webkit-details-marker { display: none; }
.info-box-collapsible > summary::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.18s ease;
    margin-right: 4px;
}
.info-box-collapsible[open] > summary::before {
    transform: rotate(90deg);
}
body.dark-mode .info-box-collapsible > summary { color: #e6edf3; }
.info-box-body { margin-top: 10px; }

.error-message {
    background: #fee;
    border-left: 4px solid #f44;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    color: #c00;
    font-size: 14px;
    display: none;
}

.success-message {
    background: #efe;
    border-left: 4px solid #4c4;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    color: #060;
    font-size: 14px;
    display: none;
}

.loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Options empreinte : bloc discret */
.biometric-options {
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(14, 165, 233, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(14, 165, 233, 0.2);
    font-size: 13px;
    text-align: center;
}
body.dark-mode .biometric-options {
    background: rgba(88, 166, 255, 0.08);
    border-color: rgba(88, 166, 255, 0.2);
}
.biometric-options .biometric-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.biometric-options input[type="checkbox"] {
    cursor: pointer;
    accent-color: #0ea5e9;
}
.biometric-options .biometric-login-link {
    display: block;
    width: fit-content;
    margin: 8px auto 0;
    color: #0ea5e9;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    text-decoration: underline;
}
.biometric-options .biometric-login-link:hover {
    color: #5a67d8;
}
body.dark-mode .biometric-options .biometric-login-link {
    color: #58a6ff;
}
body.dark-mode .biometric-options .biometric-login-link:hover {
    color: #79b8ff;
}
.biometric-options .biometric-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin: 8px auto 0;
    border-radius: 999px;
    border: 1px solid rgba(14, 165, 233, 0.35);
    background: rgba(14, 165, 233, 0.12);
    color: #0284c7;
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.biometric-options .biometric-icon-btn:hover {
    background: rgba(14, 165, 233, 0.2);
    border-color: rgba(14, 165, 233, 0.6);
    transform: translateY(-1px);
}
.biometric-options .biometric-icon-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.biometric-options .biometric-icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
body.dark-mode .biometric-options .biometric-icon-btn {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.45);
    background: rgba(96, 165, 250, 0.14);
}
body.dark-mode .biometric-options .biometric-icon-btn:hover {
    background: rgba(96, 165, 250, 0.24);
    border-color: rgba(96, 165, 250, 0.7);
}

.biometric-options .biometric-enroll-hint {
    margin: 10px 0 0;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1.45;
    color: #64748b;
    text-align: center;
}
body.dark-mode .biometric-options .biometric-enroll-hint {
    color: #94a3b8;
}

/* Bandeau téléchargement app — visible uniquement sur mobile */
.app-download-banner {
    display: none;
    margin-top: 24px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(14,165,233,0.08), rgba(99,102,241,0.08));
    border: 1px solid rgba(14,165,233,0.25);
    border-radius: 12px;
    text-align: center;
}
body.dark-mode .app-download-banner {
    background: linear-gradient(135deg, rgba(96,165,250,0.1), rgba(139,92,246,0.1));
    border-color: rgba(96,165,250,0.25);
}
.app-download-banner p {
    font-size: 13px;
    color: #475569;
    margin: 0 0 10px;
}
body.dark-mode .app-download-banner p { color: #94a3b8; }
.app-download-banner a {
    display: inline-block;
    padding: 9px 20px;
    background: #0ea5e9;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}
.app-download-banner a:hover { background: #0284c7; }
@media (max-width: 640px) {
    .app-download-banner { display: block; }
}

#cold-start-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #020617 50%, #0c0a1f 100%);
    transition: opacity 0.6s ease;
}
.cold-start-shell {
    text-align: center;
    position: relative;
    z-index: 1;
}
.cs-i18n-hidden {
    display: none;
}
@keyframes rocket-fly{0%{transform:translateY(60px) rotate(-2deg)}50%{transform:translateY(-20px) rotate(2deg)}100%{transform:translateY(60px) rotate(-2deg)}}
@keyframes exhaust-flicker{0%,100%{opacity:0.8;transform:scaleY(1)}50%{opacity:1;transform:scaleY(1.3)}}
@keyframes twinkle{0%,100%{opacity:0.3}50%{opacity:1}}
@keyframes fade-slide-up{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}
.cs-stars{position:absolute;inset:0;overflow:hidden}
.cs-star{position:absolute;width:3px;height:3px;background:#fff;border-radius:50%;animation:twinkle 2s ease-in-out infinite}
.cs-rocket-wrap{animation:rocket-fly 3s ease-in-out infinite;text-align:center}
.cs-rocket{font-size:72px;line-height:1;filter:drop-shadow(0 0 20px rgba(251,191,36,0.4))}
.cs-exhaust{font-size:32px;opacity:0.8;animation:exhaust-flicker 0.4s ease-in-out infinite;margin-top:-10px}
.cs-countdown{font-family:'Courier New',monospace;color:#fbbf24;font-size:28px;font-weight:700;letter-spacing:4px;margin-top:24px;animation:fade-slide-up 0.5s ease}
.cs-msg{color:#94a3b8;font-size:14px;margin-top:12px;letter-spacing:1px;text-transform:uppercase;animation:fade-slide-up 0.5s ease 0.2s both}
.cs-label{color:#64748b;font-size:11px;letter-spacing:3px;text-transform:uppercase;margin-top:32px;animation:fade-slide-up 0.5s ease 0.4s both}
.cs-error-card{max-width:420px;margin:0 auto;padding:32px 28px;border-radius:14px;background:rgba(15,23,42,0.85);border:1px solid rgba(248,113,113,0.35);box-shadow:0 10px 40px rgba(0,0,0,0.45);text-align:center;animation:fade-slide-up 0.4s ease}
.cs-error-icon{font-size:48px;line-height:1;margin-bottom:16px}
.cs-error-title{color:#f8fafc;font-size:20px;font-weight:700;margin:0 0 12px;letter-spacing:0.3px}
.cs-error-desc{color:#cbd5e1;font-size:14px;line-height:1.55;margin:0 0 20px}
.cs-error-actions{display:flex;justify-content:center;gap:12px;margin-bottom:14px}
.cs-error-retry{appearance:none;border:none;cursor:pointer;background:linear-gradient(135deg,#3b82f6,#2563eb);color:#fff;font-size:14px;font-weight:600;padding:10px 22px;border-radius:8px;letter-spacing:0.3px;transition:transform 0.15s ease,box-shadow 0.15s ease}
.cs-error-retry:hover{transform:translateY(-1px);box-shadow:0 6px 16px rgba(37,99,235,0.4)}
.cs-error-retry:disabled{opacity:0.6;cursor:wait;transform:none;box-shadow:none}
.cs-error-hint{color:#64748b;font-size:12px;margin:0}
.google-button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    position: relative;
    z-index: 0;
}
.google-icon {
    width: 20px;
    height: 20px;
}
.password-field-wrap {
    position: relative;
}
.password-field-input {
    padding-right: 48px;
}
.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    opacity: 0.7;
}
.forgot-password-row {
    text-align: right;
    margin-top: 8px;
    margin-bottom: 4px;
}
.forgot-password-link {
    font-size: 13px;
    color: var(--accent-primary, #0ea5e9);
    text-decoration: none;
}
.register-link--guest {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}

body.dark-mode .register-link--guest {
    border-top-color: #30363d;
}

:is(body.bw-mode, body.wbw-mode) .register-link--guest {
    border-top-color: var(--border-color) !important;
}

/* CTA visiteur : même hiérarchie visuelle que les actions principales (secondaire pleine largeur) */
.login-guest-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 4px;
    padding: 12px 16px;
    min-height: 46px;
    box-sizing: border-box;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
    border: 2px solid #0ea5e9;
    background: transparent;
    color: #0ea5e9;
}

.login-guest-cta:hover {
    background: rgba(14, 165, 233, 0.08);
    text-decoration: none;
}

.login-guest-cta:active {
    transform: translateY(1px);
}

body.dark-mode .login-guest-cta {
    border-color: #58a6ff;
    color: #58a6ff;
}

body.dark-mode .login-guest-cta:hover {
    background: rgba(88, 166, 255, 0.12);
}

:is(body.bw-mode, body.wbw-mode) .login-guest-cta {
    border: 2px solid var(--text-color) !important;
    background: transparent !important;
    color: var(--text-color) !important;
}

:is(body.bw-mode, body.wbw-mode) .login-guest-cta:hover {
    background: color-mix(in srgb, var(--text-color) 10%, transparent) !important;
    color: var(--text-color) !important;
}
.biometric-activation-row {
    margin-top: 12px;
}
.is-hidden {
    display: none;
}

/* =============================================================================
   Thèmes hors « jour » (sombre, N&B, blanc N&B)
   - bw/wbw : `span { color: … !important }` (bw-theme) rend le libellé des CTAs
     illisible sur fond sombre (le <span> interne gagne sur la couleur du <button>).
   - Onglets auth : en bw, `button[type=button]` hérite du style « bouton gris »
     global — on rétablit l’apparence onglets du login.
   - Carte : .login-container n’est pas dans la liste .card/.panel des thèmes mono.
   ============================================================================= */

/* Libellés dans les CTAs : bw-theme impose `span { color: … !important }` avec une
   spécificité élevée — les IDs boutons battent cette règle (cf. commentaire wbw-theme). */
:is(body.dark-mode, body.bw-mode, body.wbw-mode) .login-container #emailLoginBtn span,
:is(body.dark-mode, body.bw-mode, body.wbw-mode) .login-container #loginBtn span,
:is(body.dark-mode, body.bw-mode, body.wbw-mode) .login-container #registerBtn span,
:is(body.dark-mode, body.bw-mode, body.wbw-mode) .login-container #googleLoginBtn span {
    color: inherit !important;
}

body.dark-mode .btn-login,
body.dark-mode .btn-social.btn-google {
    color: #ffffff !important;
}

/* Titre marque : éviter que dark-mode.css impose du gris clair sur tout h1 */
body.dark-mode .logo h1 {
    color: var(--accent-primary, #58a6ff) !important;
}

:is(body.bw-mode, body.wbw-mode) .login-container {
    background: var(--card-bg) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 4px 24px var(--shadow-color, rgba(0, 0, 0, 0.12));
    color: var(--text-color) !important;
}

:is(body.bw-mode, body.wbw-mode) .logo h1 {
    color: var(--accent-primary) !important;
}

/* Onglets Email / Telegram — IDs pour battre les règles globales `button` mono */
:is(body.bw-mode, body.wbw-mode) .auth-tabs {
    border-bottom: 2px solid var(--border-color) !important;
    background: transparent !important;
}

:is(body.bw-mode, body.wbw-mode) #auth-tab-email,
:is(body.bw-mode, body.wbw-mode) #auth-tab-telegram {
    background: transparent !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    margin-bottom: -2px;
    box-shadow: none !important;
    color: var(--text-secondary) !important;
}

:is(body.bw-mode, body.wbw-mode) #auth-tab-email.active,
:is(body.bw-mode, body.wbw-mode) #auth-tab-telegram.active {
    color: var(--accent-primary) !important;
    border-bottom-color: var(--accent-primary) !important;
}

:is(body.bw-mode, body.wbw-mode) #auth-tab-email:hover:not(.active),
:is(body.bw-mode, body.wbw-mode) #auth-tab-telegram:hover:not(.active) {
    color: var(--text-color) !important;
}

/* CTAs mono : même logique que ui-extras (non chargé sur login.html) */
:is(body.bw-mode, body.wbw-mode) .btn-login {
    background: var(--text-color) !important;
    color: var(--bg-color) !important;
    border: 1px solid var(--text-color) !important;
}

:is(body.bw-mode, body.wbw-mode) .btn-login:hover {
    background: color-mix(in srgb, var(--text-color) 88%, var(--bg-color)) !important;
    color: var(--bg-color) !important;
}

:is(body.bw-mode, body.wbw-mode) .btn-google {
    background: var(--input-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--input-border) !important;
}

:is(body.bw-mode, body.wbw-mode) .btn-google:hover {
    background: var(--hover-bg) !important;
}

:is(body.bw-mode, body.wbw-mode) .divider {
    color: var(--text-secondary) !important;
}

:is(body.bw-mode, body.wbw-mode) .divider::before,
:is(body.bw-mode, body.wbw-mode) .divider::after {
    background: var(--border-color) !important;
}

:is(body.bw-mode, body.wbw-mode) .register-link {
    color: var(--text-secondary) !important;
}

:is(body.bw-mode, body.wbw-mode) .register-link a {
    color: var(--accent-primary) !important;
}

:is(body.bw-mode, body.wbw-mode) .forgot-password-link {
    color: var(--accent-primary) !important;
}

/* A11y prefers-reduced-motion — login.html ne charge pas main.css (uniquement
   bundle-theme-bw-wb + login.css). Audit 360 P2-1 (V4.9.76). Couvre rocket-fly,
   exhaust-flicker, twinkle, fade-slide-up, slideIn, spin. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
