:root {
    --login-primary: #3b82f6;
    --login-secondary: #1e293b;
    --login-success: #10b981;
    --login-danger: #ef4444;
    --login-bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --login-bg-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --login-glass-bg: rgba(255, 255, 255, 0.95);
    --login-glass-border: rgba(255, 255, 255, 0.2);
    --login-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --login-shadow-hover: 0 35px 60px -12px rgba(0, 0, 0, 0.3);
}

body.login-page-body { /* Specific selector to avoid conflict if base.css body is too general */
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--login-bg-primary); /* This will be overridden by .login-bg */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
}

/* Optimized animated background */
.login-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--login-bg-primary);
    z-index: -2;
    will-change: auto;
}

.login-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 40%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.2) 0%, transparent 40%);
    animation: backgroundFloat 30s ease-in-out infinite;
    will-change: transform, opacity;
}

@keyframes backgroundFloat {
    0%, 100% {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
    50% {
        transform: translate3d(0, -10px, 0);
        opacity: 0.9;
    }
}

/* Optimized floating particles - reduced count for better performance */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    will-change: auto;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    animation: float 20s infinite linear;
    will-change: transform, opacity;
}

/* Reduced from 9 to 5 particles for better performance */
.particle:nth-child(1) { width: 4px; height: 4px; left: 15%; animation-delay: 0s; }
.particle:nth-child(2) { width: 5px; height: 5px; left: 35%; animation-delay: 4s; }
.particle:nth-child(3) { width: 3px; height: 3px; left: 55%; animation-delay: 8s; }
.particle:nth-child(4) { width: 6px; height: 6px; left: 75%; animation-delay: 12s; }
.particle:nth-child(5) { width: 4px; height: 4px; left: 90%; animation-delay: 16s; }

@keyframes float {
    0% {
        transform: translate3d(0, 100vh, 0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate3d(0, -100px, 0);
        opacity: 0;
    }
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--login-glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--login-glass-border);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: var(--login-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    animation: cardSlideIn 0.6s ease-out;
    will-change: transform;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--login-primary), #1d4ed8, var(--login-success));
    border-radius: 24px 24px 0 0;
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.login-logo img {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.form-group-modern {
    position: relative;
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease;
}

.form-group-modern.focused {
    transform: scale(1.01);
}

.form-control-modern {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid rgba(203, 213, 225, 0.3);
    border-radius: 16px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    color: var(--login-secondary);
    will-change: border-color, box-shadow;
}

.form-control-modern:focus {
    outline: none;
    border-color: var(--login-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background: rgba(255, 255, 255, 0.95);
}

.form-control-modern::placeholder {
    color: #9ca3af;
    transition: all 0.3s ease;
}

.form-control-modern:focus::placeholder {
    opacity: 0.7;
    transform: translateY(-2px);
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    z-index: 10;
}

.form-group-modern:focus-within .input-icon {
    color: var(--login-primary);
    transform: translateY(-50%) scale(1.1);
}

.form-label-modern {
    position: absolute;
    left: 3rem;
    top: 1rem;
    color: #9ca3af;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    background: rgba(255, 255, 255, 0.9);
    padding: 0 0.5rem;
    border-radius: 4px;
}

.form-control-modern:focus + .form-label-modern,
.form-control-modern:not(:placeholder-shown) + .form-label-modern {
    top: -0.5rem;
    left: 2.5rem;
    font-size: 0.8rem;
    color: var(--login-primary);
    font-weight: 600;
}

.btn-login {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--login-primary) 0%, #1d4ed8 100%);
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    margin-top: 1rem;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-login:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.btn-login:hover::before {
    left: 100%;
}

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

.btn-login.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-login.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.alert-modern {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.05) 100%);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    color: #dc2626;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: alertSlideIn 0.5s ease-out;
}

.alert-modern i {
    color: var(--login-danger);
    font-size: 1.2rem;
}

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

.logged-in-banner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.05) 100%);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    color: #059669;
    margin-bottom: 1.5rem;
}

.logged-in-banner strong {
    color: #047857;
}

.logged-in-banner a {
    color: var(--login-danger);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.logged-in-banner a:hover {
    color: #dc2626;
    text-decoration: underline;
}

.login-footer {
    text-align: center;
    margin-top: 0.5rem;
    color: #6b7280;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
}

.login-footer i {
    color: var(--login-primary);
}

.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    z-index: 10;
}

.password-toggle:hover {
    color: var(--login-primary);
    transform: translateY(-50%) scale(1.1);
}

/* Responsive design */
@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
    }

    .login-card {
        padding: 2rem;
        border-radius: 20px;
    }

    .form-control-modern {
        padding: 0.875rem 0.875rem 0.875rem 2.75rem;
    }

    .input-icon {
        left: 0.875rem;
    }

    .form-label-modern {
        left: 2.75rem;
    }

    .security-badge {
        position: static;
        margin-bottom: 1rem;
        align-self: center;
        display: none; /* Hidden since removed */
    }
}

/* Performance and accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .login-bg::before,
    .particle,
    .login-card {
        animation: none !important;
    }
}

/* Disable expensive effects on lower-end devices */
@media (max-width: 768px) {
    .login-card {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(255, 255, 255, 0.95);
    }

    .particles {
        display: none;
    }

    .login-bg::before {
        animation: none;
        opacity: 0.6;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
