/**
 * CMS Source - Auth Pages CSS
 * Theme: Palette Nature (Sage / Terracotta / Cream)
 * Coherent avec la page 404
 * @version 2.0.0
 */

/* =========================================================================
   UTILITY CLASSES (CSP-compatible - no inline styles needed)
   ========================================================================= */
.hidden {
    display: none !important;
}

/* =========================================================================
   AUTH PAGE - STANDALONE LAYOUT
   ========================================================================= */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F7F1DE 0%, rgba(168, 187, 163, 0.3) 100%);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #2d3a2e;
    padding: 2rem;
    line-height: 1.6;
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

/* =========================================================================
   AUTH CARD
   ========================================================================= */
.auth-card {
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(45, 58, 46, 0.08), 0 2px 8px rgba(45, 58, 46, 0.04);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #A8BBA3 0%, #8fa889 100%);
}

.auth-card-large {
    max-width: 520px;
}

.auth-container:has(.auth-card-large) {
    max-width: 520px;
}

/* =========================================================================
   AUTH HEADER
   ========================================================================= */
.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--secondary);
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
}

.auth-subtitle {
    color: #6b7280;
    font-size: 0.95rem;
    margin: 0;
}

/* =========================================================================
   OAUTH BUTTONS
   ========================================================================= */
.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0;
}

.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #2d3a2e;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-oauth:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.btn-google:hover {
    border-color: #ea4335;
    background: rgba(234, 67, 53, 0.03);
}

.btn-facebook:hover {
    border-color: #1877F2;
    background: rgba(24, 119, 242, 0.03);
}

.oauth-icon {
    flex-shrink: 0;
}

/* =========================================================================
   AUTH DIVIDER
   ========================================================================= */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

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

.auth-divider span {
    font-size: 0.8rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* =========================================================================
   AUTH FORM
   ========================================================================= */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #2d3a2e;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-family: inherit;
    color: #2d3a2e;
    background: #ffffff;
    transition: all 0.2s ease;
    outline: none;
}

.form-input::placeholder {
    color: #9ca3af;
}

.form-input:focus {
    border-color: #A8BBA3;
    box-shadow: 0 0 0 3px rgba(168, 187, 163, 0.2);
}

.form-input.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-error-message {
    font-size: 0.8rem;
    color: #ef4444;
    min-height: 0;
}

.form-hint {
    font-size: 0.8rem;
    color: #9ca3af;
}

.required {
    color: #ef4444;
    font-weight: 600;
}

/* =========================================================================
   PASSWORD INPUT
   ========================================================================= */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper .form-input {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: #6b7280;
}

/* =========================================================================
   PASSWORD STRENGTH
   ========================================================================= */
.password-strength {
    margin-top: 0.5rem;
}

.strength-bar {
    height: 4px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.strength-fill {
    height: 100%;
    border-radius: 999px;
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.strength-text {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
    display: block;
}

/* =========================================================================
   FORGOT PASSWORD LINK
   ========================================================================= */
.forgot-password-link {
    font-size: 0.8rem;
    color: #A8BBA3;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.forgot-password-link:hover {
    color: #8fa889;
    text-decoration: underline;
}

/* =========================================================================
   CHECKBOX
   ========================================================================= */
.form-checkbox {
    flex-direction: row;
    align-items: flex-start;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #4b5563;
    cursor: pointer;
    line-height: 1.4;
}

.checkbox-input {
    display: none;
}

.checkbox-custom {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border: 1.5px solid #d1d5db;
    border-radius: 0.25rem;
    position: relative;
    transition: all 0.2s;
    margin-top: 1px;
}

.checkbox-input:checked + .checkbox-custom {
    background: linear-gradient(135deg, #A8BBA3 0%, #8fa889 100%);
    border-color: #8fa889;
}

.checkbox-input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-text a {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
}

.checkbox-text a:hover {
    text-decoration: underline;
}

/* =========================================================================
   BUTTONS
   ========================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #A8BBA3 0%, #8fa889 100%);
    color: #ffffff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(168, 187, 163, 0.4);
}

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

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* =========================================================================
   SPINNER
   ========================================================================= */
.btn-spinner {
    display: none;
    align-items: center;
}

.btn-spinner.visible {
    display: inline-flex;
}

.spinner {
    animation: spin 1s linear infinite;
}

.spinner-circle {
    stroke-dasharray: 63;
    stroke-dashoffset: 50;
}

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

/* =========================================================================
   ALERT
   ========================================================================= */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.alert-error {
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.alert-success {
    background: rgba(34, 197, 94, 0.08);
    color: #15803d;
    border: 1px solid rgba(34, 197, 94, 0.15);
}

.eye-closed {
    display: none;
}

/* =========================================================================
   AUTH FOOTER
   ========================================================================= */
.auth-footer {
    text-align: center;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid #f3f4f6;
}

.auth-footer p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

.auth-link {
    color: var(--secondary);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-link:hover {
    color: #9a6840;
    text-decoration: underline;
}

/* =========================================================================
   NETWORK INFO
   ========================================================================= */
.auth-network {
    margin-top: 1.25rem;
}

.network-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #9ca3af;
    margin: 0;
}

.network-info svg {
    flex-shrink: 0;
    opacity: 0.6;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 640px) {
    .auth-page {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }

    .auth-card {
        padding: 1.75rem;
    }

    .auth-title {
        font-size: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .oauth-buttons {
        gap: 0.5rem;
    }
}

@media (max-width: 360px) {
    .auth-card {
        padding: 1.25rem;
    }
}

/* ==========================================================================
   DARK MODE — OVERRIDES
   Les règles plus haut utilisent des couleurs hardcodées (#2d3a2e, #fff,
   etc.) qui deviennent illisibles sur fond sombre. On override ici pour
   passer aux tokens du design system. Même logique que header.css :
   bloc [data-theme="dark"] + bloc @media (prefers-color-scheme: dark)
   ceinture+bretelles, le second actif uniquement si pas d'override manuel.
   ========================================================================== */
[data-theme="dark"] .auth-page {
    background: linear-gradient(135deg, #1a2218 0%, #243022 100%);
    color: var(--text-primary, #f0f5ee);
}
[data-theme="dark"] .auth-card {
    background: var(--surface-1, #1a2218);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
    color: var(--text-primary, #f0f5ee);
}
[data-theme="dark"] .auth-title,
[data-theme="dark"] .auth-subtitle,
[data-theme="dark"] .auth-footer {
    color: var(--text-primary, #f0f5ee);
}
[data-theme="dark"] .auth-subtitle {
    color: var(--text-secondary, #d8e0d4);
}
[data-theme="dark"] .btn-oauth {
    background: var(--surface-2, #243022);
    color: var(--text-primary, #f0f5ee);
    border-color: var(--border-color, #3d4e3a);
}
[data-theme="dark"] .btn-oauth:hover {
    background: var(--surface-3, #2d3a2a);
}
[data-theme="dark"] .form-label {
    color: var(--text-primary, #f0f5ee);
}
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .form-select {
    background: var(--surface-2, #243022);
    color: var(--text-primary, #f0f5ee);
    border-color: var(--border-color, #3d4e3a);
}
[data-theme="dark"] .form-input::placeholder,
[data-theme="dark"] .form-textarea::placeholder {
    color: var(--text-muted, #a3b09d);
}
[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-textarea:focus,
[data-theme="dark"] .form-select:focus {
    border-color: var(--primary-light, #c4d4c0);
    background: var(--surface-3, #2d3a2a);
}
[data-theme="dark"] .checkbox-label,
[data-theme="dark"] .radio-label {
    color: var(--text-secondary, #d8e0d4);
}
[data-theme="dark"] .auth-separator::before,
[data-theme="dark"] .auth-separator::after {
    background: var(--border-color, #3d4e3a);
}
[data-theme="dark"] .auth-separator span {
    background: var(--surface-1, #1a2218);
    color: var(--text-muted, #a3b09d);
}
[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.12);
    color: #d1fae5;
    border-color: #34d399;
}
[data-theme="dark"] .alert-error,
[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
    border-color: #f87171;
}

/* Fallback prefers-color-scheme si aucun choix explicite */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .auth-page {
        background: linear-gradient(135deg, #1a2218 0%, #243022 100%);
        color: var(--text-primary, #f0f5ee);
    }
    :root:not([data-theme="light"]) .auth-card {
        background: var(--surface-1, #1a2218);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
        color: var(--text-primary, #f0f5ee);
    }
    :root:not([data-theme="light"]) .auth-title,
    :root:not([data-theme="light"]) .auth-subtitle,
    :root:not([data-theme="light"]) .auth-footer {
        color: var(--text-primary, #f0f5ee);
    }
    :root:not([data-theme="light"]) .btn-oauth {
        background: var(--surface-2, #243022);
        color: var(--text-primary, #f0f5ee);
        border-color: var(--border-color, #3d4e3a);
    }
    :root:not([data-theme="light"]) .form-label {
        color: var(--text-primary, #f0f5ee);
    }
    :root:not([data-theme="light"]) .form-input,
    :root:not([data-theme="light"]) .form-textarea,
    :root:not([data-theme="light"]) .form-select {
        background: var(--surface-2, #243022);
        color: var(--text-primary, #f0f5ee);
        border-color: var(--border-color, #3d4e3a);
    }
    :root:not([data-theme="light"]) .checkbox-label,
    :root:not([data-theme="light"]) .radio-label {
        color: var(--text-secondary, #d8e0d4);
    }
}
