/* ==========================================================================
   GREDI - Main Stylesheet
   Complete production-ready stylesheet with universal toast system
   ========================================================================== */

/* ==========================================================================
   1. CSS Custom Properties (Design Tokens)
   ========================================================================== */

:root {
    /* === Brand Colors (Your Bluish Palette) === */
    --brand-primary: #3b82f6;
    --brand-primary-dark: #1d4ed8;
    --brand-primary-light: #60a5fa;
    --brand-primary-rgb: 59, 130, 246;
    
    --brand-secondary: #64748b;
    --brand-success: #10b981;
    --brand-warning: #f59e0b;
    --brand-danger: #ef4444;
    --brand-info: #0ea5e9;
    --brand-purple: #8b5cf6;
    
    /* === Light Mode Colors === */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-2: #f1f5f9;
    --bg-input: #f8fafc;
    --bg-hover: rgba(59, 130, 246, 0.08);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    
    --border-color: #e2e8f0;
    --border-color-light: #f1f5f9;
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    
    /* === Typography === */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-math: 'Math Pazo', 'Times New Roman', serif;
    
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    --line-height-tight: 1.25;
    --line-height-normal: 1.6;
    --line-height-relaxed: 1.75;
    
    --navbar-height: 70px;
    
    /* === Spacing === */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    
    /* === Border Radius === */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;
    
    /* === Transitions === */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-theme: 250ms cubic-bezier(0.4, 0, 0.2, 1); /* Slightly faster than normal */
    
    /* === Z-Index Scale === */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-loading: 9999;
    --z-toast: 9999;
}

/* ==========================================================================
   2. DARK MODE OVERRIDES (Consolidated & Optimized)
   ========================================================================== */
/* 
DARK MODE MAINTENANCE GUIDE:
- Always test with real content (tables, modals, forms)
- Verify contrast ratios at webaim.org/contrastchecker
- When adding new components, add overrides HERE immediately
- Never use hardcoded #fff or #000 - use CSS variables
*/

[data-theme="dark"] {
    /* === Core Design Tokens === */
    --bg-body: #0b0f19;
    --bg-surface: #1e293b;
    --bg-surface-2: #334155;
    --bg-input: #1e293b;
    --bg-hover: rgba(59, 130, 246, 0.15);
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8; /* WCAG AA compliant on --bg-body */
    
    --border-color: #334155;
    --border-color-light: #1e293b;
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    
    /* Sidebar-specific (already defined in Section 17) */
    --sidebar-text-muted: #cbd5e1;
}

/* === GLOBAL PAGE STRUCTURE === */
[data-theme="dark"] html,
[data-theme="dark"] body {
    background-color: var(--bg-body) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] main,
[data-theme="dark"] #main-content,
[data-theme="dark"] .container,
[data-theme="dark"] .container-fluid {
    background-color: var(--bg-body) !important;
    color: var(--text-primary) !important;
}

/* === TYPOGRAPHY & TEXT UTILITIES === */
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6,
[data-theme="dark"] .h1, [data-theme="dark"] .h2, [data-theme="dark"] .h3,
[data-theme="dark"] .h4, [data-theme="dark"] .h5, [data-theme="dark"] .h6,
[data-theme="dark"] p, [data-theme="dark"] span, [data-theme="dark"] div,
[data-theme="dark"] li, [data-theme="dark"] label, [data-theme="dark"] small {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] small.text-muted {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}

[data-theme="dark"] a:not(.btn):not(.badge):not(.nav-link) {
    color: var(--brand-primary) !important;
}
[data-theme="dark"] a:not(.btn):not(.badge):not(.nav-link):hover {
    color: var(--brand-primary-light) !important;
}

/* === NAVIGATION & HEADER === */
[data-theme="dark"] .navbar {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .navbar .nav-link {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .navbar .nav-link:hover,
[data-theme="dark"] .navbar .nav-link.active {
    color: var(--brand-primary) !important;
}
[data-theme="dark"] .navbar-brand {
    color: var(--brand-primary) !important;
}

/* === CARDS & CONTAINERS === */
[data-theme="dark"] .card,
[data-theme="dark"] .filter-container,
[data-theme="dark"] .scheme-card,
[data-theme="dark"] .welcome-banner {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .card-header {
    background-color: var(--bg-surface-2) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .card-footer {
    background-color: var(--bg-surface-2) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .card-header-gradient,
[data-theme="dark"] .card-header.bg-success.bg-gradient {
    color: white !important;
}

/* === TABLES (Critical Fix) === */
[data-theme="dark"] table,
[data-theme="dark"] .table {
    --bs-table-bg: var(--bg-surface) !important;
    --bs-table-color: var(--text-primary) !important;
    --bs-table-border-color: var(--border-color) !important;
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] table th,
[data-theme="dark"] .table th {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] table td,
[data-theme="dark"] .table td {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] table tr:hover,
[data-theme="dark"] .table tr:hover {
    background-color: var(--bg-hover) !important;
}

/* === FORMS & INPUTS === */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--bg-input) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] .form-select::placeholder {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}
[data-theme="dark"] .form-label {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .form-check-input {
    background-color: var(--bg-input) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .form-check-input:checked {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
}

/* === DROPDOWNS (Critical Fix) === */
[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-lg) !important;
}
[data-theme="dark"] .dropdown-menu .dropdown-item {
    color: var(--text-primary) !important;
    background-color: transparent !important;
}
[data-theme="dark"] .dropdown-menu .dropdown-item:hover,
[data-theme="dark"] .dropdown-menu .dropdown-item:focus {
    background-color: var(--bg-hover) !important;
    color: var(--brand-primary) !important;
}
[data-theme="dark"] .dropdown-menu .dropdown-item.active,
[data-theme="dark"] .dropdown-menu .dropdown-item:active {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: var(--brand-primary-light) !important;
}
[data-theme="dark"] .dropdown-menu .text-muted,
[data-theme="dark"] .dropdown-menu small {
    color: var(--text-muted) !important;
}
[data-theme="dark"] .dropdown-menu .bg-light {
    background-color: var(--bg-surface-2) !important;
}

/* === MODALS === */
[data-theme="dark"] .modal-content {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border-color) !important;
    background-color: var(--bg-surface-2) !important;
}
[data-theme="dark"] .modal-title {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .modal-backdrop {
    background-color: #000 !important;
    opacity: 0.6 !important;
}

/* === BADGES (Critical Fix) === */
[data-theme="dark"] .badge.bg-light,
[data-theme="dark"] .badge.text-dark {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .badge.bg-white {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-primary) !important;
}
/* Preserve semantic badge colors */
[data-theme="dark"] .badge.bg-primary { background-color: var(--brand-primary) !important; color: white !important; }
[data-theme="dark"] .badge.bg-success { background-color: var(--brand-success) !important; color: white !important; }
[data-theme="dark"] .badge.bg-warning { background-color: var(--brand-warning) !important; color: white !important; }
[data-theme="dark"] .badge.bg-danger { background-color: var(--brand-danger) !important; color: white !important; }
[data-theme="dark"] .badge.bg-info { background-color: var(--brand-info) !important; color: white !important; }

/* === ALERTS === */
[data-theme="dark"] .alert {
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .alert-success { color: #6ee7b7 !important; }
[data-theme="dark"] .alert-warning { color: #fcd34d !important; }
[data-theme="dark"] .alert-danger { color: #f87171 !important; }
[data-theme="dark"] .alert-info { color: #67e8f9 !important; }

/* === BUTTONS (Preserve contrast) === */
[data-theme="dark"] .btn-outline-primary {
    color: var(--brand-primary) !important;
    border-color: var(--border-color) !important;
}

/* Ensures text/icons turn white when hovering outline buttons */
[data-theme="dark"] .btn-outline-primary:hover,
[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-success:hover,
[data-theme="dark"] .btn-outline-danger:hover,
[data-theme="dark"] .btn-outline-warning:hover,
[data-theme="dark"] .btn-outline-info:hover {
    color: white !important;
    /* Icons inside buttons inherit text color */
    fill: white !important; /* For SVG icons if used */
}

/* === FOOTER === */
[data-theme="dark"] footer {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] footer a {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] footer a:hover {
    color: var(--brand-primary) !important;
}

/* === UTILITY OVERRIDES === */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-light {
    background-color: var(--bg-surface) !important;
}
[data-theme="dark"] .border {
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .border-top {
    border-top-color: var(--border-color) !important;
}
[data-theme="dark"] .border-bottom {
    border-bottom-color: var(--border-color) !important;
}

/* === SCHEMES PAGE SPECIFICS === */
[data-theme="dark"] .schemes-header,
[data-theme="dark"] .page-header {
    background: transparent !important;
}
[data-theme="dark"] .strands-preview li {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .scheme-meta {
    border-top-color: var(--border-color) !important;
}

/* === ACCESSIBILITY: Focus States === */
[data-theme="dark"] a:focus,
[data-theme="dark"] button:focus,
[data-theme="dark"] .form-control:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3) !important;
}

/* AI Modal Dark Mode Support */
[data-theme="dark"] #aiConfirmModal .modal-content {
    background: var(--bg-surface, #1e293b) !important;
    border: 1px solid var(--border-color, #334155) !important;
    color: var(--text-primary, #f1f5f9) !important;
}
[data-theme="dark"] #aiConfirmModal .modal-header,
[data-theme="dark"] #aiConfirmModal .modal-footer {
    border-color: var(--border-color, #334155) !important;
}
[data-theme="dark"] #aiConfirmModal .bg-light {
    background: var(--bg-surface-2, #334155) !important;
    color: var(--text-muted, #94a3b8) !important;
}
[data-theme="dark"] #aiConfirmModal .btn-light {
    background: var(--bg-surface-2, #334155) !important;
    color: var(--text-primary, #f1f5f9) !important;
    border-color: var(--border-color, #475569) !important;
}
[data-theme="dark"] #aiConfirmModal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ==========================================================================
   3. Base Styles & Reset
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-padding-top: var(--navbar-height); /* Fix anchor link jumps */
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background-color: var(--bg-body);
    transition: background-color var(--transition-normal), color var(--transition-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.has-fixed-navbar {
    padding-top: var(--navbar-height); /* Prevent content overlap */
}

/* Mobile: account for taller collapsed navbar */
@media (max-width: 991px) {
    body.has-fixed-navbar {
        padding-top: calc(var(--navbar-height) + 20px);
    }
}

/* ==========================================================================
   4. Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: var(--space-3);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p {
    margin-top: 0;
    margin-bottom: var(--space-4);
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--brand-primary-dark);
    text-decoration: underline;
}

.text-primary { color: var(--brand-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--brand-success) !important; }
.text-warning { color: var(--brand-warning) !important; }
.text-danger { color: var(--brand-danger) !important; }

.font-math { font-family: var(--font-math); }
.font-mono { font-family: var(--font-mono); }


/* ==========================================================================
   6. Toast Base Styles
   ========================================================================== */

.toast {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    color: var(--text-primary) !important;
    border-left: 4px solid var(--brand-info) !important;
    min-width: 280px;
}

.toast-header {
    background: var(--bg-surface-2) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    padding: 0.75rem 1rem;
    font-weight: var(--font-weight-medium);
}

.toast-body {
    color: var(--text-primary) !important;
    padding: 0.75rem 1rem;
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.toast .btn-close {
    filter: none;
    opacity: 0.5;
    padding: 0.5rem;
}

.toast .btn-close:hover {
    opacity: 1;
}

/* Dark mode close button fix */
[data-theme="dark"] .toast .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ==========================================================================
   7. Toast Type Variants
   ========================================================================== */

.toast-success {
    border-left-color: var(--brand-success) !important;
}

.toast-success .toast-header {
    background: rgba(16, 185, 129, 0.1) !important;
}

.toast-success .toast-title {
    color: var(--brand-success) !important;
}

.toast-error {
    border-left-color: var(--brand-danger) !important;
}

.toast-error .toast-header {
    background: rgba(239, 68, 68, 0.1) !important;
}

.toast-error .toast-title {
    color: var(--brand-danger) !important;
}

.toast-warning {
    border-left-color: var(--brand-warning) !important;
}

.toast-warning .toast-header {
    background: rgba(245, 158, 11, 0.1) !important;
}

.toast-warning .toast-title {
    color: var(--brand-warning) !important;
}

.toast-info {
    border-left-color: var(--brand-info) !important;
}

.toast-info .toast-header {
    background: rgba(14, 165, 233, 0.1) !important;
}

.toast-info .toast-title {
    color: var(--brand-info) !important;
}

/* ==========================================================================
   8. Toast Animation
   ========================================================================== */

.toast {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(20px);
}

/* ==========================================================================
   9. Cards (Your Preference: No Borders, Sleek)
   ========================================================================== */

.card {
    background: var(--bg-surface);
    border: none !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-normal), transform var(--transition-fast);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color) !important;
    padding: var(--space-4) var(--space-5);
    font-weight: var(--font-weight-semibold);
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    background: var(--bg-surface-2);
    border-top: 1px solid var(--border-color) !important;
    padding: var(--space-4) var(--space-5);
}

/* Card Variants */
.card-primary {
    border-left: 4px solid var(--brand-primary) !important;
}

.card-success {
    border-left: 4px solid var(--brand-success) !important;
}

.card-warning {
    border-left: 4px solid var(--brand-warning) !important;
}

.card-danger {
    border-left: 4px solid var(--brand-danger) !important;
}

/* ==========================================================================
   10. Buttons
   ========================================================================== */

.btn {
    font-weight: var(--font-weight-medium);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.25);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
    border: none;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--brand-primary-rgb), 0.4);
    color: white;
    text-decoration: none;
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline-primary {
    background: transparent;
    border: 2px solid var(--brand-primary);
    color: var(--brand-primary);
}

.btn-outline-primary:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
}

.btn-secondary {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-success {
    background: var(--brand-success);
    border: none;
    color: white;
}

.btn-warning {
    background: var(--brand-warning);
    border: none;
    color: white;
}

.btn-danger {
    background: var(--brand-danger);
    border: none;
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-size-lg);
}

.btn-block {
    width: 100%;
}

/* Button with Icon */
.btn-icon {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   11. Forms (Your Preference: Modern, View Password)
   ========================================================================== */

.form-label {
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    display: block;
}

.form-control,
.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: var(--font-size-base);
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.15);
    background: var(--bg-surface);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled,
.form-control[readonly] {
    background: var(--bg-surface-2);
    opacity: 0.7;
    cursor: not-allowed;
}

.form-text {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* Invalid State */
.form-control.is-invalid,
.was-validated .form-control:invalid {
    border-color: var(--brand-danger);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23ef4444'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23ef4444' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: var(--space-1);
    font-size: var(--font-size-sm);
    color: var(--brand-danger);
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}

/* Password Toggle (Your Preference) */
.form-password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
    z-index: 10;
}

.password-toggle:hover {
    color: var(--brand-primary);
    background: var(--bg-hover);
}

.password-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--brand-primary-rgb), 0.25);
}

/* Remember Me Checkbox */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.form-check-input {
    width: 18px;
    height: 18px;
    margin-top: 0;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.form-check-input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.form-check-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.25);
}

.form-check-label {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* ==========================================================================
   12. Tables (Your Preference: No Borders)
   ========================================================================== */

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    border: none !important;
    margin-bottom: 0;
}

.table th {
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    padding: var(--space-3) var(--space-4);
    border-bottom: 2px solid var(--border-color) !important;
    background: var(--bg-surface-2);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color) !important;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: var(--bg-hover);
}

.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(var(--brand-primary-rgb), 0.03);
}

.table-sm th,
.table-sm td {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
}

/* DataTables Integration */
.dataTables_wrapper {
    padding: var(--space-4);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: var(--space-4);
}

.dataTables_wrapper .dataTables_info {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    padding-top: var(--space-3);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: none !important;
    background: transparent !important;
    color: var(--text-secondary) !important;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--brand-primary) !important;
    color: white !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--bg-hover) !important;
    color: var(--brand-primary) !important;
}

/* ==========================================================================
   13. Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: var(--font-weight-medium);
    padding: 0.35rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
}

.badge.bg-primary { background: var(--brand-primary) !important; }
.badge.bg-success { background: var(--brand-success) !important; }
.badge.bg-warning { background: var(--brand-warning) !important; color: white !important; }
.badge.bg-danger { background: var(--brand-danger) !important; }
.badge.bg-secondary { background: var(--brand-secondary) !important; }
.badge.bg-info { background: var(--brand-info) !important; }

/* ==========================================================================
   14. Progress Bars
   ========================================================================== */

.progress {
    background: var(--bg-surface-2);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-primary-light));
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    color: white;
    font-weight: var(--font-weight-semibold);
}

.progress-bar.bg-success {
    background: linear-gradient(90deg, var(--brand-success), #34d399);
}

.progress-bar.bg-warning {
    background: linear-gradient(90deg, var(--brand-warning), #fbbf24);
}

.progress-bar.bg-danger {
    background: linear-gradient(90deg, var(--brand-danger), #f87171);
}

/* ==========================================================================
   15. Alerts
   ========================================================================== */

.alert {
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.alert-icon {
    font-size: var(--font-size-xl);
    flex-shrink: 0;
}

.alert-content {
    flex-grow: 1;
}

.alert-success {
    background: rgba(16, 185, 129, 0.12);
    color: #065f46;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #991b1b;
}

.alert-info {
    background: rgba(14, 165, 233, 0.12);
    color: #075985;
}

[data-theme="dark"] .alert-success { color: #6ee7b7; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-danger { color: #f87171; }
[data-theme="dark"] .alert-info { color: #67e8f9; }

.btn-close {
    filter: none;
    opacity: 0.5;
}

.btn-close:hover {
    opacity: 1;
}

/* ==========================================================================
   16. Navbar & Navigation
   ========================================================================== */

.navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-3) 0;
    transition: background var(--transition-normal), border-color var(--transition-normal);
}

.navbar-brand {
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-xl);
    color: var(--brand-primary) !important;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.navbar-brand:hover {
    color: var(--brand-primary-dark) !important;
    text-decoration: none;
}

.nav-link {
    color: var(--text-secondary) !important;
    font-weight: var(--font-weight-medium);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    color: var(--brand-primary) !important;
    background: var(--bg-hover);
    text-decoration: none;
}

/* Avatar */
.avatar-img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-color);
}

/* Dropdown */
.dropdown-menu {
    background: var(--bg-surface);
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    margin-top: var(--space-2);
    min-width: 220px;
}

.dropdown-item {
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: var(--font-weight-medium);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--brand-primary);
    text-decoration: none;
}

.dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--brand-danger);
}

.dropdown-item.active {
    background: var(--bg-hover);
    color: var(--brand-primary);
}

.dropdown-divider {
    border-color: var(--border-color) !important;
    margin: var(--space-2) 0;
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
}

/* ==========================================================================
   17. Sidebar Navigation (Dashboard)
   ========================================================================== */

/* === Sidebar CSS Variables (Extend Design Tokens) === */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --sidebar-footer-height: 72px;
    
    /* Sidebar-specific colors (light mode) */
    --sidebar-bg: var(--bg-surface);
    --sidebar-border: var(--border-color);
    --sidebar-text: var(--text-secondary);
    --sidebar-text-muted: var(--text-muted);
    --sidebar-hover-bg: var(--bg-hover);
    --sidebar-active-bg: rgba(var(--brand-primary-rgb), 0.1);
    --sidebar-active-text: var(--brand-primary);
    --sidebar-active-border: var(--brand-primary);
    --sidebar-footer-bg: var(--bg-surface-2);
    --sidebar-footer-text: var(--brand-danger);
    --sidebar-footer-hover-bg: rgba(239, 68, 68, 0.1);
    --sidebar-footer-hover-text: var(--brand-danger);
    --sidebar-section-border: var(--border-color);
    --sidebar-section-title: var(--text-muted);
    --sidebar-shadow: var(--shadow-sm);
}

/* Dark mode sidebar overrides */
[data-theme="dark"] {
    --sidebar-bg: var(--bg-surface);
    --sidebar-border: var(--border-color);
    --sidebar-text: var(--text-secondary);
    --sidebar-text-muted: var(--text-muted);
    --sidebar-hover-bg: var(--bg-hover);
    --sidebar-active-bg: rgba(var(--brand-primary-rgb), 0.2);
    --sidebar-active-text: var(--brand-primary-light);
    --sidebar-active-border: var(--brand-primary-light);
    --sidebar-footer-bg: var(--bg-surface-2);
    --sidebar-footer-text: #f87171;
    --sidebar-footer-hover-bg: rgba(248, 113, 113, 0.15);
    --sidebar-footer-hover-text: #fca5a5;
    --sidebar-section-border: var(--border-color);
    --sidebar-section-title: var(--text-muted);
    --sidebar-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* === Sidebar Layout Container === */
#dashboard-container {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    margin-top: var(--navbar-height);
    gap: 0;
    position: relative;
}

#sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    transition: width var(--transition-normal);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-width: 0;
    box-shadow: var(--sidebar-shadow);
}

#sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Prevent content shift during collapse */
#sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: -1px;
    bottom: 0;
    width: 1px;
    background: var(--sidebar-border);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

#sidebar.collapsed::after {
    opacity: 1;
}

/* === Sidebar User Info Section === */
#sidebar .user-info {
    padding: var(--space-5) var(--space-4) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: var(--space-3);
    min-width: 0;
}

#sidebar .avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-base);
    flex-shrink: 0;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--brand-primary-rgb), 0.2);
}

#sidebar .avatar-placeholder:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(var(--brand-primary-rgb), 0.3);
}

#sidebar .avatar-placeholder img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

#sidebar .user-details {
    min-width: 0;
    flex: 1;
}

#sidebar .user-name {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#sidebar .user-email {
    font-size: var(--font-size-xs);
    color: var(--sidebar-text-muted);
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Sidebar Navigation Links === */
#sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.875rem var(--space-4);
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    transition: background-color var(--transition-fast), color var(--transition-fast), padding-left var(--transition-fast);
    border-radius: var(--radius-md);
    margin: 0 var(--space-2) var(--space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

#sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--sidebar-active-border);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: height var(--transition-fast);
}

#sidebar .nav-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--text-primary);
    text-decoration: none;
}

#sidebar .nav-link:hover::before {
    height: 60%;
}

#sidebar .nav-link i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

#sidebar .nav-link:hover i {
    transform: scale(1.1);
}

#sidebar .nav-link.active {
    background-color: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
    border-left: 3px solid var(--sidebar-active-border) !important;
    padding-left: calc(var(--space-4) - 3px) !important;
    font-weight: var(--font-weight-semibold);
}

#sidebar .nav-link.active::before {
    height: 0 !important;
}

#sidebar .nav-link.active i {
    transform: scale(1.1);
    color: var(--sidebar-active-text);
}

/* === Collapsed State: Hide Text Elements === */
#sidebar.collapsed .nav-text,
#sidebar.collapsed .user-details,
#sidebar.collapsed .sidebar-section-title {
    display: none !important;
}

#sidebar.collapsed .user-info {
    justify-content: center;
    padding: var(--space-4) 0 var(--space-3);
}

#sidebar.collapsed .nav-item .nav-link {
    justify-content: center;
    padding: 0.875rem !important;
    margin: var(--space-1) var(--space-2);
    border-left: none !important;
}

#sidebar.collapsed .nav-item .nav-link::before {
    display: none !important;
}

#sidebar.collapsed .avatar-placeholder {
    margin: 0 auto var(--space-3);
    width: 36px;
    height: 36px;
    font-size: var(--font-size-sm);
}

/* === Collapsed + Active Combined State === */
#sidebar.collapsed .nav-link.active {
    background-color: var(--sidebar-active-bg) !important;
    border-left: none !important;
    padding: 0.875rem !important;
}

#sidebar.collapsed .nav-link.active i {
    transform: scale(1.1);
    color: var(--sidebar-active-text);
}

/* === Sidebar Sections & Dividers === */
#sidebar .sidebar-section {
    padding: var(--space-2) 0 var(--space-3) var(--space-4);
    margin-top: var(--space-2);
    border-top: 1px solid var(--sidebar-section-border);
}

#sidebar .sidebar-section:first-child {
    border-top: none;
    padding-top: 0;
}

#sidebar .sidebar-section-title {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sidebar-section-title);
    font-weight: var(--font-weight-semibold);
    padding-left: var(--space-1);
    margin-bottom: var(--space-2);
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

#sidebar .sidebar-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--sidebar-section-border);
    margin-left: var(--space-2);
}

/* === Sidebar Footer (Logout) === */
#sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: var(--space-3) var(--space-4);
    margin-top: auto;
    background: var(--sidebar-footer-bg);
}

#sidebar-footer .nav-link {
    color: var(--sidebar-footer-text);
    padding: var(--space-2) 0;
    margin: 0;
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

#sidebar-footer .nav-link:hover {
    background: var(--sidebar-footer-hover-bg);
    color: var(--sidebar-footer-hover-text);
    text-decoration: none;
}

#sidebar-footer .nav-link i {
    transition: transform var(--transition-fast);
}

#sidebar-footer .nav-link:hover i {
    transform: translateX(2px);
}

/* === Main Content Area === */
#main-content {
    flex: 1;
    padding: var(--space-6);
    background-color: var(--bg-body);
    min-width: 0;
    transition: padding var(--transition-normal);
}

/* === Toggle Buttons === */
#mobile-sidebar-toggle,
#desktop-collapse-toggle {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    margin-left: var(--space-2);
}

#mobile-sidebar-toggle:hover,
#desktop-collapse-toggle:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
    transform: translateY(-1px);
}

#mobile-sidebar-toggle:active,
#desktop-collapse-toggle:active {
    transform: translateY(0);
}

#mobile-sidebar-toggle:focus,
#desktop-collapse-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.25);
}

/* === Collapse Icon Animation === */
#collapse-icon {
    transition: transform var(--transition-normal);
}

#sidebar.collapsed #collapse-icon {
    transform: rotate(180deg);
}

/* === Mobile Responsive Styles === */
@media (max-width: 991.98px) {
    #sidebar {
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        height: calc(100vh - var(--navbar-height));
        transform: translateX(-100%);
        z-index: 1020;
        box-shadow: var(--shadow-xl);
        width: var(--sidebar-width) !important;
        transition: transform var(--transition-normal);
    }
    
    #sidebar.show {
        transform: translateX(0);
    }
    
    #main-content {
        padding: var(--space-4);
    }
    
    #desktop-collapse-toggle {
        display: none !important;
    }
    
    /* Mobile backdrop when sidebar is open */
    #sidebar.show::before {
        content: '';
        position: fixed;
        top: var(--navbar-height);
        left: var(--sidebar-width);
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: -1;
        animation: fadeIn 0.2s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

@media (max-width: 991.98px) {
    #mobile-sidebar-toggle {
        display: flex;
    }
    #desktop-collapse-toggle {
        display: none;
    }
}

@media (min-width: 992px) {
    #mobile-sidebar-toggle {
        display: none;
    }
}

/* === Sidebar Card Integration (for analytics widgets) === */
#sidebar .analytics-card {
    background: var(--bg-surface-2);
    border-left: 4px solid var(--brand-primary);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin: var(--space-2) var(--space-2);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

#sidebar .analytics-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#sidebar .analytics-card .stat-icon {
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: rgba(var(--brand-primary-rgb), 0.1);
    color: var(--brand-primary);
    transition: transform var(--transition-fast);
}

#sidebar .analytics-card:hover .stat-icon {
    transform: scale(1.1);
}

#sidebar .analytics-card .stat-value {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

#sidebar .analytics-card .stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* === Dashboard Page Header === */
.page-header {
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-4);
}

/* === Welcome Banner Card === */
.welcome-banner {
    position: relative;
    background: linear-gradient(135deg, var(--bg-surface), var(--bg-surface-2));
    border-left: 4px solid var(--brand-primary);
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(var(--brand-primary-rgb), 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.welcome-banner .badge {
    font-weight: var(--font-weight-medium);
}

/* === Stat Cards === */
.stat-card {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon-wrapper {
    box-shadow: 0 4px 12px rgba(var(--brand-primary-rgb), 0.3);
    transition: transform var(--transition-fast);
}

.stat-card:hover .stat-icon-wrapper {
    transform: scale(1.05);
}

/* === Hover Lift Effect === */
.hover-lift {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg) !important;
}

/* === Purchase Cards === */
.purchase-card {
    border: 1px solid var(--border-color);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.purchase-card:hover {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-md);
}

/* === Table Styling - Borderless as Preferred === */
.table-borderless tbody tr {
    border-bottom: 1px dashed var(--border-color) !important;
    transition: background-color var(--transition-fast);
}

.table-borderless tbody tr:hover {
    background-color: var(--bg-hover) !important;
}

.table-borderless tbody tr:last-child {
    border-bottom: none !important;
}

.table-borderless .badge {
    font-weight: var(--font-weight-medium);
}

/* === Empty State Cards === */
.card.border-dashed {
    border: 2px dashed var(--border-color) !important;
    background: var(--bg-surface-2);
}

/* === Button Icon Utility === */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.btn-icon:hover {
    transform: scale(1.05);
}

.btn-icon.btn-light {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-icon.btn-light:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
}

/* === Gradient Badge Support === */
.bg-gradient {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark)) !important;
}

.bg-success.bg-gradient {
    background: linear-gradient(135deg, var(--brand-success), #059669) !important;
}

.bg-info.bg-gradient {
    background: linear-gradient(135deg, var(--brand-info), #0284c7) !important;
}

/* === Trend Indicators === */
.text-success { color: var(--brand-success) !important; }
.text-danger { color: var(--brand-danger) !important; }

/* === Sidebar Scrollbar Styling (WebKit) === */
#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox scrollbar */
#sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* === Accessibility: Focus States === */
#sidebar .nav-link:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: -2px;
}

#sidebar .nav-link:focus:not(:focus-visible) {
    outline: none;
}

#sidebar .nav-link:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: -2px;
}

#mobile-sidebar-toggle:focus-visible,
#desktop-collapse-toggle:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* === Reduced Motion Support === */
@media (prefers-reduced-motion: reduce) {
    #sidebar,
    #sidebar .nav-link,
    #sidebar .avatar-placeholder,
    .stat-card,
    .hover-lift,
    .purchase-card,
    #collapse-icon,
    .btn-icon {
        transition: none !important;
        animation: none !important;
    }
    
    #sidebar .nav-link:hover i,
    #sidebar .avatar-placeholder:hover,
    .stat-card:hover .stat-icon-wrapper {
        transform: none !important;
    }
}

/* === Print Styles === */
@media print {
    #sidebar,
    #mobile-sidebar-toggle,
    #desktop-collapse-toggle {
        display: none !important;
    }
    
    #main-content {
        padding: 0;
        min-width: auto;
    }
}

/* ==========================================================================
   18. Loading States
   ========================================================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: var(--z-loading);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-surface-2);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    margin-top: var(--space-4);
    font-weight: var(--font-weight-medium);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-hover) 50%, var(--bg-surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
    color: transparent !important;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   19. Social Login Buttons (Your Preference)
   ========================================================================== */

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    width: 100%;
}

.btn-social:hover {
    background: var(--bg-surface-2);
    text-decoration: none;
    border-color: var(--text-muted);
}

.btn-social-google {
    color: #ea4335;
}

.btn-social-google:hover {
    background: #f8f9fa;
}

.btn-social-facebook {
    color: #1877f2;
}

.btn-social-facebook:hover {
    background: #f0f2f5;
}

.btn-social-apple {
    color: #000;
}

[data-theme="dark"] .btn-social-apple {
    color: white;
}

.social-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: var(--space-5) 0;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.social-divider::before,
.social-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.social-divider span {
    padding: 0 var(--space-3);
}

/* ==========================================================================
   20. Footer
   ========================================================================== */

footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: var(--space-10) 0 var(--space-6);
    margin-top: var(--space-12);
}

footer h6 {
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

footer ul li {
    margin-bottom: var(--space-2);
}

footer ul li a {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    transition: color var(--transition-fast);
}

footer ul li a:hover {
    color: var(--brand-primary);
    text-decoration: none;
}

.hover-primary:hover {
    color: var(--brand-primary) !important;
}

/* ==========================================================================
   21. Print Styles
   ========================================================================== */

@media print {
    .no-print,
    .navbar,
    footer,
    .btn,
    .alert,
    .loading-overlay,
    #toast-container {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
        line-height: 1.5;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 10pt;
        color: #666;
    }
    
    .table {
        border: 1px solid #ddd !important;
    }
    
    .table th,
    .table td {
        border: 1px solid #ddd !important;
    }
}

/* ==========================================================================
   22. Responsive Utilities
   ========================================================================== */

@media (max-width: 991px) {
    .navbar-collapse {
        background: var(--bg-surface);
        padding: var(--space-4);
        border-radius: var(--radius-lg);
        margin-top: var(--space-2);
        box-shadow: var(--shadow-md);
    }
    
    .navbar-nav {
        gap: var(--space-1);
    }
}

@media (max-width: 575px) {
    :root {
        --font-size-base: 0.9375rem;
    }
    
    .card-body {
        padding: var(--space-4);
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   23. Utility Classes
   ========================================================================== */

/* Flexbox */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.flex-grow-1 { flex-grow: 1; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* Spacing */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }

/* Text */
.text-center { text-align: center; }
.text-start { text-align: start; }
.text-end { text-align: end; }
.fw-normal { font-weight: var(--font-weight-normal); }
.fw-medium { font-weight: var(--font-weight-medium); }
.fw-semibold { font-weight: var(--font-weight-semibold); }
.fw-bold { font-weight: var(--font-weight-bold); }

/* Visibility */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }

@media (min-width: 992px) {
    .d-lg-none { display: none; }
    .d-lg-block { display: block; }
    .d-lg-inline { display: inline; }
}

/* Border Radius */
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadow */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* ==========================================================================
   24. CBC Planner Specific Components
   ========================================================================== */

/* Scheme Card */
.scheme-card {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.scheme-card:hover {
    transform: translateY(-2px);
}

.scheme-card .card-body {
    padding: var(--space-5);
}

.scheme-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.scheme-badge {
    font-size: var(--font-size-xs);
    padding: 0.25rem 0.5rem;
    background: var(--bg-surface-2);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
}

/* AI Generation Card */
.ai-card {
    border: 2px solid var(--brand-primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(29, 78, 216, 0.05));
}

.ai-badge {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-purple));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Download Progress */
.download-progress {
    background: var(--bg-surface-2);
    border-radius: var(--radius-full);
    padding: var(--space-3);
    margin-top: var(--space-3);
}

.download-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

/* Subscription Tier Card */
.tier-card {
    position: relative;
    overflow: hidden;
}

.tier-card.popular {
    border: 2px solid var(--brand-primary);
}

.tier-card.popular::before {
    content: 'Most Popular';
    position: absolute;
    top: var(--space-3);
    right: -30px;
    background: var(--brand-primary);
    color: white;
    padding: 0.25rem 2.5rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    transform: rotate(45deg);
}

/* Feature List */
.feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feature-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.feature-list li i {
    color: var(--brand-success);
    flex-shrink: 0;
    margin-top: 2px;
}

.feature-list li.disabled {
    color: var(--text-muted);
    text-decoration: line-through;
}

.feature-list li.disabled i {
    color: var(--text-muted);
}

/* ==========================================================================
   25. Animations
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-slide-up {
    animation: slideUp 0.4s ease;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   26. Accessibility
   ========================================================================== */

/* Focus states for accessibility */
a:focus,
button:focus,
input:focus,
select:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--brand-primary);
    color: white;
    padding: 8px;
    z-index: 10000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* Screen reader only */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   27. Dark Mode Toggle Button (Global)
   ========================================================================== */

/* ===== Toggle Button Styles ===== */
.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: var(--z-fixed);
    box-shadow: var(--shadow-md);
    padding: 0;
    font-size: 1.25rem;
    line-height: 1;
}

.theme-toggle:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.4);
}

.theme-toggle i {
    transition: transform var(--transition-fast);
}

.theme-toggle:hover i {
    transform: scale(1.1);
}

/* ===== Dark Mode Icon States ===== */
[data-theme="dark"] .theme-toggle i.bi-moon-stars-fill::before {
    content: "\f43c"; /* Bootstrap Icons sun-fill unicode */
}

/* Alternative: Use class swapping via JS (more reliable) */
.theme-toggle .bi-moon-stars-fill,
.theme-toggle .bi-sun-fill {
    transition: opacity var(--transition-fast);
}

.theme-toggle .bi-sun-fill {
    display: none;
}

[data-theme="dark"] .theme-toggle .bi-moon-stars-fill {
    display: none;
}

[data-theme="dark"] .theme-toggle .bi-sun-fill {
    display: inline-block;
}

/* ===== Mobile Responsiveness ===== */
@media (max-width: 575.98px) {
    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
}

/* ===== Print: Hide Toggle ===== */
@media print {
    .theme-toggle {
        display: none !important;
    }
}

/* ===== Reduced Motion Support ===== */
@media (prefers-reduced-motion: reduce) {
    .theme-toggle,
    .theme-toggle i {
        transition: none !important;
        transform: none !important;
    }
}

/* ===== Accessibility: High Contrast Mode ===== */
@media (prefers-contrast: high) {
    .theme-toggle {
        border-width: 3px;
        box-shadow: 0 0 0 2px var(--text-primary);
    }
}

/* ==========================================================================
   28. Theme Transition Animations
   ========================================================================== */

/* ===== Smooth Theme Transitions ===== */
/* Apply transitions to key theme-dependent properties */
html,
body,
.card,
.section,
.content-card,
.lesson-plan-card,
.navbar,
.dropdown-menu,
.modal-content,
.toast,
.btn,
.form-control,
.form-select,
.table,
thead,
tbody,
tr,
td,
th,
a:not(.btn),
.text-primary,
.text-secondary,
.text-muted,
.border,
.border-top,
.border-bottom,
.bg-surface,
.bg-surface-2,
.bg-body {
    transition: 
        background-color var(--transition-theme),
        border-color var(--transition-theme),
        color var(--transition-theme),
        box-shadow var(--transition-normal),
        fill var(--transition-normal),
        stroke var(--transition-normal) !important;
}

/* ===== Toggle Button Click Animation ===== */
.theme-toggle:active {
    transform: scale(0.92) !important;
}

.theme-toggle.theme-changing {
    animation: themePulse 0.3s ease-in-out;
}

@keyframes themePulse {
    0% { transform: scale(1); box-shadow: var(--shadow-md); }
    50% { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(var(--brand-primary-rgb), 0.3); }
    100% { transform: scale(1); box-shadow: var(--shadow-lg); }
}

/* ===== Subtle Page-Wide Fade Overlay (Optional) ===== */
/* Creates a brief cross-fade effect during theme switch */
.theme-transition-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    opacity: 0;
    pointer-events: none;
    z-index: var(--z-loading);
    transition: opacity 0.2s ease;
}

.theme-transition-overlay.active {
    opacity: 0.15;
}

/* ===== Reduced Motion: Disable All Animations ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
    
    .theme-toggle:active,
    .theme-toggle.theme-changing {
        transform: none !important;
        animation: none !important;
    }
    
    .theme-transition-overlay {
        display: none !important;
    }
}

/* ===== High Contrast Mode: Simplify Transitions ===== */
@media (prefers-contrast: high) {
    html, body, .card, .section {
        transition-duration: 0.1s !important;
    }
}