:root {
    /* Primary Colors - Professional gradient scheme */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --secondary: #06b6d4;
    --secondary-dark: #0891b2;
    --accent: #f59e0b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border-primary: #e2e8f0;
    --border-secondary: #cbd5e1;
    --shadow-color: rgba(15, 23, 42, 0.08);

    /* Dark Theme Colors */
    --dark-bg-primary: #0f172a;
    --dark-bg-secondary: #1e293b;
    --dark-bg-tertiary: #334155;
    --dark-text-primary: #f1f5f9;
    --dark-text-secondary: #cbd5e1;
    --dark-text-tertiary: #94a3b8;
    --dark-border-primary: #334155;
    --dark-border-secondary: #475569;
    --dark-shadow-color: rgba(0, 0, 0, 0.3);

    /* Modern Gradients */
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --gradient-secondary: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
    --gradient-accent: linear-gradient(135deg, var(--accent) 0%, #ff6b35 100%);

    /* Advanced Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* Animation Variables */
    --animation-fast: 0.15s;
    --animation-normal: 0.3s;
    --animation-slow: 0.5s;
    --ease-out-cubic: cubic-bezier(0.33, 1, 0.68, 1);
    --ease-in-out-cubic: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Global Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
}

/* Dynamic Background with Advanced Animations */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(165, 180, 252, 0.06) 0%, transparent 50%),
        linear-gradient(135deg, var(--bg-secondary) 0%, #f8fafc 100%);
    animation: backgroundFlow 20s ease-in-out infinite;
}

/* Dark Mode Styles */
body.dark-mode {
    background: var(--dark-bg-primary);
    color: var(--dark-text-primary);
}

body.dark-mode::before {
    background:
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(165, 180, 252, 0.04) 0%, transparent 50%),
        linear-gradient(135deg, var(--dark-bg-primary) 0%, #1e293b 100%);
}

@keyframes backgroundFlow {
    0%, 100% {
        transform: translateX(0) translateY(0) scale(1);
    }
    33% {
        transform: translateX(-10px) translateY(-15px) scale(1.02);
    }
    66% {
        transform: translateX(15px) translateY(10px) scale(0.98);
    }
}

/* Main Container */
.login-container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

/* Enhanced Login Card with Glassmorphism */
.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    box-shadow: var(--shadow-2xl);
    overflow: hidden;
    position: relative;
    animation: cardEntrance 0.8s var(--ease-out-cubic);
    transform-origin: center;
}

body.dark-mode .login-card {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow:
        var(--shadow-2xl),
        0 0 40px rgba(99, 102, 241, 0.15);
}

/* Modern Header Design */
.card-header {
    background: var(--gradient-primary);
    padding: 2.5rem 2rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: headerShimmer 3s infinite;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 2;
}

.logo-container img {
    height: 64px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.logo-fallback {
    display: none;
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.brand-title {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    letter-spacing: -0.025em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
}

.brand-subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    font-weight: 400;
    margin: 0;
    position: relative;
    z-index: 2;
}

/* Enhanced Form Styles */
.card-body {
    padding: 2rem;
}

body.dark-mode .card-body {
    color: var(--dark-text-primary);
}

.form-section {
    margin-bottom: 1.5rem;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    transition: color var(--animation-normal) ease;
}

body.dark-mode .form-label {
    color: var(--dark-text-secondary);
}

.input-wrapper {
    position: relative;
    margin-bottom: 0.5rem;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 1rem;
    z-index: 2;
    pointer-events: none;
    transition: color var(--animation-normal) ease;
}

.form-input {
    width: 100%;
    height: 3rem;
    padding: 0 1rem 0 2.75rem;
    border: 1.5px solid var(--border-primary);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 400;
    transition: all var(--animation-normal) var(--ease-out-cubic);
    outline: none;
}

body.dark-mode .form-input {
    background: var(--dark-bg-secondary);
    border-color: var(--dark-border-primary);
    color: var(--dark-text-primary);
}

.form-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

body.dark-mode .form-input::placeholder {
    color: var(--dark-text-tertiary);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--bg-primary);
}

body.dark-mode .form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: var(--dark-bg-secondary);
}

.form-input:focus + .input-icon,
.form-input:not(:placeholder-shown) + .input-icon {
    color: var(--primary);
}

/* Password Toggle Button */
.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all var(--animation-normal) ease;
    z-index: 3;
}

.password-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

body.dark-mode .password-toggle {
    color: var(--dark-text-tertiary);
}

body.dark-mode .password-toggle:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

/* Forgot Password Link */
.forgot-link {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--animation-normal) ease;
    margin-top: 0.5rem;
}

.forgot-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
}

body.dark-mode .forgot-link {
    color: var(--primary-light);
}

body.dark-mode .forgot-link:hover {
    color: var(--primary);
}

/* Enhanced Login Button */
.login-btn {
    width: 100%;
    height: 3rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    transition: all var(--animation-normal) var(--ease-out-cubic);
    margin-top: 1.5rem;
    box-shadow: var(--shadow-md);
}

.login-btn::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 var(--animation-slow) ease;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.login-btn:hover::before {
    left: 100%;
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-btn:disabled:hover {
    box-shadow: var(--shadow-md);
}

/* Register Link Section */
.register-section {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-primary);
}

body.dark-mode .register-section {
    border-top-color: var(--dark-border-primary);
}

.register-text {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin: 0;
}

body.dark-mode .register-text {
    color: var(--dark-text-secondary);
}

.register-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--animation-normal) ease;
}

.register-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
}

body.dark-mode .register-link {
    color: var(--primary-light);
}

body.dark-mode .register-link:hover {
    color: var(--primary);
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    background: var(--gradient-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    box-shadow: var(--shadow-lg);
    transition: all var(--animation-normal) var(--ease-out-cubic);
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

/* Toast Notifications - Enhanced */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    max-width: 400px;
    width: calc(100vw - 2rem);
}

.toast-notification {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    margin-bottom: 0.75rem;
    overflow: hidden;
    animation: toastSlideIn 0.5s var(--ease-out-cubic);
    position: relative;
}

body.dark-mode .toast-notification {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.toast-notification.success {
    border-left: 4px solid var(--success);
}

.toast-notification.error {
    border-left: 4px solid var(--error);
}

.toast-notification.warning {
    border-left: 4px solid var(--warning);
}

.toast-header {
    padding: 1rem 1rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-icon {
    font-size: 1.125rem;
}

.toast-icon.success {
    color: var(--success);
}

.toast-icon.error {
    color: var(--error);
}

.toast-icon.warning {
    color: var(--warning);
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    margin: 0;
    font-size: 0.9375rem;
}

body.dark-mode .toast-title {
    color: var(--dark-text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all var(--animation-normal) ease;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

body.dark-mode .toast-close {
    color: var(--dark-text-tertiary);
}

body.dark-mode .toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--dark-text-primary);
}

.toast-body {
    padding: 0 1rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

body.dark-mode .toast-body {
    color: var(--dark-text-secondary);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.1);
    width: 100%;
    overflow: hidden;
}

body.dark-mode .toast-progress {
    background: rgba(255, 255, 255, 0.1);
}

.toast-progress-bar {
    height: 100%;
    width: 100%;
    animation: progressBar 5s linear forwards;
}

.toast-notification.success .toast-progress-bar {
    background: var(--success);
}

.toast-notification.error .toast-progress-bar {
    background: var(--error);
}

.toast-notification.warning .toast-progress-bar {
    background: var(--warning);
}

/* Loading Spinner */
.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Animations */
@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(2rem) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes headerShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes progressBar {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Shake animation for form errors */
@keyframes shake {
    0%, 20%, 50%, 80%, 100% { transform: translateX(0); }
    10% { transform: translateX(-5px); }
    30% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    70% { transform: translateX(3px); }
}

/* Responsive Design */
@media (max-width: 480px) {
    body {
        padding: 0.75rem;
        align-items: flex-start;
        padding-top: 5vh;
    }

    .login-container {
        max-width: 100%;
    }

    .card-header {
        padding: 2rem 1.5rem 1.5rem;
    }

    .brand-title {
        font-size: 1.75rem;
    }

    .card-body {
        padding: 1.5rem;
    }

    .form-input {
        font-size: 1rem; /* Prevent zoom on iOS */
    }

    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 2.75rem;
        height: 2.75rem;
    }

    .toast-container {
        max-width: calc(100vw - 1.5rem);
        right: 0.75rem;
        top: 0.75rem;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .card-header {
        padding: 1.5rem 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .brand-title {
        font-size: 1.5rem;
    }
}

/* Accessibility & Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .login-card {
        border: 2px solid currentColor;
    }

    .form-input {
        border: 2px solid currentColor;
    }
}

/* Print styles */
@media print {
    .theme-toggle,
    .toast-container {
        display: none !important;
    }
}

/* Focus indicators for better accessibility */
.login-btn:focus-visible,
.form-input:focus-visible,
.password-toggle:focus-visible,
.theme-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* 2FA modal (UI only) */
body.dark-mode .modal-content {
    background: rgba(30, 41, 59, 0.98);
    color: var(--dark-text-primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
    border-color: var(--dark-border-primary);
}

body.dark-mode .btn-close {
    filter: invert(1) grayscale(100%);
}
