/* ==============================================
   ENHANCED THEME SYSTEM - PERFECT LIGHT/DARK MODE
   ============================================== */

:root {
    /* Light Theme Variables */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-overlay: rgba(255, 255, 255, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.1);
    
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    --text-on-primary: #ffffff;
    
    --border-primary: #e2e8f0;
    --border-secondary: #cbd5e1;
    --border-focus: #3b82f6;
    --border-glass: rgba(255, 255, 255, 0.2);
    
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-heavy: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.1);
    
    /* Input styles */
    --input-background: #ffffff;
    --input-border: #e2e8f0;
    --input-focus: #3b82f6;
    --input-text: #1e293b;
    
    /* Brand Colors (Consistent across themes) */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;
    
    --success-50: #f0fdf4;
    --success-100: #dcfce7;
    --success-500: #22c55e;
    --success-600: #16a34a;
    
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    
    --error-50: #fef2f2;
    --error-100: #fee2e2;
    --error-500: #ef4444;
    --error-600: #dc2626;
    
    /* Semantic colors */
    --color-primary: var(--primary-500);
    --color-success: var(--success-500);
    --color-warning: var(--warning-500);
    --color-error: var(--error-500);
    
    /* Theme Transition */
    --transition-theme: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
    --transition-slow: all 0.5s ease;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-overlay: rgba(15, 23, 42, 0.95);
    --bg-glass: rgba(30, 41, 59, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-tertiary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;
    --text-on-primary: #ffffff;
    
    --border-primary: #334155;
    --border-secondary: #475569;
    --border-focus: #60a5fa;
    --border-glass: rgba(255, 255, 255, 0.1);
    
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-heavy: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    --input-background: #334155;
    --input-border: #475569;
    --input-focus: #60a5fa;
    --input-text: #f8fafc;
    
    /* Adjust primary colors for dark theme */
    --color-primary: var(--primary-400);
}

/* Theme Toggle Button Styles */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-glass);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: 50px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition-theme);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 60px;
    justify-content: center;
    box-shadow: var(--shadow-medium);
}

.theme-toggle:hover {
    background: var(--bg-overlay);
    transform: scale(1.05);
    box-shadow: var(--shadow-heavy);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle .icon {
    font-size: 1.2rem;
    color: var(--text-primary);
    transition: var(--transition-theme);
}

/* Show/hide icons based on theme */
[data-theme="light"] .theme-toggle .dark-icon {
    opacity: 0;
    transform: scale(0) rotate(180deg);
}

[data-theme="light"] .theme-toggle .light-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

[data-theme="dark"] .theme-toggle .light-icon {
    opacity: 0;
    transform: scale(0) rotate(180deg);
}

[data-theme="dark"] .theme-toggle .dark-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Enhanced Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    transition: var(--transition-theme);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.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 0.5s;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--text-on-primary);
    box-shadow: var(--shadow-medium);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border-primary);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--border-focus);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-outline:hover {
    background: var(--color-primary);
    color: var(--text-on-primary);
    transform: translateY(-2px);
}

/* Card Styles */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
    transition: var(--transition-theme);
}

.card:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.card-glass {
    background: var(--bg-glass);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-glass);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--input-background);
    border: 2px solid var(--input-border);
    border-radius: 8px;
    color: var(--input-text);
    font-size: 1rem;
    transition: var(--transition-theme);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

/* Responsive utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.m-2 { margin: 0.5rem; }
.m-4 { margin: 1rem; }
.m-6 { margin: 1.5rem; }

.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }

/* Grid system */
.grid {
    display: grid;
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (min-width: 768px) {
    .md\\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .lg\\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Theme transition for all elements */
* {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease, 
                box-shadow 0.3s ease;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .theme-toggle {
        transition: none;
    }
    
    .btn {
        transition: none;
    }
    
    .card {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border-width: 3px;
        font-weight: 700;
    }
    
    .card {
        border-width: 2px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        border-width: 3px;
    }
}

/* Focus indicators for accessibility */
*:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.btn:focus-visible {
    outline-color: var(--text-on-primary);
    outline-offset: 3px;
}

/* Print styles */
@media print {
    .theme-toggle {
        display: none;
    }
    
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
}