/* ============================================================================
   GLOBAL CSS VARIABLES 
   ============================================================================
   This centralizes all colors and values for easy theme management.
   Change values here to apply changes globally across the entire application.
============================================================================ */

:root {
    /* Primary Brand Colors */
    --primary-color: #4caf50;
    --primary-dark: #047857;
    --primary-light: #4caf50;
    --primary-lighter: #34d399;
    
    /* Secondary Colors */
    --secondary-color: #4caf50;    
    --secondary-dark: #9ca3af;
    --secondary-light: #9ca3af;    
    
    /* Accent Colors */
    --accent-blue: #3b82f6;
    --accent-teal: #06b6d4;
    --accent-purple: #8b5cf6;
    --accent-orange: #f59e0b;
    --accent-yellow: #fbbf24;
    
    /* Gradient Combinations */
    --gradient-primary: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --gradient-primary-horizontal: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, var(--primary-color) 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-info: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --gradient-background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    
    /* Status Colors */
    --success-color: #10b981;
    --success-light: #d1fae5;
    --success-dark: #065f46;
    
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --danger-dark: #991b1b;
    
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --warning-dark: #b45309;
    
    --info-color: #3b82f6;
    --info-light: #e0f2fe;
    --info-dark: #0369a1;
    
    /* Neutral Colors - Light Mode */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f7fafc;
    --gray-200: #edf2f7;
    --gray-300: #e2e8f0;
    --gray-400: #cbd5e0;
    --gray-500: #a0aec0;
    --gray-600: #718096;
    --gray-700: #4a5568;
    --gray-800: #2d3748;
    --gray-900: #1a202c;
    
    /* Background and Text Colors - Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    
    /* Border & Divider Colors */
    --border-color: #e8ecef;
    --border-light: #f1f3f5;
    --divider-color: #e2e8f0;
    
    /* Shadow Values */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.15);
    --shadow-primary: 0 4px 15px rgba(5, 150, 105, 0.3);
    --shadow-primary-hover: 0 6px 20px rgba(5, 150, 105, 0.4);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;
    
    /* Spacing */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 30px;
    --spacing-2xl: 40px;
    
    /* Typography - Standard Enterprise Native System Font Stack */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-xs: 0.72rem;     /* ~10.5px */
    --font-size-sm: 0.8125rem;   /* 13px */
    --font-size-base: 0.875rem;  /* 14px */
    --font-size-lg: 0.95rem;     /* 15px */
    --font-size-xl: 1.1rem;      /* 17.5px */
    --font-size-2xl: 1.3rem;     /* 20.5px */
    --font-size-3xl: 1.5rem;     /* 24px */
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.4s ease;
    --transition-bounce: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Z-Index Layers */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}


/* ============================================================================
   DARK MODE VARIABLES
   ============================================================================ */

html.dark-mode {
    /* Dark Mode Backgrounds */
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-tertiary: #4a5568;
    
    /* Dark Mode Text Colors */
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --text-tertiary: #a0aec0;
    
    /* Dark Mode Borders */
    --border-color: #4a5568;
    --border-light: #2d3748;
    --divider-color: #4a5568;
    
    /* Inverted Grays for Dark Mode */
    --white: #1a202c;
    --gray-50: #2d3748;
    --gray-100: #2d3748;
    --gray-200: #4a5568;
    --gray-300: #718096;
    --gray-400: #a0aec0;
    --gray-500: #cbd5e0;
    --gray-600: #e2e8f0;
    --gray-700: #edf2f7;
    --gray-800: #f7fafc;
    --gray-900: #ffffff;
    
    /* Dark Mode Gradients */
    --gradient-background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    
    /* Enhanced Shadows for Dark Mode */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.7);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.8);
}

/* ============================================================================
   APPLY DARK MODE TO BODY AND COMMON ELEMENTS
   ============================================================================ */

html.dark-mode body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

html.dark-mode .main-content {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

html.dark-mode .topbar {
    background-color: var(--bg-secondary);
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .sidebar {
    background-color: var(--bg-secondary);
    border-right-color: var(--border-color);
}

html.dark-mode .settings-container,
html.dark-mode .settings-card {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .settings-header {
    background: var(--gradient-primary);
}

html.dark-mode .tab-btn {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

html.dark-mode .tab-btn.active {
    background-color: var(--primary-color);
    color: white;
}

html.dark-mode input,
html.dark-mode textarea,
html.dark-mode select {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode input:focus,
html.dark-mode textarea:focus,
html.dark-mode select:focus {
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
}

html.dark-mode .preference-item {
    border-color: var(--border-color);
    background-color: var(--bg-tertiary);
}

html.dark-mode .preference-info h4 {
    color: var(--text-primary);
}

html.dark-mode .preference-info p {
    color: var(--text-secondary);
}

html.dark-mode .password-requirements {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
}

html.dark-mode .password-requirements h4,
html.dark-mode .password-requirements li {
    color: var(--text-primary);
}

html.dark-mode .footer {
    background-color: var(--bg-secondary);
    border-top-color: var(--border-color);
    color: var(--text-secondary);
}

/* Cards and Containers */
html.dark-mode .card,
html.dark-mode .dashboard-card,
html.dark-mode .module-card {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Tables */
html.dark-mode table {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

html.dark-mode th {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

html.dark-mode td {
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode tr:hover {
    background-color: var(--bg-tertiary);
}

/* Modals */
html.dark-mode .modal-content {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

html.dark-mode .modal-header {
    border-bottom-color: var(--border-color);
}

html.dark-mode .modal-footer {
    border-top-color: var(--border-color);
}

/* Dropdowns */
html.dark-mode .dropdown-menu {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

html.dark-mode .dropdown-item {
    color: var(--text-primary);
}

html.dark-mode .dropdown-item:hover {
    background-color: var(--bg-tertiary);
}

/* Alerts */
html.dark-mode .alert {
    border-color: var(--border-color);
}

/* Badges */
html.dark-mode .badge {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================================================================
   SMOOTH TRANSITIONS FOR DARK MODE
   ============================================================================ */

* {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

/* Prevent transition on page load */
.no-transition * {
    transition: none !important;
}

/* ============================================================================
   SCROLLBAR STYLING FOR DARK MODE
   ============================================================================ */

html.dark-mode ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

html.dark-mode ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

html.dark-mode ::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 6px;
}

html.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ============================================================================
   SIDEBAR DARK MODE STYLING
   ============================================================================ */

html.dark-mode .sidebar {
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    border-right-color: var(--border-color);
}

html.dark-mode .sidebar-header {
    background-color: rgba(0, 0, 0, 0.2);
    border-bottom-color: var(--border-color);
}

html.dark-mode .sidebar-header h2 {
    color: var(--text-primary);
}

html.dark-mode .sidebar-menu .menu-item {
    color: var(--text-secondary);
}

html.dark-mode .sidebar-menu .menu-item:hover {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--primary-color);
}

html.dark-mode .sidebar-menu .menu-item.active {
    background-color: var(--primary-color);
    color: white;
}

html.dark-mode .sidebar-menu .menu-item i {
    color: var(--text-secondary);
}

html.dark-mode .sidebar-menu .menu-item:hover i,
html.dark-mode .sidebar-menu .menu-item.active i {
    color: white;
}

html.dark-mode .sidebar-footer {
    background-color: rgba(0, 0, 0, 0.2);
    border-top-color: var(--border-color);
    color: var(--text-secondary);
}

/* Navigation Menu Items */
html.dark-mode .nav-item,
html.dark-mode .menu-link {
    color: var(--text-secondary);
}

html.dark-mode .nav-item:hover,
html.dark-mode .menu-link:hover {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--primary-color);
}

html.dark-mode .nav-item.active,
html.dark-mode .menu-link.active {
    background-color: var(--primary-color);
    color: white;
}

/* ============================================================================
   DASHBOARD DARK MODE STYLING
   ============================================================================ */

html.dark-mode .dashboard-container {
    background-color: var(--bg-primary);
}

html.dark-mode .dashboard-header {
    background-color: var(--bg-secondary);
    border-bottom-color: var(--border-color);
}

html.dark-mode .stats-card {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .stats-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

html.dark-mode .stats-card h3 {
    color: var(--text-secondary);
}

html.dark-mode .stats-card .stats-number {
    color: var(--text-primary);
}

html.dark-mode .module-card {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

html.dark-mode .module-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

html.dark-mode .module-card h3 {
    color: var(--text-primary);
}

html.dark-mode .module-card p {
    color: var(--text-secondary);
}

/* ============================================================================
   TOPBAR / HEADER DARK MODE
   ============================================================================ */

html.dark-mode .topbar,
html.dark-mode .header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

html.dark-mode .topbar h1,
html.dark-mode .topbar-left h1 {
    color: var(--text-primary);
}

html.dark-mode .topbar p,
html.dark-mode .topbar-left p {
    color: var(--text-secondary);
}

html.dark-mode .user-info {
    background-color: transparent;
}

html.dark-mode .user-name {
    color: var(--text-primary);
}

html.dark-mode .user-role {
    color: var(--text-secondary);
}

html.dark-mode .user-avatar {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--border-color);
}

html.dark-mode .search-bar input {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .search-bar input::placeholder {
    color: var(--text-tertiary);
}

/* ============================================================================
   BUTTONS DARK MODE
   ============================================================================ */

html.dark-mode .btn {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

html.dark-mode .btn:hover {
    background-color: var(--bg-secondary);
}

html.dark-mode .btn-primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
}

html.dark-mode .btn-primary:hover {
    box-shadow: var(--shadow-primary-hover);
}

html.dark-mode .btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

html.dark-mode .btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .btn-outline:hover {
    background-color: var(--bg-tertiary);
}

/* ============================================================================
   FORMS DARK MODE
   ============================================================================ */

html.dark-mode .form-group label {
    color: var(--text-primary);
}

html.dark-mode .form-control,
html.dark-mode .input-field {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .form-control::placeholder,
html.dark-mode .input-field::placeholder {
    color: var(--text-tertiary);
}

html.dark-mode .form-control:focus,
html.dark-mode .input-field:focus {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

html.dark-mode .form-control:disabled,
html.dark-mode .input-field:disabled {
    background-color: var(--bg-secondary);
    color: var(--text-tertiary);
}

html.dark-mode .input-group {
    background-color: var(--bg-tertiary);
}

html.dark-mode .input-icon-left,
html.dark-mode .input-icon-right {
    color: var(--text-tertiary);
}

/* ============================================================================
   TABLES DARK MODE
   ============================================================================ */

html.dark-mode table {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

html.dark-mode thead {
    background-color: var(--bg-tertiary);
}

html.dark-mode th {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

html.dark-mode td {
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode tbody tr {
    background-color: var(--bg-secondary);
}

html.dark-mode tbody tr:hover {
    background-color: var(--bg-tertiary);
}

html.dark-mode tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* ============================================================================
   PAGINATION DARK MODE
   ============================================================================ */

html.dark-mode .pagination {
    background-color: var(--bg-secondary);
}

html.dark-mode .pagination button {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

html.dark-mode .pagination button:hover {
    background-color: var(--primary-color);
    color: white;
}

html.dark-mode .pagination button.active {
    background-color: var(--primary-color);
    color: white;
}

/* ============================================================================
   BREADCRUMB DARK MODE
   ============================================================================ */

html.dark-mode .breadcrumb {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
}

html.dark-mode .breadcrumb a {
    color: var(--primary-color);
}

html.dark-mode .breadcrumb a:hover {
    color: var(--primary-light);
}

/* ============================================================================
   TOOLTIPS AND POPOVERS DARK MODE
   ============================================================================ */

html.dark-mode .tooltip {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

html.dark-mode .popover {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

html.dark-mode .popover-header {
    background-color: var(--bg-tertiary);
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .popover-body {
    color: var(--text-primary);
}

/* ============================================================================
   PROGRESS BARS DARK MODE
   ============================================================================ */

html.dark-mode .progress {
    background-color: var(--bg-tertiary);
}

html.dark-mode .progress-bar {
    background-color: var(--primary-color);
}

/* ============================================================================
   LOADING STATES DARK MODE
   ============================================================================ */

html.dark-mode .spinner,
html.dark-mode .loader {
    border-color: var(--border-color);
    border-top-color: var(--primary-color);
}

html.dark-mode .skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
}

/* ============================================================================
   CHARTS AND GRAPHS DARK MODE
   ============================================================================ */

html.dark-mode .chart-container {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

html.dark-mode .chart-legend {
    color: var(--text-primary);
}

/* ============================================================================
   LIST GROUPS DARK MODE
   ============================================================================ */

html.dark-mode .list-group {
    background-color: var(--bg-secondary);
}

html.dark-mode .list-group-item {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .list-group-item:hover {
    background-color: var(--bg-tertiary);
}

html.dark-mode .list-group-item.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ============================================================================
   ACCORDIONS DARK MODE
   ============================================================================ */

html.dark-mode .accordion {
    background-color: var(--bg-secondary);
}

html.dark-mode .accordion-header {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

html.dark-mode .accordion-body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* ============================================================================
   NOTIFICATIONS / TOASTS DARK MODE
   ============================================================================ */

html.dark-mode .notification,
html.dark-mode .toast {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
}

html.dark-mode .notification.success,
html.dark-mode .toast.success {
    border-left-color: var(--success-color);
}

html.dark-mode .notification.error,
html.dark-mode .toast.error {
    border-left-color: var(--danger-color);
}

html.dark-mode .notification.warning,
html.dark-mode .toast.warning {
    border-left-color: var(--warning-color);
}

html.dark-mode .notification.info,
html.dark-mode .toast.info {
    border-left-color: var(--info-color);
}

/* ============================================================================
   FILE UPLOAD DARK MODE
   ============================================================================ */

html.dark-mode .file-upload {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark-mode .file-upload:hover {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
}

html.dark-mode .file-list {
    background-color: var(--bg-secondary);
}

html.dark-mode .file-item {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* ============================================================================
   EMPTY STATES DARK MODE
   ============================================================================ */

html.dark-mode .empty-state {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
}

html.dark-mode .empty-state h3 {
    color: var(--text-primary);
}

/* ============================================================================
   TEXT COLORS DARK MODE
   ============================================================================ */

html.dark-mode h1,
html.dark-mode h2,
html.dark-mode h3,
html.dark-mode h4,
html.dark-mode h5,
html.dark-mode h6 {
    color: var(--text-primary);
}

html.dark-mode p {
    color: var(--text-secondary);
}

html.dark-mode small,
html.dark-mode .text-muted {
    color: var(--text-tertiary);
}

html.dark-mode a {
    color: var(--primary-color);
}

html.dark-mode a:hover {
    color: var(--primary-light);
}

/* ============================================================================
   HR / DIVIDERS DARK MODE
   ============================================================================ */

html.dark-mode hr {
    border-color: var(--border-color);
}

/* ============================================================================
   CODE BLOCKS DARK MODE
   ============================================================================ */

html.dark-mode code {
    background-color: var(--bg-tertiary);
    color: var(--primary-light);
}

html.dark-mode pre {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* ============================================================================
   SPECIFIC PAGE ELEMENTS
   ============================================================================ */

/* Welcome Section */
html.dark-mode .welcome-section {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

/* Quick Actions */
html.dark-mode .quick-actions {
    background-color: var(--bg-secondary);
}

html.dark-mode .action-btn {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

html.dark-mode .action-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Recent Activity */
html.dark-mode .activity-item {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

html.dark-mode .activity-item:hover {
    background-color: var(--bg-tertiary);
}


/* ============================================================================
   MOBILE RESPONSIVE FRAMEWORK - Add to bottom of global_theme.css
   ============================================================================
   This section makes the entire portal mobile-responsive
============================================================================ */

/* Base Mobile Optimizations */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================================================
   COMPLETE MOBILE SIDEBAR FIX
   Add this to the BOTTOM of your global_theme.css file
   This will override all existing sidebar styles on mobile
============================================================================ */

/* ============================================================================
   MOBILE RESPONSIVE FIXES - CRITICAL
============================================================================ */

/* Mobile Menu Toggle Button - Always on top */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 2000;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 15px;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1400;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Prevent body scroll when menu is open */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ============================================================================
   TABLET DEVICES (max-width: 1024px)
============================================================================ */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
    }
    
    .stats-grid,
    .modules-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 15px;
    }
}

/* ============================================================================
   MOBILE DEVICES (max-width: 768px) - CRITICAL OVERRIDES
============================================================================ */
@media (max-width: 768px) {
    /* Show hamburger menu */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    /* CRITICAL: Force sidebar off-screen by default */
    .dashboard-container {
        display: block !important;
    }
    
    .sidebar {
        position: fixed !important;
        left: -100% !important;
        top: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 1500 !important;
        transition: left 0.3s ease-in-out !important;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Show sidebar when mobile-open class is added */
    .sidebar.mobile-open {
        left: 0 !important;
    }
    
    /* Main content takes full width */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    /* Adjust topbar for hamburger button space */
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 60px 15px 15px 15px !important;
    }
    
    .topbar-left,
    .topbar-right {
        width: 100%;
    }
    
    .topbar-left h1 {
        font-size: 1.5rem;
    }
    
    .user-info {
        width: 100%;
        justify-content: space-between;
    }
    
    /* Single column layouts */
    .stats-grid,
    .modules-grid,
    .quick-actions-grid,
    .profile-content {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    /* Reduce padding everywhere */
    .dashboard-grid,
    .settings-container,
    .profile-container {
        padding: 15px;
    }
    
    .content-section,
    .form-card,
    .settings-card,
    .profile-card {
        padding: 20px 15px;
    }
    
    /* Welcome banner adjustments */
    .welcome-banner {
        padding: 25px 20px;
        margin-bottom: 20px;
    }
    
    .greeting {
        font-size: 1.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .welcome-subtitle {
        font-size: 0.9rem;
    }
    
    .quick-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Module cards */
    .module-card {
        padding: 20px;
    }
    
    .module-icon {
        font-size: 2rem;
    }
    
    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Buttons */
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-danger,
    .btn-update {
        width: 100%;
        justify-content: center;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-action {
        width: 100%;
        justify-content: center;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 700px;
        font-size: 0.85rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }
    
    /* Pagination */
    .pagination-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    /* Login page */
    .login-container {
        flex-direction: column;
        max-width: 500px;
    }
    
    .left-panel {
        padding: 30px 25px;
        min-height: 250px;
    }
    
    .left-panel h1 {
        font-size: 2rem;
    }
    
    .right-panel {
        width: 100%;
        padding: 30px 25px;
    }
}

/* ============================================================================
   SMALL MOBILE (max-width: 480px)
============================================================================ */
@media (max-width: 480px) {
    .mobile-menu-toggle {
        top: 12px;
        left: 12px;
        padding: 10px 13px;
        font-size: 1.2rem;
    }
    
    .topbar {
        padding: 55px 12px 12px 12px !important;
    }
    
    .sidebar {
        width: 260px !important;
    }
    
    .greeting {
        font-size: 1.3rem;
    }
    
    .topbar-left h1 {
        font-size: 1.3rem;
    }
}

/* ============================================================================
   ENSURE SIDEBAR IS VISIBLE ON DESKTOP
============================================================================ */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .sidebar {
        position: fixed !important;
        left: 0 !important;
        display: flex !important;
    }
    
    .main-content {
        margin-left: 260px !important;
    }
    
    body.menu-open {
        overflow: auto;
        position: static;
    }
}

/* ============================================================================
   LANDSCAPE ORIENTATION FIXES
============================================================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
    }
    
    .welcome-banner {
        padding: 20px;
    }
    
    .profile-header,
    .settings-header {
        padding: 25px;
    }
    
    .login-container {
        flex-direction: row;
        max-width: 900px;
    }
    
    .left-panel,
    .right-panel {
        padding: 20px;
    }
}

/* ============================================================================
   TOUCH DEVICE OPTIMIZATIONS
============================================================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .nav-item,
    .tab-btn,
    .module-card,
    .btn-action,
    button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .module-card:hover,
    .stat-card:hover,
    .nav-item:hover {
        transform: none;
    }
    
    /* Add active states for touch feedback */
    .btn:active,
    .module-card:active,
    .nav-item:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* ============================================================================
   PRINT STYLES
============================================================================ */
@media print {
    .sidebar,
    .topbar,
    .btn-logout,
    .mobile-menu-toggle,
    .favorite-btn,
    .action-buttons,
    .pagination-controls {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .content-section,
    .profile-card,
    .settings-card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* ============================================================================
   ACCESSIBILITY IMPROVEMENTS FOR MOBILE
============================================================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn,
    .module-card,
    .stat-card {
        border: 2px solid currentColor;
    }
}

/* ============================================================================
   GLOBAL LAYOUT FIT — prevents pages from requiring browser zoom-out
   Applied via element selectors only; no extra classes needed.
   Loaded by every page through global_theme.css.
============================================================================ */

/* 1. Root containment — stop horizontal scroll on every page */
html {
    overflow-x: hidden;
    width: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    min-width: 0;
}

/* 2. Dashboard shell — ensure the flex container never exceeds the viewport */
.dashboard-container {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* 3. Main content area — fluid width, clamps internal padding so nothing bleeds */
.main-content {
    min-width: 0;        /* critical: lets flex children shrink below their content size */
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

/* 4. Topbar — scale down its padding on smaller viewports so it never forces a scroll */
.topbar {
    padding: clamp(12px, 2vw, 25px) clamp(16px, 3vw, 40px);
    flex-wrap: wrap;
    gap: 10px;
    box-sizing: border-box;
    width: 100%;
}

/* 5. All direct section/card containers inside main-content inherit fluid width */
.main-content > *,
.content-section,
.roster-section,
.form-card,
.page-header,
.year-selector,
.dashboard-grid,
.settings-container,
.profile-container {
    box-sizing: border-box;
    max-width: 100%;
}

/* 6. Tables — always wrapped so wide tables scroll rather than push the layout */
table {
    width: 100%;
}

.table-responsive,
.roster-section table,
.content-section table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    width: 100%;
}

/* 7. Modals — keep them inside the viewport on any screen size */
.modal-content {
    box-sizing: border-box;
    max-width: min(620px, 95vw);
    width: 95%;
    padding: clamp(16px, 3vw, 30px);
}

/* 8. Stats / module grids — prevent overflow by shrinking minmax floor on narrow screens */
.stats-grid,
.modules-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
}

/* 9. Form rows — collapse to single column before content clips */
.form-row {
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}

/* 10. Images and media — never exceed their container */
img,
video,
iframe,
embed,
object {
    max-width: 100%;
    height: auto;
}

/* 11. Page header / banner inside main — fluid padding */
.page-header {
    padding: clamp(16px, 2.5vw, 30px);
    box-sizing: border-box;
}

/* 12. Year selector & info boxes */
.year-selector,
.info-box {
    box-sizing: border-box;
    flex-wrap: wrap;
    gap: 10px;
}

/* 13. Roster details grid — collapse gracefully */
.roster-details {
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
}

/* 14. Approval / data tables — ensure min-width only applies when there is room */
.approval-table,
.data-table {
    min-width: 600px; /* keeps columns readable; parent .table-responsive scrolls */
}

/* 15. Sidebar — fixed width sidebar should not contribute to body overflow */
.sidebar {
    box-sizing: border-box;
}

/* ── Medium screens (tablets / small laptops ≤ 1100px) ── */
@media (max-width: 1100px) {
    .main-content {
        margin-left: 220px !important; /* match narrower sidebar */
    }

    .sidebar {
        width: 220px !important;
    }

    .topbar-left h1 {
        font-size: clamp(18px, 2.5vw, 26px);
    }

    .stats-grid {
        padding: 20px;
    }
}

/* ── Small desktop / large tablet (≤ 900px) ── */
@media (max-width: 900px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-right {
        width: 100%;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }
}

/* ── Scrollbar styling (light mode) — matches dark-mode equivalent above ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ============================================================================
   GLOBAL COMPACT TYPOGRAPHY & COMPONENT DENSITY OVERRIDES
   ============================================================================ */
html {
    font-size: 14px !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family) !important;
    font-size: 0.925rem;
    line-height: 1.45;
    color: var(--text-primary);
}

h1, .h1 { font-size: 1.35rem !important; font-weight: 600 !important; letter-spacing: -0.01em; }
h2, .h2 { font-size: 1.15rem !important; font-weight: 600 !important; }
h3, .h3 { font-size: 1.05rem !important; font-weight: 600 !important; }
h4, .h4 { font-size: 0.95rem !important; font-weight: 600 !important; }
h5, .h5 { font-size: 0.875rem !important; font-weight: 600 !important; }
h6, .h6 { font-size: 0.8125rem !important; font-weight: 600 !important; }

/* Stat Cards & Dashboard Metrics Compact Scale */
.stat-card, .dashboard-card, .metric-card {
    padding: 14px 18px !important;
    border-radius: 10px !important;
}

.stat-icon, .metric-icon, .action-icon {
    font-size: 22px !important;
    width: auto !important;
    height: auto !important;
}

.stat-details h3, .stat-number, .stat-value {
    font-size: 1.4rem !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    margin-bottom: 2px !important;
}

.stat-details p, .stat-label {
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    color: var(--gray-600) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

/* Tables Global Compact Density */
table.data-table, table.table {
    font-size: 13px !important;
}

table.data-table th, table.table th {
    padding: 9px 12px !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

table.data-table td, table.table td {
    padding: 9px 12px !important;
    font-size: 13px !important;
}

/* Buttons Global Compact */
.btn, .btn-action, .btn-primary, .btn-secondary, .btn-success, .btn-danger {
    font-size: 13px !important;
    padding: 7px 14px !important;
    border-radius: 6px !important;
}

/* Form Controls Global Compact */
input.form-control, select.form-control, textarea.form-control,
input[type="text"], input[type="number"], input[type="email"], select {
    font-size: 13px !important;
    padding: 7px 11px !important;
    border-radius: 6px !important;
}

/* ============================================================================
   RESPONSIVE LAYOUT & MOBILE DRAWER SYSTEM
   ============================================================================ */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 14px;
    z-index: 1050;
    width: 40px;
    height: 40px;
    background: #059669;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1.15rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: #047857;
    transform: scale(1.05);
}

/* Sidebar Backdrop Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1010;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive Breakpoint: Tablets & Small Laptops (<= 1024px) */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: flex !important;
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        bottom: 0 !important;
        width: 270px !important;
        max-width: 85vw !important;
        z-index: 1020 !important;
        transition: left 0.3s ease-in-out !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25) !important;
    }

    .sidebar.mobile-open {
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-top: 64px !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .topbar {
        left: 0 !important;
        width: 100% !important;
        padding-left: 64px !important;
        padding-right: 16px !important;
    }
}

/* Responsive Breakpoint: Mobile Phones (<= 640px) */
@media (max-width: 640px) {
    .topbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 10px 14px 10px 60px !important;
        height: auto !important;
    }

    .topbar-left {
        width: 100% !important;
    }

    .topbar-left h1 {
        font-size: 1.1rem !important;
    }

    .topbar-right {
        width: 100% !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .user-info {
        font-size: 0.8rem !important;
        padding: 4px 8px !important;
    }

    /* Cards & Container Spacing */
    .dashboard-container,
    .mgmt-card,
    .settings-card,
    .profile-card,
    .card {
        padding: 14px 12px !important;
        border-radius: 8px !important;
    }

    /* Responsive Grids */
    .stats-grid,
    .metrics-grid,
    .form-grid,
    .form-row,
    .grid-2-col,
    .grid-3-col,
    .grid-4-col {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Responsive Tables */
    .table-responsive,
    .table-responsive-wrapper,
    .table-card {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    table.data-table,
    table.table,
    table.mgmt-table {
        min-width: 580px !important;
    }

    /* Modals Responsive */
    .modal-content {
        width: 94vw !important;
        max-width: 94vw !important;
        padding: 16px !important;
        margin: 10px auto !important;
    }
}