/**
 * auth.css — Site Public
 *
 * Pages : login, register, forgot-password, reset-password
 * Design : glassmorphism immersif, dark ambiance
 * Convention : BEM (.auth__element--modifier)
 * Dépend de : global.css (variables, reset, animations, .hidden, .btn-*)
 *
 * Ne redéfinit AUCUN composant global (.btn, .alert, .modal…)
 */

/* ============================================================
   1. SCENE — fond immersif plein écran
   ============================================================ */

.auth-scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background: linear-gradient(160deg, #080c1a 0%, #0f1629 40%, #151b33 70%, #0a0e1f 100%);
}

/* Orbes de lumière animées */
.auth-scene__orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    will-change: transform;
}

.auth-scene__orb--1 {
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.25) 0%, transparent 70%);
    top: -12%; right: -8%;
    animation: authOrb1 20s ease-in-out infinite;
}

.auth-scene__orb--2 {
    width: 450px; height: 450px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.18) 0%, transparent 70%);
    bottom: -10%; left: -6%;
    animation: authOrb2 24s ease-in-out infinite;
}

.auth-scene__orb--3 {
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.12) 0%, transparent 70%);
    top: 50%; left: 40%;
    transform: translate(-50%, -50%);
    animation: authOrb3 18s ease-in-out infinite;
}

/* Grille subtile */
.auth-scene__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 64px 64px;
}

@keyframes authOrb1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-40px, 50px) scale(1.08); }
    66% { transform: translate(30px, -30px) scale(0.95); }
}
@keyframes authOrb2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(50px, -40px) scale(1.1); }
    66% { transform: translate(-30px, 20px) scale(0.92); }
}
@keyframes authOrb3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

/* ============================================================
   2. LAYOUT — wrapper auth (override global.css .auth-wrapper)
   ============================================================ */

.auth-wrapper {
    /* global.css fournit min-height:100vh + flex center */
    position: relative;
    z-index: 1;
}

.auth-container {
    /* global.css fournit width:100% + max-width */
    max-width: 440px;
}

.auth-container--wide {
    max-width: 500px;
}

/* ============================================================
   3. CARD — panneau glassmorphism
   ============================================================ */

.auth-card {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(32px) saturate(1.4);
    -webkit-backdrop-filter: blur(32px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 40px 36px;
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    animation: authCardIn 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes authCardIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   4. HEADER — logo + titre
   ============================================================ */

.auth-card__header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card__logo {
    max-height: 44px;
    width: auto;
    margin: 0 auto 16px;
    display: block;
}

.auth-card__icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-400);
    border: 1px solid rgba(var(--primary-rgb), 0.18);
}

.auth-card__icon--info {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.18);
}

.auth-card__icon--warning {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.18);
}

.auth-card__title {
    font-size: 22px;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.auth-card__subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
    line-height: 1.5;
}

/* ============================================================
   5. FORMULAIRE — champs, labels, inputs
   ============================================================ */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-form__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-form__label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.01em;
}

.auth-form__input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-form__input-icon {
    position: absolute;
    left: 14px;
    color: rgba(255, 255, 255, 0.25);
    font-size: 16px;
    pointer-events: none;
    transition: color 200ms ease;
}

.auth-form__input {
    width: 100%;
    height: 46px;
    padding: 0 14px 0 42px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-family: var(--font-family);
    font-size: 15px;
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.04);
    outline: none;
    transition: border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
}

.auth-form__input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.auth-form__input:focus {
    border-color: rgba(var(--primary-rgb), 0.5);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.auth-form__input:focus ~ .auth-form__input-icon {
    color: var(--primary-400);
}

.auth-form__input--error {
    border-color: rgba(239, 68, 68, 0.5) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* Input sans icône gauche */
.auth-form__input--no-icon {
    padding-left: 14px;
}

.auth-form__hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 2px;
}

/* ============================================================
   6. TOGGLE PASSWORD
   ============================================================ */

.auth-form__toggle-pw {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    padding: 6px;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: color 200ms ease, background 200ms ease;
}

.auth-form__toggle-pw:hover {
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================================
   7. PASSWORD STRENGTH — barres segmentées
   ============================================================ */

.auth-pw-strength {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.auth-pw-strength__bars {
    display: flex;
    gap: 4px;
    flex: 1;
}

.auth-pw-strength__segment {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.08);
    transition: background 300ms ease;
}

/* Niveaux */
.auth-pw-strength[data-level="1"] .auth-pw-strength__segment:nth-child(-n+1) {
    background: var(--danger);
}
.auth-pw-strength[data-level="2"] .auth-pw-strength__segment:nth-child(-n+2) {
    background: var(--warning);
}
.auth-pw-strength[data-level="3"] .auth-pw-strength__segment:nth-child(-n+3) {
    background: var(--info);
}
.auth-pw-strength[data-level="4"] .auth-pw-strength__segment:nth-child(-n+4) {
    background: var(--success);
}

.auth-pw-strength__label {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    min-width: 56px;
    text-align: right;
    transition: color 300ms ease;
}

.auth-pw-strength[data-level="0"] .auth-pw-strength__label { color: rgba(255,255,255,0.3); }
.auth-pw-strength[data-level="1"] .auth-pw-strength__label { color: #f87171; }
.auth-pw-strength[data-level="2"] .auth-pw-strength__label { color: #fbbf24; }
.auth-pw-strength[data-level="3"] .auth-pw-strength__label { color: #60a5fa; }
.auth-pw-strength[data-level="4"] .auth-pw-strength__label { color: #4ade80; }

/* ============================================================
   8. PASSWORD MATCH
   ============================================================ */

.auth-pw-match {
    font-size: 12px;
    margin-top: 4px;
    min-height: 18px;
    transition: color 200ms ease;
}

.auth-pw-match--ok { color: #4ade80; }
.auth-pw-match--ko { color: #f87171; }

/* ============================================================
   9. OPTIONS — remember me + forgot link
   ============================================================ */

.auth-form__options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Checkbox custom */
.auth-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    user-select: none;
}

.auth-check input { display: none; }

.auth-check__box {
    width: 18px;
    height: 18px;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 200ms ease;
}

.auth-check input:checked + .auth-check__box {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.auth-check input:checked + .auth-check__box::after {
    content: '';
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
    margin-top: -2px;
}

/* ============================================================
   10. LINKS
   ============================================================ */

.auth-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-400);
    text-decoration: none;
    transition: color 200ms ease;
}

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

.auth-link--accent {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1.5px;
}

.auth-link--back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: rgba(255, 255, 255, 0.4);
}

.auth-link--back:hover { color: rgba(255, 255, 255, 0.7); }

/* ============================================================
   11. BUTTON SUBMIT
   ============================================================ */

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 12px;
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 250ms cubic-bezier(0.22, 1, 0.36, 1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.auth-btn--primary {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-700) 100%);
    color: #fff;
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.3);
}

.auth-btn--primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(var(--primary-rgb), 0.4);
}

.auth-btn--primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 12px rgba(var(--primary-rgb), 0.3);
}

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

.auth-btn--secondary {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-btn--secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Spinner dans le bouton */
.auth-btn .bi-arrow-repeat {
    animation: authSpin 0.8s linear infinite;
}

@keyframes authSpin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   12. DIVIDER
   ============================================================ */

.auth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(255, 255, 255, 0.25);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

/* ============================================================
   13. ALERT
   ============================================================ */

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    animation: authAlertIn 300ms ease both;
}

.auth-alert i { flex-shrink: 0; margin-top: 2px; }

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

.auth-alert--danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.auth-alert--success {
    background: rgba(34, 197, 94, 0.1);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.15);
}

.auth-alert--warning {
    background: rgba(245, 158, 11, 0.1);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.15);
}

/* ============================================================
   14. SUCCESS STATE
   ============================================================ */

.auth-success {
    text-align: center;
    padding: 20px 0;
    animation: authCardIn 500ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-success__icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.auth-success__title {
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
    margin: 0 0 8px;
}

.auth-success__text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.6;
    margin: 0 0 24px;
}

/* ============================================================
   15. DISABLED STATE
   ============================================================ */

.auth-disabled {
    text-align: center;
    padding: 24px 0;
}

.auth-disabled__icon {
    font-size: 40px;
    color: rgba(255, 255, 255, 0.2);
    margin-bottom: 12px;
}

.auth-disabled__text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0 20px;
    line-height: 1.5;
}

/* ============================================================
   16. FOOTER
   ============================================================ */

.auth-card__footer {
    text-align: center;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.35);
}

.auth-card__footer p { margin: 0; }

/* ============================================================
   17. OAUTH
   ============================================================ */

.auth-oauth {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-oauth__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 46px;
    border-radius: 12px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 200ms ease;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-oauth__btn:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.15);
}

.auth-oauth__btn svg,
.auth-oauth__btn img {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ============================================================
   18. RESPONSIVE
   ============================================================ */

@media (max-width: 520px) {
    .auth-card {
        padding: 32px 24px;
        border-radius: 20px;
    }

    .auth-card__title { font-size: 20px; }

    .auth-scene__orb--1 { width: 350px; height: 350px; }
    .auth-scene__orb--2 { width: 280px; height: 280px; }
    .auth-scene__orb--3 { display: none; }

    .auth-form__options {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

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

@media (max-width: 380px) {
    .auth-card {
        padding: 28px 20px;
        border-radius: 16px;
    }
}
