/* Theme Variables - Light and Dark Mode Support */

/* Default to dark theme */
:root {
  /* Theme Colors - Dark Mode (Default) */
  --theme-bg-primary: #0F0F0F;
  --theme-bg-secondary: #1A1A1A;
  --theme-bg-tertiary: #262626;
  --theme-bg-card: #1F1F1F;
  --theme-bg-hover: #2A2A2A;
  --theme-bg-input: #1A1A1A;
  --theme-bg-modal: #1A1A1A;
  
  /* Text Colors - Dark Mode */
  --theme-text-primary: #F9FAFB;
  --theme-text-secondary: #D1D5DB;
  --theme-text-muted: #9CA3AF;
  --theme-text-dim: #6B7280;
  --theme-text-inverse: #1F2937;
  
  /* Border Colors - Dark Mode */
  --theme-border-default: rgba(255, 255, 255, 0.1);
  --theme-border-hover: rgba(255, 255, 255, 0.2);
  --theme-border-focus: rgba(251, 4, 4, 0.5);
  
  /* Shadow Colors - Dark Mode */
  --theme-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --theme-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --theme-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --theme-shadow-glow: 0 0 20px rgba(251, 4, 4, 0.3);
  
  /* Component Specific - Dark Mode */
  --theme-navbar-bg: #0F0F0F;
  --theme-sidebar-bg: #1A1A1A;
  --theme-footer-bg: #0F0F0F;
  --theme-dropdown-bg: #262626;
  --theme-tooltip-bg: #374151;
  --theme-code-bg: #1F2937;
  
  /* Form Elements - Dark Mode */
  --theme-input-bg: #1A1A1A;
  --theme-input-border: rgba(255, 255, 255, 0.1);
  --theme-input-focus-border: var(--blufftube-red);
  --theme-button-bg: #374151;
  --theme-button-hover-bg: #4B5563;
  
  /* Status Colors remain consistent */
  --theme-success: #10B981;
  --theme-warning: #F59E0B;
  --theme-danger: #EF4444;
  --theme-info: #3B82F6;
}

/* Light theme - Modern Platform Inspired */
[data-theme="light"] {
  /* Theme Colors - Sophisticated palette */
  --theme-bg-primary: #FAFAFA; /* Soft off-white background */
  --theme-bg-secondary: #F5F5F5; /* Light gray for sections */
  --theme-bg-tertiary: #EEEEEE; /* Medium gray for contrast */
  --theme-bg-card: #FFFFFF; /* Pure white cards for pop */
  --theme-bg-hover: #E8E8E8;
  --theme-bg-input: #FFFFFF;
  --theme-bg-modal: #FFFFFF;
  
  /* Text Colors - Optimized contrast */
  --theme-text-primary: #1A1A1A; /* Soft black for readability */
  --theme-text-secondary: #5A5A5A; /* Dark gray */
  --theme-text-muted: #757575;
  --theme-text-dim: #9E9E9E;
  --theme-text-inverse: #FFFFFF;
  
  /* Border Colors - Defined but subtle */
  --theme-border-default: rgba(0, 0, 0, 0.08);
  --theme-border-hover: rgba(0, 0, 0, 0.12);
  --theme-border-focus: rgba(251, 4, 4, 0.4);
  
  /* Shadow Colors - Material-inspired depth */
  --theme-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --theme-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --theme-shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);
  --theme-shadow-glow: 0 0 20px rgba(251, 4, 4, 0.15);
  
  /* Component Specific - Distinct sections */
  --theme-navbar-bg: #FFFFFF; /* Clean white navbar */
  --theme-sidebar-bg: #F8F8F8; /* Slightly gray sidebar */
  --theme-footer-bg: #F5F5F5;
  --theme-dropdown-bg: #FFFFFF;
  --theme-tooltip-bg: #424242;
  --theme-code-bg: #F5F5F5;
  
  /* Form Elements - Light Mode */
  --theme-input-bg: #FFFFFF;
  --theme-input-border: rgba(0, 0, 0, 0.12);
  --theme-input-focus-border: var(--blufftube-red);
  --theme-button-bg: #E0E0E0;
  --theme-button-hover-bg: #D5D5D5;
}

/* --- Base Sidebar Styles (Consistent across themes) --- */
.enhanced-sidebar {
    display: flex;
    flex-direction: column;
}
.enhanced-heading {
    font-weight: 600;
    font-size: 0.875rem !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem 0.5rem 1.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}
.enhanced-nav-link {
    padding: 0.75rem 1.5rem;
    margin: 0.125rem 0.75rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.15s ease-in-out;
    border: 1px solid transparent;
}
.enhanced-nav-link .nav-link-icon {
    width: 1.25rem;
    margin-right: 0.75rem;
    text-align: center;
    transition: color 0.15s ease-in-out;
}

/* --- Dark Theme Sidebar Styles --- */
.enhanced-sidebar {
    background: #000;
    border-right: 1px solid #4b5563;
}
.enhanced-heading {
    color: #f9fafb;
}
.enhanced-heading i {
    color: #6900c7;
    font-size: 1rem;
}
.enhanced-nav-link {
    color: #d1d5db;
}
.enhanced-nav-link .nav-link-icon {
    color: #9ca3af;
}
.enhanced-nav-link:hover {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    color: #ffffff;
    border-color: #4b5563;
    transform: translateX(4px);
}
.enhanced-nav-link:hover .nav-link-icon {
    color: #6900c7;
}
.enhanced-nav-link.active {
    background: linear-gradient(135deg, #6900c7 0%, #5800e8 100%);
    color: #ffffff;
    border-color: #6900c7;
}
.enhanced-nav-link.active .nav-link-icon,
.enhanced-nav-link.active .nav-link-text {
    color: #ffffff;
}

/* --- Light Theme Overrides --- */

/* General Text Overrides */
[data-theme="light"] .text-light,
[data-theme="light"] .text-white {
    color: var(--theme-text-primary) !important;
}
[data-theme="light"] .text-light-50 {
    color: var(--theme-text-secondary) !important;
}

/* Search Bar */
[data-theme="light"] .form-control::placeholder {
  color: #9ca3af !important;
  opacity: 1 !important;
}
[data-theme="light"] .input-group-solid .form-control {
    border: 1px solid #ced4da !important;
}

/* Borders - More defined in light mode */
[data-theme="light"] .topnav {
    border-bottom: 1px solid rgba(0, 0, 0, 0.2) !important;
}
[data-theme="light"] .enhanced-sidebar {
    border-right: 1px solid rgba(0, 0, 0, 0.2) !important;
}
[data-theme="light"] .icon-sidenav {
    border-right: 1px solid rgba(0, 0, 0, 0.2) !important;
}

/* Sidebar Container */
[data-theme="light"] .enhanced-sidebar {
    background-color: var(--theme-sidebar-bg);
}

/* Legal section border in light mode */
[data-theme="light"] .legal-section-bottom {
    border-top-color: rgba(0, 0, 0, 0.2);
}

/* Icon sidebar background in light mode */
[data-theme="light"] .icon-sidenav,
[data-theme="light"] .icon-sidenav .nav,
[data-theme="light"] .icon-sidenav .nav-item,
[data-theme="light"] .icon-sidenav ul {
    background-color: var(--theme-sidebar-bg) !important;
}

/* Icon sidebar text and icons in light mode */
[data-theme="light"] .icon-sidenav .nav-link {
    color: var(--theme-text-secondary) !important;
    background-color: transparent !important;
}

[data-theme="light"] .icon-sidenav .nav-icon {
    color: var(--theme-text-secondary) !important;
    background-color: transparent !important;
}

/* Ensure Font Awesome icons don't have backgrounds */
[data-theme="light"] .icon-sidenav .fas,
[data-theme="light"] .icon-sidenav .far,
[data-theme="light"] .icon-sidenav .fab,
[data-theme="light"] .icon-sidenav i {
    background-color: transparent !important;
    color: var(--theme-text-secondary) !important;
}

[data-theme="light"] .icon-sidenav .nav-text {
    color: var(--theme-text-secondary) !important;
}

/* Fix any background on nav items in light mode */
[data-theme="light"] .icon-sidenav .nav-item {
    background-color: transparent !important;
}

[data-theme="light"] .icon-sidenav li {
    background-color: transparent !important;
}

/* Remove all possible backgrounds in icon sidebar for light mode */
[data-theme="light"] .icon-sidenav * {
    background-color: transparent !important;
}

/* Then re-apply the sidebar background */
[data-theme="light"] .icon-sidenav {
    background-color: var(--theme-sidebar-bg) !important;
}

/* Icon sidebar hover state in light mode */
[data-theme="light"] .icon-sidenav .nav-link:hover {
    background-color: var(--theme-bg-hover) !important;
    color: var(--theme-text-primary) !important;
}

[data-theme="light"] .icon-sidenav .nav-link:hover .nav-icon,
[data-theme="light"] .icon-sidenav .nav-link:hover .nav-text {
    color: var(--theme-text-primary) !important;
}

/* Icon sidebar active state in light mode */
[data-theme="light"] .icon-sidenav .nav-link.active {
    background-color: #6900c7 !important;
    color: #ffffff !important;
}

[data-theme="light"] .icon-sidenav .nav-link.active .nav-icon,
[data-theme="light"] .icon-sidenav .nav-link.active .nav-text {
    color: #ffffff !important;
}

/* Icon sidebar divider in light mode */
[data-theme="light"] .icon-sidenav .divider {
    border-top: 1px solid rgba(0, 0, 0, 0.2) !important;
    background-color: rgba(0, 0, 0, 0.2) !important;
    height: 1px !important;
}

/* Sidebar Headings */
[data-theme="light"] .enhanced-sidebar .enhanced-heading {
    color: var(--theme-text-primary);
}
[data-theme="light"] .enhanced-sidebar .enhanced-heading i {
    color: #6900c7;
}

/* Sidebar Navigation Links */
[data-theme="light"] .enhanced-sidebar .enhanced-nav-link {
    color: var(--theme-text-secondary);
}
[data-theme="light"] .enhanced-sidebar .enhanced-nav-link .nav-link-icon {
    color: var(--theme-text-muted);
}

/* Sidebar Link Hover State */
[data-theme="light"] .enhanced-sidebar .enhanced-nav-link:hover {
    background: var(--theme-bg-hover);
    color: var(--theme-text-primary);
    border-color: transparent;
    transform: none;
}
[data-theme="light"] .enhanced-sidebar .enhanced-nav-link:hover .nav-link-icon {
    color: var(--theme-text-primary);
}

/* Sidebar Link Active State */
[data-theme="light"] .enhanced-sidebar .enhanced-nav-link.active {
    background: linear-gradient(135deg, #6900c7 0%, #5800e8 100%);
    color: #ffffff;
    border-color: #6900c7;
}
[data-theme="light"] .enhanced-sidebar .enhanced-nav-link.active .nav-link-icon,
[data-theme="light"] .enhanced-sidebar .enhanced-nav-link.active .nav-link-text {
    color: #ffffff;
}

/* Topnav */
[data-theme="light"] .topnav.navbar-dark .navbar-brand {
    color: var(--theme-text-primary) !important;
}
[data-theme="light"] .topnav .btn-transparent-light,
[data-theme="light"] .topnav .btn-transparent-light i,
[data-theme="light"] .topnav .btn-transparent-light svg {
    color: var(--theme-text-secondary) !important;
}
[data-theme="light"] .topnav .btn-transparent-light:hover {
    color: var(--theme-text-primary) !important;
    background-color: var(--theme-bg-hover) !important;
}
[data-theme="light"] .topnav .btn-transparent-light:hover i,
[data-theme="light"] .topnav .btn-transparent-light:hover svg {
    color: var(--theme-text-primary) !important;
}

/* Theme Toggle Icons */
[data-theme="dark"] [data-theme-icon="dark"],
[data-theme="light"] [data-theme-icon="light"] {
    display: none;
}

/* Toast Notifications */
[data-theme="light"] .toast {
    background-color: var(--theme-bg-card) !important;
    color: var(--theme-text-primary) !important;
}
[data-theme="light"] .toast-header {
    background-color: var(--theme-bg-secondary) !important;
    color: var(--theme-text-primary) !important;
}
[data-theme="light"] .toast-body {
    color: #1A1A1A !important; /* Force black text for better contrast */
}
[data-theme="light"] .toast .btn-close {
    filter: invert(1);
}


/* Apply theme variables to existing CSS variables for compatibility */
:root {
  --bg-primary: var(--theme-bg-primary);
  --bg-secondary: var(--theme-bg-secondary);
  --bg-tertiary: var(--theme-bg-tertiary);
  --bg-card: var(--theme-bg-card);
  --bg-hover: var(--theme-bg-hover);
  
  --text-primary: var(--theme-text-primary);
  --text-secondary: var(--theme-text-secondary);
  --text-muted: var(--theme-text-muted);
  --text-dim: var(--theme-text-dim);
  
  --border-default: var(--theme-border-default);
  --border-hover: var(--theme-border-hover);
  
  --shadow-sm: var(--theme-shadow-sm);
  --shadow-md: var(--theme-shadow-md);
  --shadow-lg: var(--theme-shadow-lg);
  --shadow-glow: var(--theme-shadow-glow);
}

/* --- General Overrides --- */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}
#layoutSidenav_content {
  background-color: var(--bg-primary) !important;
}
#layoutSidenav_nav {
  background-color: var(--bg-secondary) !important;
}
.card {
  background-color: var(--bg-card);
  border-color: var(--border-default);
  color: var(--text-primary);
}
.modal-content {
  background-color: var(--bg-modal);
  color: var(--text-primary);
}
.form-control {
  background-color: var(--theme-input-bg);
  border-color: var(--theme-input-border);
  color: var(--theme-text-primary);
}
.text-white {
  color: var(--text-primary) !important;
}
.text-muted {
  color: var(--text-muted) !important;
}
.bg-black {
  background-color: var(--bg-primary) !important;
}
.bg-dark {
  background-color: var(--bg-secondary) !important;
}
[data-theme="light"] nav.bg-black {
  background-color: var(--theme-navbar-bg) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}