/* ============================================
   NEXUS KLOUD THEME SYSTEM
   Light & Dark Mode Support
   ============================================ */

/* Light Theme (Default) */
:root {
    /* Primary Colors */
    --theme-primary: #667eea;
    --theme-primary-hover: #5a67d8;
    --theme-primary-light: #eef2ff;
    --theme-primary-rgb: 102, 126, 234;

    /* Secondary / Accent */
    --theme-secondary: #764ba2;
    --theme-accent: #0ea5e9;

    /* Backgrounds */
    --theme-bg-primary: #f6f9fc;
    --theme-bg-secondary: #ffffff;
    --theme-bg-tertiary: #f8fafc;
    --theme-bg-card: #ffffff;
    --theme-bg-hover: #f1f5f9;
    --theme-bg-input: #ffffff;

    /* Text Colors */
    --theme-text-primary: #1e293b;
    --theme-text-secondary: #64748b;
    --theme-text-muted: #94a3b8;
    --theme-text-inverse: #ffffff;

    /* Borders */
    --theme-border: #e2e8f0;
    --theme-border-hover: #cbd5e1;
    --theme-border-focus: #667eea;

    /* Shadows */
    --theme-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --theme-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    --theme-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --theme-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --theme-shadow-primary: 0 4px 12px rgba(102, 126, 234, 0.25);

    /* Gradient */
    --theme-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --theme-gradient-hover: linear-gradient(135deg, #5a67d8 0%, #6b4190 100%);

    /* Status Colors */
    --theme-success: #10b981;
    --theme-success-bg: #d1fae5;
    --theme-warning: #f59e0b;
    --theme-warning-bg: #fef3c7;
    --theme-error: #ef4444;
    --theme-error-bg: #fee2e2;
    --theme-info: #0ea5e9;
    --theme-info-bg: #e0f2fe;

    /* Info/Warning/Idea/Highlight Boxes */
    --theme-box-info-bg: #cff4fc;
    --theme-box-info-border: #0dcaf0;
    --theme-box-info-text: #055160;
    --theme-box-warning-bg: #f8d7da;
    --theme-box-warning-border: #dc3545;
    --theme-box-warning-text: #842029;
    --theme-box-idea-bg: #d1e7dd;
    --theme-box-idea-border: #198754;
    --theme-box-idea-text: #0f5132;
    --theme-box-highlight-bg: #fff3cd;
    --theme-box-highlight-border: #ffc107;
    --theme-box-highlight-text: #664d03;

    /* Badge Colors */
    --theme-badge-bg: #eef2ff;
    --theme-badge-text: #4f46e5;

    /* Scrollbar */
    --theme-scrollbar-track: #f1f5f9;
    --theme-scrollbar-thumb: #cbd5e1;
    --theme-scrollbar-thumb-hover: #94a3b8;

    /* Header */
    --theme-header-bg: #f8fafc;
    --theme-header-text: #1e293b;

    /* Sidebar */
    --theme-sidebar-bg: #12132e;
    --theme-sidebar-text: #7a7a8c;
    --theme-sidebar-text-hover: #ffffff;
    --theme-sidebar-hover-bg: #1e2040;

    /* Transitions */
    --theme-transition: 0.2s ease;
    --theme-transition-slow: 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"],
body.dark-theme,
body.dark-mode {
    /* Primary Colors */
    --theme-primary: #818cf8;
    --theme-primary-hover: #a5b4fc;
    --theme-primary-light: #1e1b4b;
    --theme-primary-rgb: 129, 140, 248;

    /* Secondary / Accent */
    --theme-secondary: #a78bfa;
    --theme-accent: #38bdf8;

    /* Backgrounds */
    --theme-bg-primary: #0f172a;
    --theme-bg-secondary: #1e293b;
    --theme-bg-tertiary: #334155;
    --theme-bg-card: #1e293b;
    --theme-bg-hover: #334155;
    --theme-bg-input: #1e293b;

    /* Text Colors */
    --theme-text-primary: #f1f5f9;
    --theme-text-secondary: #94a3b8;
    --theme-text-muted: #64748b;
    --theme-text-inverse: #0f172a;

    /* Borders */
    --theme-border: #334155;
    --theme-border-hover: #475569;
    --theme-border-focus: #818cf8;

    /* Shadows */
    --theme-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --theme-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    --theme-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --theme-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --theme-shadow-primary: 0 4px 12px rgba(129, 140, 248, 0.3);

    /* Gradient */
    --theme-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --theme-gradient-hover: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%);

    /* Status Colors */
    --theme-success: #34d399;
    --theme-success-bg: #064e3b;
    --theme-warning: #fbbf24;
    --theme-warning-bg: #78350f;
    --theme-error: #f87171;
    --theme-error-bg: #7f1d1d;
    --theme-info: #38bdf8;
    --theme-info-bg: #0c4a6e;

    /* Info/Warning/Idea/Highlight Boxes — soft tinted surfaces that sit over --theme-bg-card */
    --theme-box-info-bg: rgba(34, 211, 238, 0.12);
    --theme-box-info-border: #22d3ee;
    --theme-box-info-text: #a5f3fc;
    --theme-box-warning-bg: rgba(248, 113, 113, 0.12);
    --theme-box-warning-border: #f87171;
    --theme-box-warning-text: #fecaca;
    --theme-box-idea-bg: rgba(52, 211, 153, 0.12);
    --theme-box-idea-border: #34d399;
    --theme-box-idea-text: #bbf7d0;
    --theme-box-highlight-bg: rgba(251, 191, 36, 0.14);
    --theme-box-highlight-border: #fbbf24;
    --theme-box-highlight-text: #fde68a;

    /* Badge Colors */
    --theme-badge-bg: #1e1b4b;
    --theme-badge-text: #a5b4fc;

    /* Scrollbar */
    --theme-scrollbar-track: #1e293b;
    --theme-scrollbar-thumb: #475569;
    --theme-scrollbar-thumb-hover: #64748b;

    /* Header */
    --theme-header-bg: #0f172a;
    --theme-header-text: #f1f5f9;

    /* Sidebar */
    --theme-sidebar-bg: #0a0a1e;
    --theme-sidebar-text: #94a3b8;
    --theme-sidebar-text-hover: #f1f5f9;
    --theme-sidebar-hover-bg: #1e1e3f;
}

/* ============================================
   BASE THEME STYLES
   ============================================ */

body {
    background-color: var(--theme-bg-primary);
    color: var(--theme-text-primary);
    transition: background-color var(--theme-transition), color var(--theme-transition);
}

/* Cards */
.card,
.theme-card {
    background-color: var(--theme-bg-card);
    border-color: var(--theme-border);
    box-shadow: var(--theme-shadow);
    transition: all var(--theme-transition);
}

.card:hover,
.theme-card:hover {
    border-color: var(--theme-border-hover);
    box-shadow: var(--theme-shadow-md);
}

/* Inputs */
.form-control,
.form-select,
.theme-input {
    background-color: var(--theme-bg-input);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
    transition: all var(--theme-transition);
}

.form-control:focus,
.form-select:focus,
.theme-input:focus {
    background-color: var(--theme-bg-input);
    border-color: var(--theme-border-focus);
    color: var(--theme-text-primary);
    box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.15);
}

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

/* Buttons */
.btn-primary,
.theme-btn-primary {
    background: var(--theme-gradient);
    border: none;
    color: var(--theme-text-inverse);
    transition: all var(--theme-transition);
}

.btn-primary:hover,
.theme-btn-primary:hover {
    background: var(--theme-gradient-hover);
    box-shadow: var(--theme-shadow-primary);
    transform: translateY(-1px);
}

.btn-outline-primary,
.theme-btn-outline {
    border-color: var(--theme-primary);
    color: var(--theme-primary);
    background: transparent;
    transition: all var(--theme-transition);
}

.btn-outline-primary:hover,
.theme-btn-outline:hover {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--theme-text-inverse);
}

/* Links */
a {
    color: var(--theme-primary);
    transition: color var(--theme-transition);
}

a:hover {
    color: var(--theme-primary-hover);
}

/* Badges */
.badge,
.theme-badge {
    background-color: var(--theme-badge-bg);
    color: var(--theme-badge-text);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--theme-scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--theme-scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--theme-scrollbar-thumb-hover);
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--theme-header-text);
    cursor: pointer;
    transition: all var(--theme-transition);
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle i {
    font-size: 1.2rem;
    transition: transform 0.3s ease, opacity 0.2s ease;
}

.theme-toggle .bi-sun-fill {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.theme-toggle .bi-moon-fill {
    opacity: 1;
    transform: rotate(0) scale(1);
}

[data-theme="dark"] .theme-toggle .bi-sun-fill,
body.dark-theme .theme-toggle .bi-sun-fill,
body.dark-mode .theme-toggle .bi-sun-fill {
    opacity: 1;
    transform: rotate(0) scale(1);
}

[data-theme="dark"] .theme-toggle .bi-moon-fill,
body.dark-theme .theme-toggle .bi-moon-fill,
body.dark-mode .theme-toggle .bi-moon-fill {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

/* ============================================
   DROPDOWN THEME SUPPORT
   ============================================ */

.dropdown-menu,
.profile-dropdown {
    background-color: var(--theme-bg-card);
    border-color: var(--theme-border);
    box-shadow: var(--theme-shadow-lg);
}

.dropdown-item {
    color: var(--theme-text-primary);
}

.dropdown-item:hover {
    background-color: var(--theme-bg-hover);
    color: var(--theme-primary);
}

.dropdown-item.disabled {
    color: var(--theme-text-muted);
}

.dropdown-divider {
    border-color: var(--theme-border);
}

/* ============================================
   TABLE THEME SUPPORT
   ============================================ */

.table {
    --bs-table-bg: var(--theme-bg-card);
    --bs-table-color: var(--theme-text-primary);
    --bs-table-border-color: var(--theme-border);
    --bs-table-striped-bg: var(--theme-bg-tertiary);
    --bs-table-hover-bg: var(--theme-bg-hover);
}

.table thead th {
    background-color: var(--theme-bg-tertiary);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

/* ============================================
   MODAL THEME SUPPORT
   ============================================ */

.modal-content {
    background-color: var(--theme-bg-card);
    border-color: var(--theme-border);
}

.modal-header {
    border-color: var(--theme-border);
}

.modal-footer {
    border-color: var(--theme-border);
}

.btn-close {
    filter: var(--bs-btn-close-white-filter);
}

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

/* ============================================
   ALERT / BOX THEME SUPPORT
   ============================================ */

.info-box {
    background-color: var(--theme-box-info-bg);
    border-left-color: var(--theme-box-info-border);
    color: var(--theme-box-info-text);
}

.warning-box {
    background-color: var(--theme-box-warning-bg);
    border-left-color: var(--theme-box-warning-border);
    color: var(--theme-box-warning-text);
}

.idea-box {
    background-color: var(--theme-box-idea-bg);
    border-left-color: var(--theme-box-idea-border);
    color: var(--theme-box-idea-text);
}

.highlight-box {
    background-color: var(--theme-box-highlight-bg);
    border-left-color: var(--theme-box-highlight-border);
    color: var(--theme-box-highlight-text);
}

/* ============================================
   BREADCRUMB THEME SUPPORT
   ============================================ */

.breadcrumb {
    background-color: transparent;
}

.breadcrumb-item a {
    color: var(--theme-primary);
}

.breadcrumb-item.active {
    color: var(--theme-text-secondary);
}

.breadcrumb-item+.breadcrumb-item::before {
    color: var(--theme-text-muted);
}

/* ============================================
   HEADER THEME OVERRIDES
   ============================================ */

.header {
    background-color: var(--theme-header-bg) !important;
    color: var(--theme-header-text) !important;
    border-bottom: 1px solid var(--theme-border);
    box-shadow: var(--theme-shadow-sm);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.header h3,
.header .m-0 {
    color: var(--theme-header-text) !important;
}

.header .bi-chevron-down,
.header .bi-list {
    color: var(--theme-header-text) !important;
}

.header .profile-button:hover {
    background-color: var(--theme-bg-hover);
}

.header .mobile-toggle-btn {
    color: var(--theme-header-text) !important;
    background: transparent;
    border: none;
}

.header .walkthrough-btn,
.header .btn-link {
    color: var(--theme-header-text) !important;
}

/* ============================================
   SIDEBAR THEME OVERRIDES
   ============================================ */

.sidebar {
    background-color: var(--theme-sidebar-bg);
}

.sidebar .nav-link {
    color: var(--theme-sidebar-text);
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: var(--theme-sidebar-hover-bg);
    color: var(--theme-sidebar-text-hover);
}

.sidebar .submenu {
    background-color: var(--theme-sidebar-hover-bg);
}

.sidebar .submenu a {
    color: var(--theme-sidebar-text);
}

.sidebar .submenu a:hover {
    color: var(--theme-sidebar-text-hover);
}

/* ============================================
   TOC (Table of Contents) THEME SUPPORT
   ============================================ */

.toc-nav a {
    color: var(--theme-text-secondary);
}

.toc-nav a:hover,
.toc-nav a.active {
    color: var(--theme-primary);
    border-left-color: var(--theme-primary);
}

/* ============================================
   SELECTION THEME
   ============================================ */

::selection {
    background-color: var(--theme-primary);
    color: var(--theme-text-inverse);
}

::-moz-selection {
    background-color: var(--theme-primary);
    color: var(--theme-text-inverse);
}

/* ============================================
   FOCUS STYLES
   ============================================ */

:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

/* ============================================
   SYSTEM PREFERENCE DETECTION
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not(.light-theme) {
        /* Only apply if user hasn't explicitly chosen light mode */
    }
}

/* ============================================
   SUPPORT PAGE (#support-app) — legacy styles.css
   forces .table cells and .form-control to white
   with !important even in dark mode. Restore themed
   surfaces for tickets list + create-ticket modal.
   (Must stay after styles.css in the support layout.)
   ============================================ */

#support-app .table.tickets-table {
    --bs-table-bg: var(--theme-bg-card);
    --bs-table-color: var(--theme-text-primary);
    --bs-table-border-color: var(--theme-border);
    --bs-table-striped-bg: var(--theme-bg-tertiary);
    --bs-table-hover-bg: var(--theme-bg-hover);
    --bs-table-hover-color: var(--theme-text-primary);
    background-color: var(--theme-bg-card) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

#support-app .table.tickets-table thead th {
    background-color: var(--theme-bg-tertiary) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

#support-app .table.tickets-table tbody td {
    background-color: var(--theme-bg-card) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

#support-app .table.tickets-table tbody tr.clickable:hover td {
    background-color: var(--theme-bg-hover) !important;
}

#support-app .filter-tab:not(.active) {
    background: var(--theme-bg-card) !important;
    color: var(--theme-text-secondary) !important;
    border-color: var(--theme-border) !important;
}

#support-app .filter-tab:not(.active):hover {
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border-hover) !important;
}

#support-app .filter-tab.active {
    background: var(--theme-gradient) !important;
    border-color: transparent !important;
    color: #ffffff !important;
}

#support-app .ticket-modal-content .form-control,
#support-app .ticket-modal-content .form-select,
#support-app .ticket-modal-content textarea,
#support-app .ticket-modal-content input[type="text"],
#support-app .ticket-modal-content input[type="tel"],
#support-app .ticket-modal-content input[type="file"] {
    background-color: var(--theme-bg-input) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

#support-app .ticket-modal-content .form-control:focus,
#support-app .ticket-modal-content textarea:focus,
#support-app .ticket-modal-content input[type="text"]:focus,
#support-app .ticket-modal-content input[type="tel"]:focus {
    background-color: var(--theme-bg-input) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border-focus) !important;
}

#support-app .ticket-modal-content .form-control::placeholder,
#support-app .ticket-modal-content textarea::placeholder {
    color: var(--theme-text-muted) !important;
}

#support-app .ticket-modal-content .form-label {
    color: var(--theme-text-secondary) !important;
}

#support-app .ticket-modal-content .form-text {
    color: var(--theme-text-muted) !important;
}

#support-app .ticket-modal-content input[type="file"]::file-selector-button {
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-primary);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    margin-right: 0.75rem;
}

#support-app .ticket-modal-content {
    background: var(--theme-bg-card) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

#support-app .ticket-modal-header {
    background: var(--theme-bg-card) !important;
    border-bottom-color: var(--theme-border) !important;
}

#support-app .ticket-modal-title {
    color: var(--theme-text-primary) !important;
}

#support-app .ticket-modal-close {
    color: var(--theme-text-secondary) !important;
}

#support-app .new-ticket-btn-cancel {
    background: var(--theme-bg-tertiary) !important;
    color: var(--theme-text-primary) !important;
    border: 1px solid var(--theme-border) !important;
}

#support-app .new-ticket-form .alert.alert-info {
    background: var(--theme-box-info-bg) !important;
    border-color: var(--theme-box-info-border) !important;
    color: var(--theme-box-info-text) !important;
}

#support-app .new-ticket-form .alert.alert-danger {
    background: var(--theme-error-bg) !important;
    border-color: var(--theme-error) !important;
    color: var(--theme-text-primary) !important;
}

#support-app .new-ticket-form .text-muted {
    color: var(--theme-text-muted) !important;
}

#support-app .new-ticket-form .progress {
    background-color: var(--theme-bg-tertiary);
}
/* ============================================
   SEARCH LOGS ADMIN PAGE
   ============================================ */

.search-logs-admin .search-log-badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.search-logs-admin .search-log-badge--primary {
    background: var(--theme-primary-light);
    color: var(--theme-primary);
    border: 1px solid var(--theme-primary);
}

.search-logs-admin .search-log-badge--info {
    background: var(--theme-info-bg);
    color: var(--theme-info);
    border: 1px solid var(--theme-info);
}

.search-logs-admin .search-log-badge--success {
    background: var(--theme-success-bg);
    color: var(--theme-success);
    border: 1px solid var(--theme-success);
}

.search-logs-admin .search-log-badge--danger {
    background: var(--theme-error-bg);
    color: var(--theme-error);
    border: 1px solid var(--theme-error);
}

.search-logs-admin .search-log-badge--warning {
    background: var(--theme-warning-bg);
    color: var(--theme-warning);
    border: 1px solid var(--theme-warning);
}

.search-logs-admin .search-log-badge--secondary {
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-secondary);
    border: 1px solid var(--theme-border);
}

.search-logs-admin .search-log-muted {
    color: var(--theme-text-muted);
}

.search-logs-admin .search-log-json-block {
    background: var(--theme-bg-tertiary);
    border: 1px solid var(--theme-border);
    color: var(--theme-text-primary);
}

.search-logs-admin .search-log-alert-info {
    background: var(--theme-box-info-bg) !important;
    border-color: var(--theme-box-info-border) !important;
    color: var(--theme-box-info-text) !important;
}

.search-logs-admin .search-log-alert-danger {
    background: var(--theme-error-bg) !important;
    border-color: var(--theme-error) !important;
    color: var(--theme-text-primary) !important;
}

.search-logs-admin .list-group-item {
    background: var(--theme-bg-card);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

.search-logs-admin .list-group-item.active {
    background: var(--theme-primary-light);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

.search-logs-admin .list-group-item:hover:not(.active) {
    background: var(--theme-bg-hover);
}

/* ============================================
   DARK MODE — Bootstrap badge / bg overrides
   (fixes badges across admin dashboard, tables,
   DataTables render strings, and legacy pages)
   ============================================ */

[data-theme="dark"] .badge.bg-secondary,
body.dark-theme .badge.bg-secondary,
body.dark-mode .badge.bg-secondary {
    background-color: var(--theme-bg-tertiary) !important;
    color: var(--theme-text-secondary) !important;
    border: 1px solid var(--theme-border);
}

[data-theme="dark"] .badge.bg-success,
body.dark-theme .badge.bg-success,
body.dark-mode .badge.bg-success {
    background-color: var(--theme-success-bg) !important;
    color: var(--theme-success) !important;
    border: 1px solid var(--theme-success);
}

[data-theme="dark"] .badge.bg-danger,
body.dark-theme .badge.bg-danger,
body.dark-mode .badge.bg-danger {
    background-color: var(--theme-error-bg) !important;
    color: var(--theme-error) !important;
    border: 1px solid var(--theme-error);
}

[data-theme="dark"] .badge.bg-warning,
body.dark-theme .badge.bg-warning,
body.dark-mode .badge.bg-warning {
    background-color: var(--theme-warning-bg) !important;
    color: var(--theme-warning) !important;
    border: 1px solid var(--theme-warning);
}

[data-theme="dark"] .badge.bg-info,
body.dark-theme .badge.bg-info,
body.dark-mode .badge.bg-info {
    background-color: var(--theme-info-bg) !important;
    color: var(--theme-info) !important;
    border: 1px solid var(--theme-info);
}

[data-theme="dark"] .badge.bg-light,
body.dark-theme .badge.bg-light,
body.dark-mode .badge.bg-light {
    background-color: var(--theme-bg-tertiary) !important;
    color: var(--theme-text-primary) !important;
    border: 1px solid var(--theme-border);
}

[data-theme="dark"] .badge.bg-primary,
body.dark-theme .badge.bg-primary,
body.dark-mode .badge.bg-primary {
    background-color: var(--theme-primary-light) !important;
    color: var(--theme-primary) !important;
    border: 1px solid var(--theme-primary);
}

[data-theme="dark"] .badge.bg-dark,
body.dark-theme .badge.bg-dark,
body.dark-mode .badge.bg-dark {
    background-color: var(--theme-bg-secondary) !important;
    color: var(--theme-text-primary) !important;
    border: 1px solid var(--theme-border);
}

/* Dark mode bg-* utilities used inside badges or standalone */
[data-theme="dark"] .bg-light,
body.dark-theme .bg-light,
body.dark-mode .bg-light {
    background-color: var(--theme-bg-tertiary) !important;
}

[data-theme="dark"] .text-dark,
body.dark-theme .text-dark,
body.dark-mode .text-dark {
    color: var(--theme-text-primary) !important;
}

[data-theme="dark"] .text-muted,
body.dark-theme .text-muted,
body.dark-mode .text-muted {
    color: var(--theme-text-muted) !important;
}

[data-theme="dark"] .text-success,
body.dark-theme .text-success,
body.dark-mode .text-success {
    color: var(--theme-success) !important;
}

[data-theme="dark"] .text-danger,
body.dark-theme .text-danger,
body.dark-mode .text-danger {
    color: var(--theme-error) !important;
}

[data-theme="dark"] .text-warning,
body.dark-theme .text-warning,
body.dark-mode .text-warning {
    color: var(--theme-warning) !important;
}

[data-theme="dark"] .text-info,
body.dark-theme .text-info,
body.dark-mode .text-info {
    color: var(--theme-info) !important;
}

/* Dark mode alerts */
[data-theme="dark"] .alert.alert-info,
body.dark-theme .alert.alert-info,
body.dark-mode .alert.alert-info {
    background: var(--theme-box-info-bg) !important;
    border-color: var(--theme-box-info-border) !important;
    color: var(--theme-box-info-text) !important;
}

[data-theme="dark"] .alert.alert-danger,
body.dark-theme .alert.alert-danger,
body.dark-mode .alert.alert-danger {
    background: var(--theme-error-bg) !important;
    border-color: var(--theme-error) !important;
    color: var(--theme-text-primary) !important;
}

[data-theme="dark"] .alert.alert-success,
body.dark-theme .alert.alert-success,
body.dark-mode .alert.alert-success {
    background: var(--theme-success-bg) !important;
    border-color: var(--theme-success) !important;
    color: var(--theme-text-primary) !important;
}

[data-theme="dark"] .alert.alert-warning,
body.dark-theme .alert.alert-warning,
body.dark-mode .alert.alert-warning {
    background: var(--theme-warning-bg) !important;
    border-color: var(--theme-warning) !important;
    color: var(--theme-text-primary) !important;
}

/* Dark mode list-group */
[data-theme="dark"] .list-group-item,
body.dark-theme .list-group-item,
body.dark-mode .list-group-item {
    background: var(--theme-bg-card);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

[data-theme="dark"] .list-group-item.active,
body.dark-theme .list-group-item.active,
body.dark-mode .list-group-item.active {
    background: var(--theme-primary-light);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

[data-theme="dark"] .list-group-item:hover:not(.active),
body.dark-theme .list-group-item:hover:not(.active),
body.dark-mode .list-group-item:hover:not(.active) {
    background: var(--theme-bg-hover);
}

/* Dark mode pre / code blocks */
[data-theme="dark"] pre,
body.dark-theme pre,
body.dark-mode pre {
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

/* ============================================
   DARK MODE — TABLE / DATA TABLE FIXES
   Fixes striped rows, hover, borders, and
   DataTables zebra striping in dark mode.
   ============================================ */

[data-theme="dark"] .table,
body.dark-theme .table,
body.dark-mode .table {
    --bs-table-bg: var(--theme-bg-card) !important;
    --bs-table-color: var(--theme-text-primary) !important;
    --bs-table-border-color: var(--theme-border) !important;
    --bs-table-striped-bg: var(--theme-bg-tertiary) !important;
    --bs-table-striped-color: var(--theme-text-primary) !important;
    --bs-table-hover-bg: var(--theme-bg-hover) !important;
    --bs-table-hover-color: var(--theme-text-primary) !important;
    --bs-table-active-bg: var(--theme-bg-hover) !important;
    --bs-table-active-color: var(--theme-text-primary) !important;
}

[data-theme="dark"] .table > thead > tr > th,
body.dark-theme .table > thead > tr > th,
body.dark-mode .table > thead > tr > th {
    background-color: var(--theme-bg-tertiary) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] .table > tbody > tr > td,
body.dark-theme .table > tbody > tr > td,
body.dark-mode .table > tbody > tr > td {
    background-color: var(--theme-bg-card) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

/* Striped rows — override Bootstrap nth-of-type */
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > *,
body.dark-theme .table-striped > tbody > tr:nth-of-type(odd) > *,
body.dark-mode .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: var(--theme-bg-tertiary) !important;
    background-color: var(--theme-bg-tertiary) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(even) > *,
body.dark-theme .table-striped > tbody > tr:nth-of-type(even) > *,
body.dark-mode .table-striped > tbody > tr:nth-of-type(even) > * {
    --bs-table-accent-bg: var(--theme-bg-card) !important;
    background-color: var(--theme-bg-card) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

/* Hover rows */
[data-theme="dark"] .table-hover > tbody > tr:hover > *,
body.dark-theme .table-hover > tbody > tr:hover > *,
body.dark-mode .table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: var(--theme-bg-hover) !important;
    background-color: var(--theme-bg-hover) !important;
    color: var(--theme-text-primary) !important;
}

/* DataTables specific classes */
[data-theme="dark"] table.dataTable tbody tr.odd,
body.dark-theme table.dataTable tbody tr.odd,
body.dark-mode table.dataTable tbody tr.odd {
    background-color: var(--theme-bg-tertiary) !important;
}

[data-theme="dark"] table.dataTable tbody tr.odd > td,
body.dark-theme table.dataTable tbody tr.odd > td,
body.dark-mode table.dataTable tbody tr.odd > td {
    background-color: var(--theme-bg-tertiary) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] table.dataTable tbody tr.even,
body.dark-theme table.dataTable tbody tr.even,
body.dark-mode table.dataTable tbody tr.even {
    background-color: var(--theme-bg-card) !important;
}

[data-theme="dark"] table.dataTable tbody tr.even > td,
body.dark-theme table.dataTable tbody tr.even > td,
body.dark-mode table.dataTable tbody tr.even > td {
    background-color: var(--theme-bg-card) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] table.dataTable tbody tr:hover > td,
body.dark-theme table.dataTable tbody tr:hover > td,
body.dark-mode table.dataTable tbody tr:hover > td {
    background-color: var(--theme-bg-hover) !important;
    color: var(--theme-text-primary) !important;
}

[data-theme="dark"] table.dataTable thead th,
body.dark-theme table.dataTable thead th,
body.dark-mode table.dataTable thead th {
    background-color: var(--theme-bg-tertiary) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] table.dataTable,
body.dark-theme table.dataTable,
body.dark-mode table.dataTable {
    border-color: var(--theme-border) !important;
}

/* DataTables pagination / info text */
[data-theme="dark"] .dataTables_info,
body.dark-theme .dataTables_info,
body.dark-mode .dataTables_info,
[data-theme="dark"] .dataTables_length label,
body.dark-theme .dataTables_length label,
body.dark-mode .dataTables_length label,
[data-theme="dark"] .dataTables_filter label,
body.dark-theme .dataTables_filter label,
body.dark-mode .dataTables_filter label {
    color: var(--theme-text-secondary) !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button,
body.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button,
body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--theme-text-secondary) !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--theme-primary-light) !important;
    color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
body.dark-theme .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--theme-bg-hover) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border-hover) !important;
}

/* Admin dashboard table-sm fix */
[data-theme="dark"] .table-sm > tbody > tr > td,
body.dark-theme .table-sm > tbody > tr > td,
body.dark-mode .table-sm > tbody > tr > td {
    background-color: var(--theme-bg-card) !important;
    color: var(--theme-text-primary) !important;
    border-color: var(--theme-border) !important;
}
