/* ========================================
   DSA Portal - Premium Styles
   ======================================== */

/* CSS Variables */
:root {
    /* Colors */
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;

    --purple-400: #a78bfa;
    --purple-500: #8b5cf6;
    --purple-600: #7c3aed;

    /* Neutrals */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --gray-950: #030712;

    /* Semantic */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* ========================================
       Theme Variables (Dark Mode - Default)
       ======================================== */
    --theme-bg: #030712;
    --theme-bg-secondary: #0f0f1a;
    --theme-bg-elevated: rgba(255, 255, 255, 0.03);
    --theme-bg-input: rgba(255, 255, 255, 0.05);
    --theme-bg-input-focus: rgba(255, 255, 255, 0.08);
    --theme-bg-hover: rgba(255, 255, 255, 0.05);
    --theme-bg-dark-overlay: rgba(0, 0, 0, 0.2);
    --theme-bg-dark-overlay-heavy: rgba(0, 0, 0, 0.3);

    --theme-sidebar-bg: linear-gradient(180deg, #1a1a2e 0%, #16162a 100%);
    --theme-sidebar-border: rgba(255, 255, 255, 0.05);

    --theme-text-primary: #ffffff;
    --theme-text-secondary: rgba(255, 255, 255, 0.9);
    --theme-text-tertiary: rgba(255, 255, 255, 0.7);
    --theme-text-muted: rgba(255, 255, 255, 0.6);
    --theme-text-faint: rgba(255, 255, 255, 0.5);
    --theme-text-fainter: rgba(255, 255, 255, 0.4);
    --theme-text-faintest: rgba(255, 255, 255, 0.3);

    --theme-border: rgba(255, 255, 255, 0.05);
    --theme-border-input: rgba(255, 255, 255, 0.1);
    --theme-border-hover: rgba(255, 255, 255, 0.15);

    --theme-glass-bg: rgba(255, 255, 255, 0.05);
    --theme-glass-border: rgba(255, 255, 255, 0.1);
    --theme-glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

    --theme-select-option-bg: #1a1a2e;

    --theme-autofill-shadow: rgba(255, 255, 255, 0.05);
    --theme-autofill-text: #fff;

    --theme-nav-active-bg: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    --theme-nav-active-border: rgba(102, 126, 234, 0.3);
    --theme-nav-icon-bg: rgba(255, 255, 255, 0.05);
    --theme-nav-badge-bg: rgba(255, 255, 255, 0.1);

    --theme-table-head-bg: rgba(0, 0, 0, 0.3);
    --theme-table-row-hover: rgba(255, 255, 255, 0.02);
    --theme-table-border: rgba(255, 255, 255, 0.05);
    --theme-table-foot-bg: rgba(16, 185, 129, 0.08);
}

/* ========================================
   Light Theme
   ======================================== */
[data-theme="light"] {
    --theme-bg: #d5d8dc;
    --theme-bg-secondary: #dddfe3;
    --theme-bg-elevated: rgba(0, 0, 0, 0.06);
    --theme-bg-input: rgba(0, 0, 0, 0.07);
    --theme-bg-input-focus: rgba(0, 0, 0, 0.10);
    --theme-bg-hover: rgba(0, 0, 0, 0.08);
    --theme-bg-dark-overlay: rgba(0, 0, 0, 0.06);
    --theme-bg-dark-overlay-heavy: rgba(0, 0, 0, 0.09);

    --theme-sidebar-bg: linear-gradient(180deg, #cdd0d5 0%, #c5c8cd 100%);
    --theme-sidebar-border: #b0b4ba;

    --theme-text-primary: #0a0f1a;
    --theme-text-secondary: #151b28;
    --theme-text-tertiary: #272d3a;
    --theme-text-muted: #3a4150;
    --theme-text-faint: #4d5566;
    --theme-text-fainter: #636b7c;
    --theme-text-faintest: #7d8594;

    --theme-border: #b8bcc3;
    --theme-border-input: #a8adb5;
    --theme-border-hover: #8b9099;

    --theme-glass-bg: rgba(210, 213, 218, 0.9);
    --theme-glass-border: rgba(0, 0, 0, 0.12);
    --theme-glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);

    --theme-select-option-bg: #d5d8dc;

    --theme-autofill-shadow: rgba(0, 0, 0, 0.05);
    --theme-autofill-text: #0a0f1a;

    --theme-nav-active-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    --theme-nav-active-border: rgba(99, 102, 241, 0.3);
    --theme-nav-icon-bg: rgba(0, 0, 0, 0.08);
    --theme-nav-badge-bg: rgba(0, 0, 0, 0.10);

    --theme-table-head-bg: rgba(0, 0, 0, 0.07);
    --theme-table-row-hover: rgba(0, 0, 0, 0.04);
    --theme-table-border: #a8adb5;
    --theme-table-foot-bg: rgba(16, 185, 129, 0.08);
}

/* Smooth theme transition */
html, body, .app-container, .login-container, .login-card,
.dashboard-wrapper, .sidebar, .main-content, .panel, .panel-header,
.form-input, .form-select, .stat-box, .dash-card, .nav-item,
.info-item, .data-table, .result-card, .lender-card, .empty-state {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--theme-bg);
    color: var(--theme-text-secondary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Login Page Styles
   ======================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
}

/* Animated Background Shapes */
.background-shapes {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, var(--primary-600), var(--purple-600));
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.shape-2 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--purple-500), var(--primary-500));
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.shape-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, var(--primary-400), var(--purple-400));
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(30px, -30px) scale(1.05);
    }
    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }
    75% {
        transform: translate(40px, 10px) scale(1.02);
    }
}

/* Login Card - Glassmorphism */
.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    background: var(--theme-glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--theme-glass-border);
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    box-shadow: var(--theme-glass-shadow);
}

/* Login Header */
.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-lg);
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--theme-text-primary);
    margin-bottom: var(--space-xs);
    letter-spacing: -0.02em;
}

.login-header .subtitle {
    color: var(--theme-text-faint);
    font-size: 0.9375rem;
}

/* Messages / Alerts */
.messages {
    margin-bottom: var(--space-lg);
}

.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: var(--space-sm);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

/* Form Styles */
.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.login-form .form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--theme-text-tertiary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: var(--space-md);
    color: var(--theme-text-faint);
    pointer-events: none;
    transition: color var(--transition-base);
}

.input-wrapper.focused .input-icon {
    color: var(--primary-400);
}

.input-wrapper input {
    width: 100%;
    padding: var(--space-md) var(--space-md) var(--space-md) 48px;
    background: var(--theme-bg-input);
    border: 1px solid var(--theme-border-input);
    border-radius: var(--radius-lg);
    color: var(--theme-text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all var(--transition-base);
}

.input-wrapper input::placeholder {
    color: var(--theme-text-faint);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: var(--theme-bg-input-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Password Toggle */
.toggle-password {
    position: absolute;
    right: var(--space-md);
    background: none;
    border: none;
    color: var(--theme-text-faint);
    cursor: pointer;
    padding: var(--space-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-base);
}

.toggle-password:hover {
    color: var(--theme-text-tertiary);
}

/* Form Options Row */
.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

/* Custom Checkbox */
.remember-me {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    color: var(--theme-text-fainter);
}

.remember-me input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--theme-text-faint);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.remember-me input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.remember-me input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.forgot-password {
    color: var(--primary-400);
    text-decoration: none;
    transition: color var(--transition-base);
}

.forgot-password:hover {
    color: var(--primary-300);
    text-decoration: underline;
}

/* Login Button */
.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(135deg, var(--primary-500), var(--purple-500));
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn-login::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-600), var(--purple-600));
    opacity: 0;
    transition: opacity var(--transition-base);
}

.btn-login:hover::before {
    opacity: 1;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login span,
.btn-login svg {
    position: relative;
    z-index: 1;
}

.btn-login svg {
    transition: transform var(--transition-base);
}

.btn-login:hover svg {
    transform: translateX(4px);
}

/* Login Footer */
.login-footer {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--theme-glass-border);
    text-align: center;
}

.login-footer p {
    font-size: 0.8125rem;
    color: var(--theme-text-faint);
    margin-bottom: var(--space-sm);
}

.security-badges {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.75rem;
    color: var(--theme-text-fainter);
}

.security-badges svg {
    color: var(--success);
}

/* ========================================
   Responsive Styles
   ======================================== */

@media (max-width: 480px) {
    .login-card {
        padding: var(--space-xl);
    }
    
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
}

/* ========================================
   Utility Classes
   ======================================== */

.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;
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Theme Toggle Button
   ======================================== */
.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--theme-border-input);
    background: var(--theme-glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--theme-text-faint);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
    color: var(--theme-text-primary);
    border-color: var(--primary-500);
}

.theme-toggle svg {
    width: 22px;
    height: 22px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Dark mode: show sun icon (to switch to light) */
.theme-toggle .icon-sun {
    opacity: 1;
    transform: scale(1);
}

.theme-toggle .icon-moon {
    opacity: 0;
    transform: scale(0.5);
}

/* Light mode: show moon icon (to switch to dark) */
[data-theme="light"] .theme-toggle .icon-sun {
    opacity: 0;
    transform: scale(0.5);
}

[data-theme="light"] .theme-toggle .icon-moon {
    opacity: 1;
    transform: scale(1);
}

/* Light mode: soften animated background shapes */
[data-theme="light"] .shape {
    opacity: 0.2;
}

[data-theme="light"] .logo {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.12));
}

/* Light mode: darken alert text for readability */
[data-theme="light"] .alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #b91c1c;
}

[data-theme="light"] .alert-success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #047857;
}

[data-theme="light"] .alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #92400e;
}

[data-theme="light"] .alert-info {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #1d4ed8;
}
