/**
 * Auth Modal - Lightbox d'authentification
 * Theme Nature : Sage (#A8BBA3) / Terracotta (var(--secondary)) / Cream (#F7F1DE)
 * @version 1.0.0
 */

/* ==========================================================================
   AUTH MODAL OVERRIDES
   ========================================================================== */
.auth-modal {
    z-index: 9999;
}

.auth-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(45, 58, 46, 0.15), 0 4px 16px rgba(45, 58, 46, 0.08);
    overflow-y: auto;
    overflow-x: hidden;
    transform: scale(0.95) translateY(1rem);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.auth-modal.show .auth-modal-dialog {
    transform: scale(1) translateY(0);
}

/* Scrollbar */
.auth-modal-dialog::-webkit-scrollbar {
    width: 4px;
}
.auth-modal-dialog::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

/* Top accent bar */
.auth-modal-dialog::before {
    content: '';
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    display: block;
    height: 4px;
    background: linear-gradient(135deg, #A8BBA3 0%, #8fa889 100%);
    z-index: 2;
}

/* ==========================================================================
   CLOSE BUTTON
   ========================================================================== */
.auth-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-modal-close:hover {
    background: #f3f4f6;
    color: #4b5563;
}

/* ==========================================================================
   PANELS - Switching animation
   ========================================================================== */
.auth-panel {
    display: none;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.25s ease;
}

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

/* ==========================================================================
   PANEL: WELCOME
   ========================================================================== */
.auth-modal-welcome {
    text-align: center;
    padding: 1rem 0;
}

.auth-modal-logo {
    margin-bottom: 0.75rem;
}

.auth-modal-logo svg {
    display: block;
    margin: 0 auto 0.75rem;
}

.auth-modal-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
    margin: 0;
    line-height: 1.2;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.auth-modal-subtitle {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0 0 2rem;
    line-height: 1.5;
}

.auth-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.auth-modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

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

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

.auth-modal-btn-register {
    background: #ffffff;
    color: var(--secondary);
    border: 2px solid var(--secondary);
}

.auth-modal-btn-register:hover {
    background: rgba(var(--secondary-rgb), 0.05);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(var(--secondary-rgb), 0.2);
}

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

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

/* ==========================================================================
   PANEL: BACK BUTTON
   ========================================================================== */
.auth-panel-back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    margin-bottom: 1rem;
    background: none;
    border: none;
    color: #A8BBA3;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.2s;
}

.auth-panel-back:hover {
    color: #8fa889;
}

/* ==========================================================================
   PANEL: HEADER
   ========================================================================== */
.auth-panel-header {
    text-align: center;
    margin-bottom: 1.25rem;
}

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

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

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

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

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

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

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

.auth-modal-oauth-btn svg {
    flex-shrink: 0;
}

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

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

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

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

.auth-modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.auth-modal-field input[type="text"],
.auth-modal-field input[type="email"],
.auth-modal-field input[type="password"] {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: #2d3a2e;
    background: #ffffff;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.auth-modal-field input::placeholder {
    color: #9ca3af;
}

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

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

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

.auth-modal-error {
    font-size: 0.75rem;
    color: #ef4444;
    min-height: 0;
}

.auth-modal-hint {
    font-size: 0.75rem;
    color: #9ca3af;
}

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

/* Alert */
.auth-modal-alert {
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.15);
    line-height: 1.4;
}

/* ==========================================================================
   PASSWORD INPUT
   ========================================================================== */
.auth-modal-password-wrap {
    position: relative;
}

.auth-modal-password-wrap input {
    padding-right: 2.75rem;
}

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

.auth-modal-eye:hover {
    color: #6b7280;
}

/* Forgot password */
.auth-modal-forgot {
    font-size: 0.75rem;
    color: #A8BBA3;
    text-decoration: none;
    font-weight: 500;
}

.auth-modal-forgot:hover {
    color: #8fa889;
    text-decoration: underline;
}

/* ==========================================================================
   PASSWORD STRENGTH
   ========================================================================== */
.auth-modal-strength {
    margin-top: 0.375rem;
}

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

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

.auth-modal-strength-text {
    font-size: 0.7rem;
    color: #6b7280;
    margin-top: 0.2rem;
    display: block;
}

/* ==========================================================================
   CHECKBOX
   ========================================================================== */
.auth-modal-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #4b5563;
    cursor: pointer;
    line-height: 1.4;
}

.auth-modal-checkbox input {
    display: none;
}

.auth-modal-check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 0.2rem;
    position: relative;
    transition: all 0.2s;
    margin-top: 1px;
}

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

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

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

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

/* ==========================================================================
   SUBMIT BUTTON
   ========================================================================== */
.auth-modal-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #A8BBA3 0%, #8fa889 100%);
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.25rem;
}

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

.auth-modal-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-modal-spinner {
    display: inline-flex;
    align-items: center;
}

.auth-modal-spinner svg {
    animation: auth-spin 1s linear infinite;
}

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

/* ==========================================================================
   PANEL FOOTER
   ========================================================================== */
.auth-panel-footer {
    text-align: center;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #f3f4f6;
    font-size: 0.825rem;
    color: #6b7280;
}

.auth-panel-switch {
    background: none;
    border: none;
    color: var(--secondary);
    font-weight: 500;
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

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

/* ==========================================================================
   PANEL: SUCCESS
   ========================================================================== */
.auth-modal-success {
    text-align: center;
    padding: 1.5rem 0;
}

.auth-modal-success-icon {
    display: block;
    margin: 0 auto 1.25rem;
}

.auth-modal-success-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3a2e;
    margin: 0 0 0.5rem;
}

.auth-modal-success-message {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

/* ==========================================================================
   BACKDROP
   ========================================================================== */
.auth-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.auth-modal-backdrop.show {
    opacity: 1;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 576px) {
    .auth-modal {
        align-items: flex-end;
        padding: 0;
    }

    .auth-modal-dialog {
        max-width: none;
        max-height: 92vh;
        border-radius: 1rem 1rem 0 0;
        margin: 0;
    }

    .auth-panel {
        padding: 1.5rem;
    }

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

    .auth-modal-brand {
        font-size: 1.25rem;
    }
}

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

/* ==========================================================================
   DARK MODE — OVERRIDES
   Les règles plus haut utilisent #2d3a2e / #4b5563 / #fff hardcodés.
   Ici on override pour que les tokens du design system prennent le relais.
   ========================================================================== */
[data-theme="dark"] .auth-modal-overlay {
    background: rgba(0, 0, 0, 0.75);
}
[data-theme="dark"] .auth-modal,
[data-theme="dark"] .auth-panel {
    background: var(--surface-1, #1a2218);
    color: var(--text-primary, #f0f5ee);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .auth-modal-close {
    color: var(--text-muted, #a3b09d);
}
[data-theme="dark"] .auth-modal-close:hover {
    color: var(--text-primary, #f0f5ee);
}
[data-theme="dark"] .auth-modal-title,
[data-theme="dark"] .auth-modal-subtitle,
[data-theme="dark"] .auth-panel-title {
    color: var(--text-primary, #f0f5ee);
}
[data-theme="dark"] .auth-modal-subtitle,
[data-theme="dark"] .auth-panel-subtitle {
    color: var(--text-secondary, #d8e0d4);
}
[data-theme="dark"] .auth-modal .form-label,
[data-theme="dark"] .auth-panel .form-label {
    color: var(--text-primary, #f0f5ee);
}
[data-theme="dark"] .auth-modal .form-input,
[data-theme="dark"] .auth-modal .form-select,
[data-theme="dark"] .auth-panel .form-input,
[data-theme="dark"] .auth-panel .form-select {
    background: var(--surface-2, #243022);
    color: var(--text-primary, #f0f5ee);
    border-color: var(--border-color, #3d4e3a);
}
[data-theme="dark"] .auth-modal .form-input::placeholder,
[data-theme="dark"] .auth-panel .form-input::placeholder {
    color: var(--text-muted, #a3b09d);
}
[data-theme="dark"] .auth-modal .form-input:focus,
[data-theme="dark"] .auth-panel .form-input:focus {
    background: var(--surface-3, #2d3a2a);
    border-color: var(--primary-light, #c4d4c0);
}
[data-theme="dark"] .auth-modal .btn-oauth,
[data-theme="dark"] .auth-panel .btn-oauth {
    background: var(--surface-2, #243022);
    color: var(--text-primary, #f0f5ee);
    border-color: var(--border-color, #3d4e3a);
}
[data-theme="dark"] .auth-modal .btn-oauth:hover,
[data-theme="dark"] .auth-panel .btn-oauth:hover {
    background: var(--surface-3, #2d3a2a);
}
[data-theme="dark"] .auth-modal .checkbox-label,
[data-theme="dark"] .auth-panel .checkbox-label {
    color: var(--text-secondary, #d8e0d4);
}
[data-theme="dark"] .auth-modal .auth-separator span,
[data-theme="dark"] .auth-panel .auth-separator span {
    background: var(--surface-1, #1a2218);
    color: var(--text-muted, #a3b09d);
}
[data-theme="dark"] .auth-success-title {
    color: var(--text-primary, #f0f5ee);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .auth-modal,
    :root:not([data-theme="light"]) .auth-panel {
        background: var(--surface-1, #1a2218);
        color: var(--text-primary, #f0f5ee);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    }
    :root:not([data-theme="light"]) .auth-modal-title,
    :root:not([data-theme="light"]) .auth-modal-subtitle,
    :root:not([data-theme="light"]) .auth-panel-title {
        color: var(--text-primary, #f0f5ee);
    }
    :root:not([data-theme="light"]) .auth-modal .form-input,
    :root:not([data-theme="light"]) .auth-modal .form-select,
    :root:not([data-theme="light"]) .auth-panel .form-input {
        background: var(--surface-2, #243022);
        color: var(--text-primary, #f0f5ee);
        border-color: var(--border-color, #3d4e3a);
    }
    :root:not([data-theme="light"]) .auth-modal .form-label,
    :root:not([data-theme="light"]) .auth-panel .form-label {
        color: var(--text-primary, #f0f5ee);
    }
    :root:not([data-theme="light"]) .auth-modal .checkbox-label,
    :root:not([data-theme="light"]) .auth-panel .checkbox-label {
        color: var(--text-secondary, #d8e0d4);
    }
}
