/**
 * Shared CSS Variables - Xtender Design System
 * Version: 3.0.0 — Xtender Brand Identity
 * Brand: #0C5E94 (blue), #F69047 (orange), #254048 (dark)
 * Font: Plus Jakarta Sans
 */

:root {
    /* Brand Blue — Primary (logo left chevron #0C5E94) */
    --x-primary: #0C5E94;
    --x-primary-dark: #0A4E7C;
    --x-primary-light: #1D7DC0;
    --x-primary-hover: #0A4E7C;
    --x-primary-rgb: 12, 94, 148;
    --x-secondary: #F69047;
    --x-secondary-dark: #C0641E;

    /* Blue Ramp */
    --x-blue-50: #E8F3FB; --x-blue-100: #C3DCF3; --x-blue-200: #8BBDE7;
    --x-blue-300: #4D9DD8; --x-blue-400: #1D7DC0; --x-blue-500: #0C5E94;
    --x-blue-600: #0A4E7C; --x-blue-700: #083E62; --x-blue-800: #052D47;

    /* Orange Ramp */
    --x-orange-50: #FEF5EC; --x-orange-100: #FDE3C6; --x-orange-200: #FBCA9B;
    --x-orange-300: #F9B070; --x-orange-400: #F69047; --x-orange-500: #E07A30;
    --x-orange-600: #C0641E; --x-orange-700: #9A4E10;

    /* Dark Ramp (wordmark #254048) */
    --x-dark-50: #EBF0F1; --x-dark-100: #C7D5D8; --x-dark-200: #9FB8BC;
    --x-dark-300: #6E8E94; --x-dark-400: #476772; --x-dark-500: #254048;
    --x-dark-600: #1D333B; --x-dark-700: #16272E; --x-dark-800: #0E1B21;

    /* Status Colors — brand-tinted */
    --x-success: #1A5C34;
    --x-success-dark: #144A28;
    --x-success-bg: #E9F7EF;
    --x-success-border: #7DD3A8;
    --x-warning: #7A4210;
    --x-warning-dark: #63360D;
    --x-warning-bg: #FEF5EC;
    --x-warning-border: #F9B070;
    --x-danger: #8B1F1F;
    --x-danger-dark: #711919;
    --x-danger-bg: #FDF2F2;
    --x-danger-border: #F5A8A8;
    --x-info: #0A4E7C;
    --x-info-dark: #083E62;
    --x-info-bg: #E8F3FB;
    --x-info-border: #8BBDE7;

    /* Accent Colours — professional palette (no purple/pink/indigo/teal) */
    --x-accent-blue: var(--x-header-primary, #0C5E94);
    --x-accent-blue-dark: var(--x-header-primary-dark, #0A4E7C);
    --x-accent-purple: #0A4E7C;
    --x-accent-amber: #d97706;
    --x-accent-green: #059669;
    --x-accent-pink: #F69047;
    --x-accent-indigo: #254048;
    --x-accent-teal: #1D7DC0;
    --x-accent-orange: #F69047;
    --x-accent-red: #dc2626;

    /* Text Colors — uses brand dark */
    --x-text-primary: #254048;
    --x-text-secondary: #476772;
    --x-text-tertiary: #6E8E94;
    --x-text-muted: #8794A3;
    --x-text-light: #B0B8C4;

    /* Grey Scale — brand-neutral */
    --x-gray-50: #F7F8F9;
    --x-gray-100: #EAECEF;
    --x-gray-200: #D2D6DC;
    --x-gray-300: #B0B8C4;
    --x-gray-400: #8794A3;
    --x-gray-500: #5F6E7D;
    --x-gray-600: #445160;
    --x-gray-700: #313D4A;
    --x-gray-800: #1E2835;
    --x-gray-900: #0D1219;

    /* Background / Surfaces */
    --x-bg-primary: #FFFFFF;
    --x-bg-secondary: #F4F6F8;
    --x-bg-tertiary: #F0F2F5;
    --x-bg-hover: rgba(37, 64, 72, 0.04);
    --x-bg-active: rgba(37, 64, 72, 0.08);

    /* Border Colors */
    --x-border: rgba(37, 64, 72, 0.13);
    --x-border-light: rgba(37, 64, 72, 0.07);
    --x-border-dark: rgba(37, 64, 72, 0.24);

    /* Spacing */
    --x-spacing-xs: 0.25rem;   /* 4px */
    --x-spacing-sm: 0.5rem;    /* 8px */
    --x-spacing-md: 1rem;      /* 16px */
    --x-spacing-lg: 1.5rem;    /* 24px */
    --x-spacing-xl: 2rem;      /* 32px */
    --x-spacing-2xl: 3rem;     /* 48px */

    /* Typography */
    --x-font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --x-font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --x-font-size-xs: 0.6875rem;  /* 11px */
    --x-font-size-sm: 0.8125rem;  /* 13px */
    --x-font-size-base: 0.9375rem; /* 15px */
    --x-font-size-lg: 1.125rem;   /* 18px */
    --x-font-size-xl: 1.25rem;    /* 20px */
    --x-font-size-2xl: 1.5rem;    /* 24px */

    /* Border Radius */
    --x-radius-sm: 4px;
    --x-radius: 8px;
    --x-radius-lg: 12px;
    --x-radius-xl: 16px;
    --x-radius-full: 9999px;

    /* Shadows — brand-tinted */
    --x-shadow-sm: 0 1px 4px rgba(37, 64, 72, 0.07);
    --x-shadow: 0 1px 4px rgba(37, 64, 72, 0.07), 0 1px 2px rgba(37, 64, 72, 0.04);
    --x-shadow-md: 0 4px 8px rgba(37, 64, 72, 0.08), 0 2px 4px rgba(37, 64, 72, 0.04);
    --x-shadow-lg: 0 8px 16px rgba(37, 64, 72, 0.09), 0 4px 8px rgba(37, 64, 72, 0.04);
    --x-shadow-xl: 0 16px 32px rgba(37, 64, 72, 0.10), 0 8px 12px rgba(37, 64, 72, 0.05);

    /* Layout */
    --x-sidebar-width: 56px;
    --x-sidebar-expanded-width: 280px;
    --x-topbar-height: 60px;

    /* Transitions */
    --x-transition-fast: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    --x-transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --x-transition-slow: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);

    /* Z-Index Scale */
    --x-z-dropdown: 100;
    --x-z-sticky: 200;
    --x-z-fixed: 250;
    --x-z-modal-backdrop: 300;
    --x-z-modal: 300;
    --x-z-popover: 400;
    --x-z-tooltip: 500;
}

/* Common Sidebar Styles */
.x-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--x-sidebar-width);
    height: 100vh;
    background: var(--x-bg-primary);
    border-right: 1px solid var(--x-border);
    display: flex;
    flex-direction: column;
    z-index: 950;
    overflow: visible;
}

.x-sidebar-nav {
    flex: 1;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
}

.x-sidebar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border-radius: var(--x-radius);
    background: transparent;
    color: var(--x-gray-600);
    text-decoration: none;
    transition: var(--x-transition-fast);
    position: relative;
}

.x-sidebar-link:hover {
    background: var(--x-gray-100);
    color: var(--x-text-primary);
}

.x-sidebar-link.active {
    background: var(--x-primary);
    color: white;
}

.x-sidebar-link svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.x-sidebar-link span {
    display: none;
}

.x-sidebar-footer {
    padding: 16px 8px;
    border-top: 1px solid var(--x-border);
}

.x-sidebar-footer .x-sidebar-link {
    color: var(--x-danger);
}

.x-sidebar-footer .x-sidebar-link:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Common Card Styles */
.x-card {
    background: var(--x-bg-primary);
    border: 1px solid var(--x-border);
    border-radius: var(--x-radius-lg);
    box-shadow: var(--x-shadow-sm);
    margin-bottom: var(--x-spacing-lg);
    transition: var(--x-transition);
}

.x-card:hover {
    box-shadow: var(--x-shadow);
}

.x-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--x-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.x-card-header h2,
.x-card-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.x-card-body {
    padding: 1.5rem;
}

/* Common Button Styles */
.x-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: var(--x-font-size-sm);
    font-weight: 500;
    border-radius: var(--x-radius);
    border: none;
    cursor: pointer;
    transition: var(--x-transition-fast);
    text-decoration: none;
}

.x-btn-primary {
    background: var(--x-primary);
    color: white;
}

.x-btn-primary:hover {
    background: var(--x-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--x-shadow);
}

.x-btn-secondary {
    background: transparent;
    border: 1px solid var(--x-border);
    color: var(--x-text-primary);
}

.x-btn-secondary:hover {
    background: var(--x-bg-hover);
}

.x-btn-success {
    background: var(--x-success);
    color: white;
}

.x-btn-success:hover {
    background: var(--x-success-dark);
}

.x-btn-danger {
    background: var(--x-danger);
    color: white;
}

.x-btn-danger:hover {
    background: var(--x-danger-dark);
}

.x-btn-sm {
    padding: 6px 12px;
    font-size: var(--x-font-size-xs);
}

.x-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Common Badge Styles */
.x-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: var(--x-font-size-xs);
    font-weight: 600;
    border-radius: 12px;
}

.x-badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--x-success);
}

.x-badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--x-warning);
}

.x-badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--x-danger);
}

.x-badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--x-info);
}

/* Common Form Styles */
.x-form-group {
    margin-bottom: var(--x-spacing-lg);
}

.x-form-label {
    display: block;
    margin-bottom: var(--x-spacing-sm);
    font-size: var(--x-font-size-sm);
    font-weight: 500;
    color: var(--x-text-primary);
}

.x-form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: var(--x-font-size-sm);
    border: 1px solid var(--x-border);
    border-radius: var(--x-radius);
    transition: var(--x-transition-fast);
}

.x-form-control:focus {
    outline: none;
    border-color: var(--x-primary);
    box-shadow: 0 0 0 3px rgba(12, 94, 148, 0.1);
}

.x-form-control::placeholder {
    color: var(--x-text-muted);
}

/* Select */
.x-select {
    width: 100%;
    padding: 10px 14px;
    font-size: var(--x-font-size-sm);
    border: 1px solid var(--x-border);
    border-radius: var(--x-radius);
    transition: var(--x-transition-fast);
    background: var(--x-bg-primary);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.x-select:focus {
    outline: none;
    border-color: var(--x-primary);
    box-shadow: 0 0 0 3px rgba(12, 94, 148, 0.1);
}

/* Textarea */
.x-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: var(--x-font-size-sm);
    border: 1px solid var(--x-border);
    border-radius: var(--x-radius);
    transition: var(--x-transition-fast);
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.x-textarea:focus {
    outline: none;
    border-color: var(--x-primary);
    box-shadow: 0 0 0 3px rgba(12, 94, 148, 0.1);
}

/* Input Group — icon or addon beside input */
.x-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.x-input-group .x-form-control {
    padding-left: 40px;
}

.x-input-group .x-input-icon {
    position: absolute;
    left: 14px;
    color: var(--x-text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.x-input-group .x-input-icon svg {
    width: 16px;
    height: 16px;
}

/* Form Hint / Helper Text */
.x-form-hint {
    margin-top: 4px;
    font-size: var(--x-font-size-xs);
    color: var(--x-text-muted);
}

/* Form Error State */
.x-form-control.x-error,
.x-select.x-error,
.x-textarea.x-error {
    border-color: var(--x-danger);
}

.x-form-control.x-error:focus,
.x-select.x-error:focus,
.x-textarea.x-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.x-form-error {
    margin-top: 4px;
    font-size: var(--x-font-size-xs);
    color: var(--x-danger);
}

/* Disabled State */
.x-form-control:disabled,
.x-select:disabled,
.x-textarea:disabled {
    background: var(--x-bg-tertiary);
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   SHARED MODAL STYLES
   ============================================ */

/* Modal Overlay */
.x-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--x-z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.x-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.x-modal {
    position: fixed;
    inset: 0;
    z-index: var(--x-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--x-spacing-xl);
    pointer-events: none;
}

.x-modal.active {
    pointer-events: auto;
}

/* Modal Content Box */
.x-modal-content {
    background: var(--x-bg-primary);
    border-radius: var(--x-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: x-modal-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Size Variants */
.x-modal-sm .x-modal-content { max-width: 400px; }
.x-modal-lg .x-modal-content { max-width: 900px; }
.x-modal-xl .x-modal-content { max-width: 1200px; }

/* Modal Header */
.x-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--x-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.x-modal-header h2,
.x-modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--x-text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Modal Close Button */
.x-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--x-radius-sm);
    border: none;
    background: transparent;
    color: var(--x-text-tertiary);
    cursor: pointer;
    transition: var(--x-transition-fast);
    flex-shrink: 0;
}

.x-modal-close:hover {
    background: var(--x-bg-hover);
    color: var(--x-text-primary);
}

.x-modal-close svg {
    width: 18px;
    height: 18px;
}

/* Modal Body */
.x-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Modal Footer */
.x-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--x-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Modal Animation */
@keyframes x-modal-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive Modal */
@media (max-width: 640px) {
    .x-modal {
        padding: var(--x-spacing-md);
    }
    .x-modal-content {
        max-height: 95vh;
    }
    .x-modal-header,
    .x-modal-body,
    .x-modal-footer {
        padding: 1rem;
    }
}

/* ============================================
   DARK MODE - Global Theme Overrides
   ============================================ */
body[data-theme="dark"] {
    background: #111827 !important;
    color: #f9fafb !important;
}

[data-theme="dark"] {
    /* Text Colors */
    --x-text-primary: #f9fafb;
    --x-text-secondary: #d1d5db;
    --x-text-tertiary: #9ca3af;
    --x-text-muted: #6b7280;
    --x-text-light: #374151;

    /* Gray Scale - Inverted */
    --x-gray-50: #1f2937;
    --x-gray-100: #374151;
    --x-gray-200: #4b5563;
    --x-gray-300: #6b7280;
    --x-gray-400: #9ca3af;
    --x-gray-500: #d1d5db;
    --x-gray-600: #e5e7eb;
    --x-gray-700: #f3f4f6;
    --x-gray-800: #f9fafb;
    --x-gray-900: #ffffff;

    /* Background Colors */
    --x-bg-primary: #1f2937;
    --x-bg-secondary: #111827;
    --x-bg-tertiary: #1a2332;
    --x-bg-hover: rgba(255, 255, 255, 0.06);
    --x-bg-active: rgba(255, 255, 255, 0.1);

    /* Border Colors */
    --x-border: #374151;
    --x-border-light: #1f2937;
    --x-border-dark: #4b5563;

    /* Shadows - Darker */
    --x-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --x-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --x-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --x-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --x-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

/* Dark mode - shared modals */
body[data-theme="dark"] .x-modal-content {
    background-color: #1f2937;
    border-color: #374151;
}

body[data-theme="dark"] .x-modal-header {
    border-bottom-color: #374151;
}

body[data-theme="dark"] .x-modal-header h2,
body[data-theme="dark"] .x-modal-header h3 {
    color: #f9fafb;
}

body[data-theme="dark"] .x-modal-body {
    color: #f9fafb;
}

body[data-theme="dark"] .x-modal-footer {
    border-top-color: #374151;
}

body[data-theme="dark"] .x-modal-close {
    color: #9ca3af;
}

body[data-theme="dark"] .x-modal-close:hover {
    background: #374151;
    color: #f9fafb;
}

/* Dark mode - shared form elements */
body[data-theme="dark"] .x-select {
    background-color: #1f2937;
    color: #f9fafb;
    border-color: #374151;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

body[data-theme="dark"] .x-textarea {
    background-color: #1f2937;
    color: #f9fafb;
    border-color: #374151;
}

body[data-theme="dark"] .x-form-hint {
    color: #6b7280;
}

/* Dark mode form controls */
body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] input:focus,
body[data-theme="dark"] select:focus,
body[data-theme="dark"] textarea:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder {
    color: #6b7280 !important;
}

/* Dark mode tables */
body[data-theme="dark"] table {
    color: #f9fafb;
}

body[data-theme="dark"] table thead th {
    background-color: #1a2332 !important;
    color: #d1d5db !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] table tbody td {
    border-color: #374151 !important;
}

body[data-theme="dark"] table tbody tr {
    background-color: #1f2937;
}

body[data-theme="dark"] table tbody tr:nth-child(even) {
    background-color: #1a2332;
}

body[data-theme="dark"] table tbody tr:hover {
    background-color: #253344 !important;
}

/* Dark mode modals */
body[data-theme="dark"] .modal-content,
body[data-theme="dark"] .modal-container,
body[data-theme="dark"] .swal2-popup {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] .modal-header {
    background-color: #1f2937 !important;
    border-bottom-color: #374151 !important;
    color: #f9fafb !important;
}

body[data-theme="dark"] .modal-header h2,
body[data-theme="dark"] .modal-header h3 {
    color: #f9fafb !important;
}

body[data-theme="dark"] .modal-body {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
}

body[data-theme="dark"] .modal-footer {
    background-color: #1f2937 !important;
    border-top-color: #374151 !important;
    color: #f9fafb !important;
}

body[data-theme="dark"] .modal-close {
    color: #d1d5db !important;
}

body[data-theme="dark"] .modal-close:hover {
    background-color: #374151 !important;
    color: #f9fafb !important;
}

body[data-theme="dark"] .modal-backdrop {
    background-color: rgba(0, 0, 0, 0.7) !important;
}

body[data-theme="dark"] .swal2-title {
    color: #f9fafb !important;
}

body[data-theme="dark"] .swal2-html-container {
    color: #d1d5db !important;
}

/* Dark mode dropdowns */
body[data-theme="dark"] .dropdown-menu {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] .dropdown-item {
    color: #d1d5db !important;
}

body[data-theme="dark"] .dropdown-item:hover {
    background-color: #374151 !important;
    color: #f9fafb !important;
}

/* Dark mode scrollbar */
body[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #1f2937;
}

body[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 4px;
}

body[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Dark mode links */
body[data-theme="dark"] a {
    color: #60a5fa;
}

body[data-theme="dark"] a:hover {
    color: #93bbfd;
}

/* Dark mode hr */
body[data-theme="dark"] hr {
    border-color: #374151;
}

/* Dark mode labels and text helpers */
body[data-theme="dark"] label {
    color: #d1d5db;
}

body[data-theme="dark"] .text-muted {
    color: #9ca3af !important;
}

body[data-theme="dark"] .text-dark {
    color: #f9fafb !important;
}

/* Dark mode cards with hardcoded white backgrounds */
body[data-theme="dark"] .card {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
    color: #f9fafb;
}

body[data-theme="dark"] .card-header {
    background-color: #1a2332 !important;
    border-bottom-color: #374151 !important;
    color: #f9fafb;
}

body[data-theme="dark"] .card-body {
    background-color: #1f2937 !important;
}

body[data-theme="dark"] .card-footer {
    background-color: #1a2332 !important;
    border-top-color: #374151 !important;
}

/* Dark mode alerts */
body[data-theme="dark"] .alert {
    border-color: #374151;
}

/* Dark mode pagination */
body[data-theme="dark"] .pagination .page-link {
    background-color: #1f2937;
    border-color: #374151;
    color: #d1d5db;
}

body[data-theme="dark"] .pagination .page-item.active .page-link {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* Dark mode tooltips (Bootstrap) */
body[data-theme="dark"] .tooltip-inner {
    background-color: #f9fafb;
    color: #111827;
}

/* ============================================
   DARK MODE - Catch-All Element Overrides
   Handles hardcoded white/light colors across
   all modules without modifying each file
   ============================================ */

/* ALL sidebars */
body[data-theme="dark"] [class*="-sidebar"] {
    background: #1a1b1e !important;
    border-color: #374151 !important;
}

/* ALL main content areas */
body[data-theme="dark"] [class*="-main"] {
    background: #111827 !important;
}

/* ALL sidebar links */
body[data-theme="dark"] [class*="-sidebar-link"],
body[data-theme="dark"] [class*="-nav-item"] {
    color: #9ca3af !important;
}

body[data-theme="dark"] [class*="-sidebar-link"]:hover,
body[data-theme="dark"] [class*="-nav-item"]:hover {
    background: #374151 !important;
    color: #e5e7eb !important;
}

body[data-theme="dark"] [class*="-sidebar-link"].active,
body[data-theme="dark"] [class*="-nav-item"].active {
    color: white !important;
}

/* ALL cards, panels, containers, sections, wrappers */
body[data-theme="dark"] [class*="-card"],
body[data-theme="dark"] [class*="-panel"],
body[data-theme="dark"] [class*="-box"],
body[data-theme="dark"] [class*="-section"],
body[data-theme="dark"] [class*="-wrapper"],
body[data-theme="dark"] [class*="-content"]:not(.modal-content),
body[data-theme="dark"] [class*="-detail"],
body[data-theme="dark"] [class*="-info-card"],
body[data-theme="dark"] [class*="-stats"],
body[data-theme="dark"] [class*="-summary"],
body[data-theme="dark"] [class*="-empty"],
body[data-theme="dark"] [class*="-placeholder"],
body[data-theme="dark"] [class*="-skeleton"] {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
    border-color: #374151 !important;
}

/* Headers and footers within components */
body[data-theme="dark"] [class*="-header"]:not(.x-header-topbar):not(.modal-header),
body[data-theme="dark"] [class*="-footer"]:not(.modal-footer) {
    background-color: #1a2332 !important;
    color: #f9fafb !important;
    border-color: #374151 !important;
}

/* Body sections within components */
body[data-theme="dark"] [class*="-body"]:not(.modal-body) {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
}

/* List items and rows */
body[data-theme="dark"] [class*="-item"],
body[data-theme="dark"] [class*="-row"]:not(tr) {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] [class*="-item"]:hover,
body[data-theme="dark"] [class*="-row"]:not(tr):hover {
    background-color: #253344 !important;
}

/* Forms and groups */
body[data-theme="dark"] [class*="-form"],
body[data-theme="dark"] [class*="-group"],
body[data-theme="dark"] [class*="-field"] {
    color: #f9fafb !important;
}

/* Lists */
body[data-theme="dark"] [class*="-list"] {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
}

/* Tabs */
body[data-theme="dark"] [class*="-tab"] {
    background-color: #1f2937 !important;
    color: #d1d5db !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] [class*="-tab"].active,
body[data-theme="dark"] [class*="-tab"][class*="active"] {
    color: #f9fafb !important;
}

/* Modals, dialogs, popups */
body[data-theme="dark"] [class*="-modal"],
body[data-theme="dark"] [class*="-dialog"],
body[data-theme="dark"] [class*="-popup"] {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
    border-color: #374151 !important;
}

/* Dropdowns and menus */
body[data-theme="dark"] [class*="-dropdown"],
body[data-theme="dark"] [class*="-menu"]:not([class*="hamburger"]) {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
    color: #f9fafb !important;
}

/* Filters and search bars */
body[data-theme="dark"] [class*="-filter"],
body[data-theme="dark"] [class*="-search"] {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
    color: #f9fafb !important;
}

/* Notifications, alerts, toasts */
body[data-theme="dark"] [class*="-notification"],
body[data-theme="dark"] [class*="-alert"]:not([class*="alert-"]),
body[data-theme="dark"] [class*="-toast"] {
    background-color: #1a2744 !important;
    border-color: #374151 !important;
    color: #f9fafb !important;
}

/* Status badges - preserve colored backgrounds but fix plain ones */
body[data-theme="dark"] [class*="-badge"]:not([class*="-badge-success"]):not([class*="-badge-warning"]):not([class*="-badge-danger"]):not([class*="-badge-info"]):not([class*="-badge-primary"]) {
    background-color: #374151 !important;
    color: #f9fafb !important;
}

/* Toggle sliders */
body[data-theme="dark"] [class*="slider"]:before,
body[data-theme="dark"] [class*="toggle-slider"]:before {
    background-color: #d1d5db !important;
}

/* Typography - ensure text colors inherit dark mode */
body[data-theme="dark"] h1, body[data-theme="dark"] h2,
body[data-theme="dark"] h3, body[data-theme="dark"] h4,
body[data-theme="dark"] h5, body[data-theme="dark"] h6 {
    color: #f9fafb !important;
}

body[data-theme="dark"] p {
    color: #d1d5db;
}

body[data-theme="dark"] strong, body[data-theme="dark"] b {
    color: #f9fafb;
}

body[data-theme="dark"] small {
    color: #9ca3af;
}

/* Ensure all generic containers catch hardcoded whites */
body[data-theme="dark"] .container,
body[data-theme="dark"] .container-fluid {
    color: #f9fafb;
}

/* Nav pills/tabs (Bootstrap-style) */
body[data-theme="dark"] .nav-tabs {
    border-bottom-color: #374151;
}

body[data-theme="dark"] .nav-tabs .nav-link {
    color: #9ca3af;
}

body[data-theme="dark"] .nav-tabs .nav-link.active {
    background-color: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

body[data-theme="dark"] .nav-pills .nav-link {
    color: #9ca3af;
}

body[data-theme="dark"] .nav-pills .nav-link.active {
    background-color: #3b82f6;
    color: white;
}

/* Accordion */
body[data-theme="dark"] .accordion-item {
    background-color: #1f2937;
    border-color: #374151;
}

body[data-theme="dark"] .accordion-button {
    background-color: #1f2937;
    color: #f9fafb;
}

body[data-theme="dark"] .accordion-body {
    background-color: #1f2937;
}

/* Breadcrumbs */
body[data-theme="dark"] .breadcrumb {
    background-color: transparent;
}

body[data-theme="dark"] .breadcrumb-item a {
    color: #60a5fa;
}

body[data-theme="dark"] .breadcrumb-item.active {
    color: #9ca3af;
}

/* Progress bars */
body[data-theme="dark"] .progress {
    background-color: #374151;
}

/* Close buttons */
body[data-theme="dark"] .btn-close,
body[data-theme="dark"] .close {
    filter: invert(1);
}

/* Google Places autocomplete */
body[data-theme="dark"] .pac-container {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] .pac-item {
    background-color: #1f2937 !important;
    color: #d1d5db !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] .pac-item:hover {
    background-color: #374151 !important;
}

body[data-theme="dark"] .pac-item-query {
    color: #f9fafb !important;
}

/* Select2 dropdowns */
body[data-theme="dark"] .select2-container--default .select2-selection {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
    color: #f9fafb !important;
}

body[data-theme="dark"] .select2-dropdown {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
}

body[data-theme="dark"] .select2-results__option {
    color: #d1d5db !important;
}

body[data-theme="dark"] .select2-results__option--highlighted {
    background-color: #374151 !important;
    color: #f9fafb !important;
}

/* DataTables */
body[data-theme="dark"] .dataTables_wrapper {
    color: #f9fafb;
}

body[data-theme="dark"] .dataTables_wrapper .dataTables_length,
body[data-theme="dark"] .dataTables_wrapper .dataTables_filter,
body[data-theme="dark"] .dataTables_wrapper .dataTables_info,
body[data-theme="dark"] .dataTables_wrapper .dataTables_paginate {
    color: #d1d5db !important;
}

/* Popovers */
body[data-theme="dark"] .popover {
    background-color: #1f2937;
    border-color: #374151;
}

body[data-theme="dark"] .popover-header {
    background-color: #1a2332;
    border-bottom-color: #374151;
    color: #f9fafb;
}

body[data-theme="dark"] .popover-body {
    color: #d1d5db;
}

/* Preserve white text on colored buttons */
body[data-theme="dark"] [class*="btn-primary"],
body[data-theme="dark"] [class*="btn-success"],
body[data-theme="dark"] [class*="btn-danger"],
body[data-theme="dark"] [class*="btn-warning"],
body[data-theme="dark"] [class*="btn-info"],
body[data-theme="dark"] .x-btn-primary,
body[data-theme="dark"] .x-btn-success,
body[data-theme="dark"] .x-btn-danger {
    color: white !important;
}

/* Secondary/outline buttons in dark mode */
body[data-theme="dark"] [class*="btn-secondary"],
body[data-theme="dark"] [class*="btn-outline"],
body[data-theme="dark"] .x-btn-secondary {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f9fafb !important;
}

body[data-theme="dark"] [class*="btn-outline"]:hover,
body[data-theme="dark"] [class*="btn-secondary"]:hover,
body[data-theme="dark"] .x-btn-secondary:hover {
    background-color: #4b5563 !important;
}

/* Main Content Area */
.x-main {
    margin-left: var(--x-sidebar-width);
    min-height: 100vh;
    background: var(--x-bg-secondary);
}

.x-content {
    padding: var(--x-spacing-xl);
    padding-top: calc(var(--x-topbar-height) + var(--x-spacing-xl));
    max-width: 1400px;
    margin: 0 auto;
}
