/* Variables pour les couleurs */
:root {
    --primary-blue: #1e3a8a;
    --dark-blue: #0f172a;
    --accent-yellow: #fbbf24;
    --text-dark: #374151;
    --text-light: #f9fafb;
    --glass-bg: rgba(248, 250, 252, 0.98);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-strong: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Container principal */
.login-container {
    min-height: 100vh;
    height: 100vh;
    width: 100vw;
    background:
        radial-gradient(circle at 14% 18%, rgba(251, 191, 36, 0.18), transparent 24%),
        radial-gradient(circle at 85% 14%, rgba(96, 165, 250, 0.20), transparent 28%),
        radial-gradient(circle at 50% 100%, rgba(16, 185, 129, 0.14), transparent 30%),
        linear-gradient(135deg, #020617 0%, #0f172a 44%, #1e3a8a 100%);
    position: fixed;
    top: 0;
    left: 0;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    z-index: 1000;
}

.login-container::before,
.login-container::after {
    content: '';
    position: absolute;
    pointer-events: none;
    z-index: 0;
}

.login-container::before {
    top: -12%;
    left: -8%;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.16) 0%, rgba(251, 191, 36, 0.05) 42%, transparent 72%);
    filter: blur(10px);
}

.login-container::after {
    right: -14%;
    bottom: -18%;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.18) 0%, rgba(59, 130, 246, 0.05) 44%, transparent 74%);
    filter: blur(16px);
}

/* Icônes flottantes */
.floating-icons {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    /* Isole les peintures pour limiter les saccades */
    contain: layout paint;
}

.floating-icons::before,
.floating-icons::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.floating-icons::before {
    background:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 140px 140px;
    opacity: 0.32;
}

.floating-icons::after {
    background: radial-gradient(circle at center, transparent 18%, rgba(2, 6, 23, 0.18) 68%, rgba(2, 6, 23, 0.42) 100%);
}

.icon {
    --icon-color: rgba(251, 191, 36, 0.88);
    --icon-bg-start: rgba(255, 255, 255, 0.16);
    --icon-bg-end: rgba(255, 255, 255, 0.04);
    --icon-border: rgba(255, 255, 255, 0.16);
    --icon-glow: rgba(251, 191, 36, 0.18);
    --icon-radius: 22px;
    --icon-speed: 20s;
    --icon-opacity: 0.24;
    --icon-drift-mid: 18px;
    --icon-drift-end: -14px;
    --icon-tilt-start: -8deg;
    --icon-tilt-end: 10deg;
    position: absolute;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--icon-color);
    background: linear-gradient(145deg, var(--icon-bg-start), var(--icon-bg-end));
    border: 1px solid var(--icon-border);
    border-radius: var(--icon-radius);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        0 12px 34px rgba(2, 6, 23, 0.24);
    opacity: 0;
    overflow: hidden;
    animation: scroll var(--icon-speed) linear infinite;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.icon::before,
.icon::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

.icon::before {
    inset: 1px;
    border-radius: calc(var(--icon-radius) - 1px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0));
}

.icon::after {
    inset: -16px;
    border-radius: var(--icon-radius);
    background: radial-gradient(circle, var(--icon-glow) 0%, transparent 72%);
    opacity: 0.7;
    z-index: -1;
}

.icon i {
    position: relative;
    z-index: 1;
    line-height: 1;
}

.floating-icons .icon:nth-child(3n) {
    --icon-color: rgba(191, 219, 254, 0.82);
    --icon-bg-start: rgba(59, 130, 246, 0.16);
    --icon-bg-end: rgba(255, 255, 255, 0.03);
    --icon-border: rgba(147, 197, 253, 0.22);
    --icon-glow: rgba(96, 165, 250, 0.18);
    --icon-radius: 999px;
    --icon-speed: 24s;
    --icon-drift-mid: -20px;
    --icon-drift-end: 14px;
    --icon-tilt-start: 8deg;
    --icon-tilt-end: -8deg;
}

.floating-icons .icon:nth-child(4n) {
    --icon-color: rgba(226, 232, 240, 0.82);
    --icon-bg-start: rgba(255, 255, 255, 0.16);
    --icon-bg-end: rgba(148, 163, 184, 0.05);
    --icon-border: rgba(255, 255, 255, 0.18);
    --icon-glow: rgba(255, 255, 255, 0.10);
    --icon-speed: 22s;
}

.floating-icons .icon:nth-child(5n) {
    --icon-color: rgba(134, 239, 172, 0.78);
    --icon-bg-start: rgba(16, 185, 129, 0.14);
    --icon-bg-end: rgba(255, 255, 255, 0.03);
    --icon-border: rgba(74, 222, 128, 0.20);
    --icon-glow: rgba(16, 185, 129, 0.14);
    --icon-radius: 18px;
    --icon-speed: 26s;
}

.icon-1 { left: 5%; bottom: -100px; animation-delay: 0s; }
.icon-2 { left: 15%; bottom: -100px; animation-delay: 1s; }
.icon-3 { left: 25%; bottom: -100px; animation-delay: 2s; }
.icon-4 { left: 35%; bottom: -100px; animation-delay: 3s; }
.icon-5 { left: 45%; bottom: -100px; animation-delay: 4s; }
.icon-6 { left: 55%; bottom: -100px; animation-delay: 5s; }
.icon-7 { left: 65%; bottom: -100px; animation-delay: 6s; }
.icon-8 { left: 75%; bottom: -100px; animation-delay: 7s; }
.icon-9 { left: 85%; bottom: -100px; animation-delay: 8s; }
.icon-10 { left: 95%; bottom: -100px; animation-delay: 9s; }
.icon-11 { left: 10%; bottom: -100px; animation-delay: 10s; }
.icon-12 { left: 20%; bottom: -100px; animation-delay: 11s; }
.icon-13 { left: 30%; bottom: -100px; animation-delay: 12s; }
.icon-14 { left: 40%; bottom: -100px; animation-delay: 13s; }
.icon-15 { left: 50%; bottom: -100px; animation-delay: 14s; }
.icon-16 { left: 60%; bottom: -100px; animation-delay: 15s; }
.icon-17 { left: 70%; bottom: -100px; animation-delay: 16s; }
.icon-18 { left: 80%; bottom: -100px; animation-delay: 17s; }
.icon-19 { left: 90%; bottom: -100px; animation-delay: 18s; }
.icon-20 { left: 100%; bottom: -100px; animation-delay: 19s; }
.icon-21 { left: 7%; bottom: -100px; animation-delay: 20s; }
.icon-22 { left: 17%; bottom: -100px; animation-delay: 21s; }
.icon-23 { left: 27%; bottom: -100px; animation-delay: 22s; }
.icon-24 { left: 37%; bottom: -100px; animation-delay: 23s; }
.icon-25 { left: 47%; bottom: -100px; animation-delay: 24s; }
.icon-26 { left: 57%; bottom: -100px; animation-delay: 25s; }
.icon-27 { left: 67%; bottom: -100px; animation-delay: 26s; }
.icon-28 { left: 77%; bottom: -100px; animation-delay: 27s; }
.icon-29 { left: 87%; bottom: -100px; animation-delay: 28s; }
.icon-30 { left: 97%; bottom: -100px; animation-delay: 29s; }

@keyframes scroll {
    0% {
        transform: translate3d(0, 0, 0) rotate(var(--icon-tilt-start)) scale(0.88);
        opacity: 0;
    }
    12% {
        opacity: var(--icon-opacity);
    }
    52% {
        transform: translate3d(var(--icon-drift-mid), -48vh, 0) rotate(0deg) scale(1);
        opacity: var(--icon-opacity);
    }
    88% {
        opacity: var(--icon-opacity);
    }
    100% {
        transform: translate3d(var(--icon-drift-end), calc(-100vh - 180px), 0) rotate(var(--icon-tilt-end)) scale(1.04);
        opacity: 0;
    }
}

/* Réduire le nombre d’icônes animées (meilleure fluidité, mais encore visibles) */
.floating-icons .icon:nth-child(n+21) {
    display: none;
}

/* (Préférence reduced-motion ignorée ici pour garder les animations visibles) */

/* Container du formulaire */
.login-form-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 450px;
}

.login-form {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.92) 0%, rgba(15, 23, 42, 0.92) 100%);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 28px 80px rgba(2, 6, 23, 0.46);
    border: 1px solid rgba(255, 255, 255, 0.22);
    animation: slideIn 0.8s ease-out;
    position: relative;
    overflow: hidden;
}

.login-form::before {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: 19px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    pointer-events: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* En-tête */
.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.user-icon {
    width: 96px;
    height: 96px;
    background: var(--primary-blue);
    border-radius: 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 25px rgba(30, 58, 138, 0.3);
}

.user-icon i {
    font-size: 2.4rem;
    color: #ffffff;
}

.login-title {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Formulaire */
.login-form-content {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 25px;
}

.form-label {
    display: block;
    color: white;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1rem;
}

.input-group {
    position: relative;
}

.form-control {
    width: 100%;
    padding: 18px 50px 18px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1.1rem;
    background: white;
    color: var(--text-dark);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    transform: translateY(-2px);
}

.form-control::placeholder {
    color: #9ca3af;
}

.input-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 1.1rem;
}

/* Message d'erreur */
.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    border-left: 4px solid #dc2626;
}

/* Bouton de connexion */
.login-button {
    width: 100%;
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    position: relative;
    overflow: hidden;
}

.login-button:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 50%, #065f46 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.login-button:active {
    transform: translateY(0);
}

/* Indicateur de chargement */
.loading-spinner {
    display: none;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

.loading-circle {
    width: 18px;
    height: 18px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle-progress {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(0, 0, 0, 0.2);
    border-top: 3px solid #000000;
    border-radius: 50%;
    animation: circleSpin 1s linear infinite;
}

@keyframes circleSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* État de chargement du bouton */
.login-button.loading {
    cursor: not-allowed;
    pointer-events: none;
}

.login-button.loading .button-icon { display: none; }

.login-button.loading .loading-spinner {
    display: inline-flex;
}

/* Lien mot de passe oublié */
.forgot-password {
    text-align: center;
    margin-bottom: 20px;
}

.forgot-link {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.forgot-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Lien d'inscription */
.register-link {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.register-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: white;
    border: 2px solid var(--primary-blue);
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.register-button:hover {
    background: var(--primary-blue);
    color: white;
    transform: translateY(-1px);
    text-decoration: none;
}

/* Overlay de chargement */
.login-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.login-loading-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    max-width: 420px;
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
}

.overlay-logo {
    width: 80px;
    height: 80px;
    border-radius: 24px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a, #1e3a8a);
    color: #fbbf24;
    font-size: 2rem;
    box-shadow: inset 0 0 15px rgba(251, 191, 36, 0.25);
}

.overlay-title {
    color: #f9fafb;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.overlay-subtitle {
    color: rgba(249, 250, 251, 0.7);
    font-size: 0.95rem;
    margin-bottom: 30px;
    line-height: 1.5;
}

.overlay-progress {
    text-align: center;
    margin-top: 10px;
}

.overlay-spinner {
    width: 38px;
    height: 38px;
    margin: 0 auto 12px auto;
    border-radius: 999px;
    border: 3px solid rgba(248, 250, 252, 0.25);
    border-top-color: #22c55e;
    border-right-color: #22c55e;
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.45);
    animation: overlaySpin 0.8s linear infinite;
}

@keyframes overlaySpin {
    to {
        transform: rotate(360deg);
    }
}

.progress-text {
    color: rgba(249, 250, 251, 0.6);
    font-size: 0.85rem;
    display: block;
}

/* Responsive */
@media (max-width: 1024px) {
    .login-container {
        padding: 1rem;
    }
    
    .login-form-container {
        max-width: 100%;
    }
    
    .login-form {
        padding: 35px 25px;
    }
    
    /* Réduire le nombre d'icônes visibles sur tablettes */
    .floating-icons .icon:nth-child(n+16) {
        display: none;
    }
}

@media (max-width: 768px) {
    .login-container {
        padding: 0.5rem;
        height: auto;
        min-height: 100vh;
    }
    
    .login-form {
        padding: 30px 20px;
        margin: 10px;
        border-radius: 16px;
    }
    
    .login-title {
        font-size: 1.2rem;
    }
    
    .user-icon {
        width: 70px;
        height: 70px;
    }
    
    .user-icon i {
        font-size: 1.8rem;
    }
    
    .form-control {
        padding: 16px 45px 16px 18px;
        font-size: 1rem;
    }
    
    .input-icon {
        font-size: 1rem;
        right: 12px;
    }
    
    .login-button {
        padding: 14px 18px;
        font-size: 0.95rem;
    }
    
    /* Réduire encore plus les icônes sur mobile */
    .floating-icons .icon:nth-child(n+11) {
        display: none;
    }
    
    .icon {
        width: 64px;
        height: 64px;
        font-size: 1.75rem;
    }
    
    .overlay-content {
        padding: 30px 20px;
        max-width: 90%;
    }
    
    .overlay-title {
        font-size: 1.1rem;
    }
    
    .overlay-subtitle {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 0;
    }
    
    .login-form {
        padding: 25px 18px;
        margin: 15px;
        border-radius: 12px;
        min-width: 0;
        width: calc(100% - 30px);
        box-sizing: border-box;
    }
    
    .login-title {
        font-size: 1.1rem;
        letter-spacing: 0.5px;
    }
    
    .user-icon {
        width: 60px;
        height: 60px;
        margin-bottom: 15px;
    }
    
    .user-icon i {
        font-size: 1.5rem;
    }
    
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }
    
    .form-control {
        padding: 14px 40px 14px 16px;
        font-size: 0.95rem;
        border-radius: 10px;
    }
    
    .input-icon {
        font-size: 0.95rem;
        right: 10px;
    }
    
    .login-button {
        padding: 12px 16px;
        font-size: 0.9rem;
        border-radius: 10px;
    }
    
    .forgot-link {
        font-size: 0.85rem;
    }
    
    .register-button {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    /* Masquer la plupart des icônes sur très petits écrans */
    .floating-icons .icon:nth-child(n+6) {
        display: none;
    }
    
    .icon {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    .overlay-content {
        padding: 25px 18px;
        max-width: 95%;
        border-radius: 16px;
    }

    .overlay-title {
        font-size: 1.05rem;
    }
    
    .overlay-subtitle {
        font-size: 0.85rem;
    }
    
    .overlay-logo {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .progress-text {
        font-size: 0.8rem;
    }
}

/* Gestion du clavier virtuel sur mobile */
@media (max-width: 768px) and (max-height: 600px) {
    .login-container {
        align-items: flex-start;
        padding-top: 1rem;
    }
    
    .login-form {
        margin-top: 0;
    }
    
    .floating-icons {
        display: none; /* Masquer les icônes quand le clavier est ouvert */
    }
}
