/* 
 * BAC Bill & Invoice Management System - Premium Stylesheet
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    /* Default: Dark Mode variables with increased contrast */
    --bg-primary: #0b0f19;
    --bg-secondary: #131b2e;
    --bg-tertiary: #1e293b;
    --border-color: #273549;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1; /* Increased contrast (was #94a3b8) */
    --text-muted: #94a3b8; /* Increased contrast (was #64748b) */
    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --glass-bg: rgba(19, 27, 46, 0.75);
    --glass-border: rgba(39, 53, 73, 0.6);
    --hover-bg: rgba(255, 255, 255, 0.03);
    --kpi-bg: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(19, 27, 46, 0.9) 100%);
    --kpi-after-radial: radial-gradient(circle, rgba(6, 182, 212, 0.05) 0%, transparent 70%);
    --sidebar-width: 260px;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Poppins', sans-serif;
}

/* Light Mode Variables Override */
body.light-mode {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --border-color: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(226, 232, 240, 0.85);
    --hover-bg: rgba(0, 0, 0, 0.02);
    --kpi-bg: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(241, 245, 249, 0.9) 100%);
    --kpi-after-radial: radial-gradient(circle, rgba(6, 182, 212, 0.02) 0%, transparent 70%);

    /* Slightly darker accent colors for higher contrast in light mode */
    --accent-cyan: #0891b2;
    --accent-blue: #1d4ed8;
    --accent-purple: #6d28d9;
    --accent-emerald: #047857;
    --accent-rose: #be123c;
}

/* High Contrast Override Utilities */
.text-muted {
    color: var(--text-muted) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    overflow-x: hidden;
    letter-spacing: 0.2px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

/* Light Mode DOM Overrides */
body.light-mode .text-white,
body.light-mode .dropdown-toggle,
body.light-mode .dropdown-item,
body.light-mode .table-custom tbody tr,
body.light-mode .table-custom tbody td,
body.light-mode .sidebar h6 {
    color: var(--text-primary) !important;
}

body.light-mode .sidebar-brand-name {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-mode .sidebar-brand i {
    color: var(--accent-cyan) !important;
}

body.light-mode .sidebar {
    background-color: var(--bg-secondary);
    border-right-color: var(--border-color);
}

body.light-mode .sidebar-brand {
    background: rgba(0, 0, 0, 0.02);
    border-bottom-color: var(--border-color);
}

body.light-mode .sidebar-footer {
    background: rgba(0, 0, 0, 0.02);
    border-top-color: var(--border-color);
}

body.light-mode .top-navbar {
    background-color: var(--bg-secondary);
    border-bottom-color: var(--border-color);
}

body.light-mode .top-navbar h5 {
    color: var(--text-primary) !important;
}

body.light-mode .card-glass {
    background-color: var(--glass-bg);
    border-color: var(--glass-border);
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

body.light-mode .card-header-custom {
    border-bottom-color: var(--border-color);
    background: rgba(0, 0, 0, 0.02);
}

body.light-mode .dropdown-menu {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body.light-mode .dropdown-item:hover {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

body.light-mode .modal-content {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.light-mode .modal-header,
body.light-mode .modal-footer {
    border-color: var(--border-color) !important;
}

body.light-mode .modal-header .btn-close {
    filter: invert(1);
}

body.light-mode .form-control,
body.light-mode .form-select {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.light-mode .form-control:focus,
body.light-mode .form-select:focus {
    border-color: var(--accent-cyan);
    background-color: var(--bg-secondary);
}

body.light-mode .input-group-text {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

body.light-mode .table-custom thead th {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border-bottom-color: var(--border-color);
}

body.light-mode .table-custom tbody td {
    border-bottom-color: var(--border-color);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 100;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-brand-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-left: 0.5rem;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.sidebar-menu-item {
    margin: 0.2rem 1rem;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-menu-link i {
    font-size: 1.2rem;
    margin-right: 0.75rem;
    transition: transform 0.2s ease;
}

.sidebar-menu-link:hover {
    background: rgba(6, 182, 212, 0.08);
    color: var(--text-primary);
}

.sidebar-menu-link:hover i {
    transform: scale(1.1);
}

.sidebar-menu-item.active .sidebar-menu-link {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.1));
    color: var(--text-primary);
    border-left: 3px solid var(--accent-cyan);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

/* Main Content Wrapper */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* Header Top Navbar */
.top-navbar {
    height: 70px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.content-body {
    padding: 2rem;
    flex-grow: 1;
}

/* Cards & Glassmorphism */
.card-glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.3s ease;
}

.card-glass:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(6, 182, 212, 0.4);
}

.card-header-custom {
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
    padding: 1.25rem 1.5rem;
}

/* Inputs & Form Controls */
.form-control, .form-select {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-primary);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 0.25rem rgba(6, 182, 212, 0.15);
    color: var(--text-primary);
}

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

.form-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group-text {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Buttons */
.btn-cyan {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-cyan:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
    color: white;
}

.btn-outline-cyan {
    background: transparent;
    border: 1.5px solid var(--accent-cyan);
    color: var(--accent-cyan);
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-outline-cyan:hover {
    background: var(--accent-cyan);
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.2);
}

.btn-outline-rose {
    background: transparent;
    border: 1.5px solid var(--accent-rose);
    color: var(--accent-rose);
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-outline-rose:hover {
    background: var(--accent-rose);
    color: white;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.2);
}

/* Tables */
.table-custom {
    color: var(--text-primary);
    margin-bottom: 0;
    --bs-table-bg: transparent !important;
    --bs-table-accent-bg: transparent !important;
    background-color: transparent !important;
}

/* Fix contrast of standard tables inside card-glass elements */
.card-glass table,
.card-glass td,
.card-glass th {
    background-color: transparent !important;
    --bs-table-bg: transparent !important;
}

.card-glass table.text-white td:not(.text-muted),
.card-glass table.text-white th:not(.text-muted) {
    color: var(--text-primary) !important;
}

.table-custom thead th {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    border-bottom: 1.5px solid var(--border-color);
    padding: 1rem;
}

.table-custom tbody tr {
    transition: background-color 0.2s ease;
    background-color: transparent !important;
}

.table-custom tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    background-color: transparent !important;
    color: var(--text-primary);
}

.table-custom tbody tr:hover {
    background-color: var(--hover-bg) !important;
}

/* Badges */
.badge-active, .badge-paid, .badge-approved, .badge-yes {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.35em 0.65em;
    border-radius: 6px;
    font-weight: 500;
}

.badge-draft, .badge-unpaid, .badge-pending, .badge-submitted {
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 0.35em 0.65em;
    border-radius: 6px;
    font-weight: 500;
}

.badge-inactive, .badge-locked, .badge-rejected, .badge-cancelled, .badge-no {
    background-color: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
    padding: 0.35em 0.65em;
    border-radius: 6px;
    font-weight: 500;
}

.badge-partially_paid {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.35em 0.65em;
    border-radius: 6px;
    font-weight: 500;
}

/* KPI Cards */
.kpi-card {
    background: var(--kpi-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 150px;
    height: 150px;
    background: var(--kpi-after-radial);
    border-radius: 50%;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.kpi-icon-cyan { background: rgba(6, 182, 212, 0.1); color: var(--accent-cyan); }
.kpi-icon-blue { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.kpi-icon-purple { background: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }
.kpi-icon-emerald { background: rgba(16, 185, 129, 0.1); color: var(--accent-emerald); }
.kpi-icon-rose { background: rgba(244, 63, 94, 0.1); color: var(--accent-rose); }

/* Login Page Layout */
.login-body {
    background: radial-gradient(circle at top right, #111827, #030712);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: rgba(17, 24, 39, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Print CSS overrides */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 10pt !important;
    }
    .sidebar, .top-navbar, .btn, .no-print, nav, footer, .breadcrumb {
        display: none !important;
    }
    .main-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .content-body {
        padding: 0 !important;
    }
    .card, .card-glass {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
    }
    .table-custom thead th {
        background-color: #f1f5f9 !important;
        color: #000 !important;
        border-bottom: 2px solid #000 !important;
    }
    .table-custom tbody td {
        border-bottom: 1px solid #ddd !important;
    }
}

/* --- High-Contrast & Color-Safe Visibility Rules --- */

/* 1. Ensure default dark mode views with white/light backgrounds force dark text */
body:not(.light-mode) .bg-white,
body:not(.light-mode) .bg-light,
body:not(.light-mode) .invoice-print-container {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

body:not(.light-mode) .bg-white *,
body:not(.light-mode) .bg-light *,
body:not(.light-mode) .invoice-print-container * {
    color: #1e293b !important;
}

body:not(.light-mode) .bg-white h1, body:not(.light-mode) .bg-white h2, body:not(.light-mode) .bg-white h3, body:not(.light-mode) .bg-white h4, body:not(.light-mode) .bg-white h5, body:not(.light-mode) .bg-white h6,
body:not(.light-mode) .bg-light h1, body:not(.light-mode) .bg-light h2, body:not(.light-mode) .bg-light h3, body:not(.light-mode) .bg-light h4, body:not(.light-mode) .bg-light h5, body:not(.light-mode) .bg-light h6,
body:not(.light-mode) .invoice-print-container h1, body:not(.light-mode) .invoice-print-container h2, body:not(.light-mode) .invoice-print-container h3, body:not(.light-mode) .invoice-print-container h4, body:not(.light-mode) .invoice-print-container h5, body:not(.light-mode) .invoice-print-container h6,
body:not(.light-mode) .bg-white th, body:not(.light-mode) .bg-white td,
body:not(.light-mode) .bg-light th, body:not(.light-mode) .bg-light td,
body:not(.light-mode) .invoice-print-container th, body:not(.light-mode) .invoice-print-container td,
body:not(.light-mode) .invoice-print-container p, body:not(.light-mode) .invoice-print-container span, body:not(.light-mode) .invoice-print-container small, body:not(.light-mode) .invoice-print-container strong, body:not(.light-mode) .invoice-print-container div {
    color: #1e293b !important;
}

body:not(.light-mode) .bg-white strong,
body:not(.light-mode) .bg-light strong,
body:not(.light-mode) .invoice-print-container strong,
body:not(.light-mode) .bg-white th,
body:not(.light-mode) .bg-light th,
body:not(.light-mode) .invoice-print-container th {
    color: #0f172a !important;
}

body:not(.light-mode) .bg-white .text-muted,
body:not(.light-mode) .bg-light .text-muted,
body:not(.light-mode) .invoice-print-container .text-muted {
    color: #64748b !important;
}

body:not(.light-mode) .bg-white .text-secondary,
body:not(.light-mode) .bg-light .text-secondary,
body:not(.light-mode) .invoice-print-container .text-secondary {
    color: #475569 !important;
}

body:not(.light-mode) .bg-white code,
body:not(.light-mode) .bg-light code,
body:not(.light-mode) .invoice-print-container code {
    color: #be123c !important;
    background-color: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
}

/* 2. Light Mode: adaptive overrides to make dark background elements readable */
body.light-mode .bg-dark {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.light-mode .bg-dark *,
body.light-mode .bg-dark h1, body.light-mode .bg-dark h2, body.light-mode .bg-dark h3, body.light-mode .bg-dark h4, body.light-mode .bg-dark h5, body.light-mode .bg-dark h6,
body.light-mode .bg-dark p, body.light-mode .bg-dark span, body.light-mode .bg-dark small, body.light-mode .bg-dark strong, body.light-mode .bg-dark div,
body.light-mode .bg-dark th, body.light-mode .bg-dark td,
body.light-mode .bg-dark .text-white, body.light-mode .bg-dark .text-secondary {
    color: var(--text-primary) !important;
}

body.light-mode .bg-dark .text-muted {
    color: var(--text-muted) !important;
}

/* Ensure buttons with btn-dark remain dark and have crisp white text */
body.light-mode .btn-dark,
body.light-mode .btn-dark.dropdown-toggle,
body.light-mode .btn-dark:hover,
body.light-mode .btn-dark:focus,
body.light-mode .btn-dark:active {
    background-color: #0f172a !important;
    border-color: #0f172a !important;
    color: #ffffff !important;
}

/* Fix dropdown menu bg-dark overrides */
body.light-mode .dropdown-menu.bg-dark {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}
body.light-mode .dropdown-menu.bg-dark .dropdown-item {
    color: var(--text-primary) !important;
}
body.light-mode .dropdown-menu.bg-dark .dropdown-item:hover {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}
body.light-mode .dropdown-menu.bg-dark .dropdown-divider {
    border-color: var(--border-color) !important;
}

/* Fix system footer */
body.light-mode footer.bg-dark {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}
body.light-mode footer.bg-dark * {
    color: var(--text-secondary) !important;
}

/* Fix navigation links/tabs in light mode */
body.light-mode .nav-link.bg-dark {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}
body.light-mode .nav-link.bg-dark.active {
    background-color: var(--bg-primary) !important;
    color: var(--accent-cyan) !important;
    border-bottom-color: transparent !important;
}

/* Fix list items in permissions matrix */
body.light-mode .list-group-item.bg-dark {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
body.light-mode .list-group-item.bg-dark.active {
    background-color: var(--accent-cyan) !important;
    border-color: var(--accent-cyan) !important;
    color: #ffffff !important;
}

/* Fix readonly text controls that have .bg-dark in views */
body.light-mode .form-control.bg-dark,
body.light-mode .form-select.bg-dark {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Keep white text white in elements with explicitly dark backgrounds in light mode */
body.light-mode .text-white[style*="background"],
body.light-mode [style*="background: #000"].text-white,
body.light-mode [style*="background:#000"].text-white,
body.light-mode [style*="background-color: #000"].text-white,
body.light-mode [style*="background-color:#000"].text-white,
body.light-mode [style*="background: black"].text-white,
body.light-mode [style*="background:black"].text-white,
body.light-mode [style*="background-color: black"].text-white,
body.light-mode [style*="background-color:black"].text-white,
body.light-mode [style*="background: #000"] .text-white,
body.light-mode [style*="background:#000"] .text-white,
body.light-mode [style*="background-color: #000"] .text-white,
body.light-mode [style*="background-color:#000"] .text-white,
body.light-mode [style*="background: black"] .text-white,
body.light-mode [style*="background:black"] .text-white,
body.light-mode [style*="background-color: black"] .text-white,
body.light-mode [style*="background-color:black"] .text-white {
    color: #ffffff !important;
}

body.light-mode .text-white[style*="background"] *,
body.light-mode [style*="background: #000"].text-white *,
body.light-mode [style*="background:#000"].text-white *,
body.light-mode [style*="background-color: #000"].text-white *,
body.light-mode [style*="background-color:#000"].text-white *,
body.light-mode [style*="background: black"].text-white *,
body.light-mode [style*="background:black"].text-white *,
body.light-mode [style*="background-color: black"].text-white *,
body.light-mode [style*="background-color:black"].text-white *,
body.light-mode [style*="background: #000"] .text-white *,
body.light-mode [style*="background:#000"] .text-white *,
body.light-mode [style*="background-color: #000"] .text-white *,
body.light-mode [style*="background-color:#000"] .text-white *,
body.light-mode [style*="background: black"] .text-white *,
body.light-mode [style*="background:black"] .text-white *,
body.light-mode [style*="background-color: black"] .text-white *,
body.light-mode [style*="background-color:black"] .text-white * {
    color: #ffffff !important;
}

/* --- Responsive Sidebar Collapsing & Expanding --- */

/* Desktop view state rules */
@media (min-width: 768.01px) {
    .sidebar {
        left: 0;
    }
    .sidebar.collapsed {
        left: -260px;
    }
    .main-wrapper {
        margin-left: var(--sidebar-width);
    }
    .main-wrapper.expanded {
        margin-left: 0 !important;
    }
    .table-responsive {
        overflow: visible !important;
    }
}

/* Mobile/Tablet view state rules */
@media (max-width: 768px) {
    .sidebar {
        left: -260px;
    }
    /* When toggled active on mobile, slide in and show dark shadow overlay */
    .sidebar.show-mobile {
        left: 0;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.4);
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
}

/* Sidebar Toggle Button styling for high contrast and premium aesthetics */
#sidebarToggle {
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    background-color: transparent !important;
    font-size: 1.2rem;
    padding: 0.25rem 0.55rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#sidebarToggle:hover {
    background-color: var(--accent-cyan) !important;
    border-color: var(--accent-cyan) !important;
    color: #ffffff !important;
}

#sidebarToggle i {
    color: inherit !important;
}

/* --- Dropdown Menus Global Style Enhancements --- */
.dropdown-menu {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4) !important;
    border-radius: 10px !important;
    padding: 0.4rem 0 !important;
    z-index: 1000 !important;
}

.dropdown-item {
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem !important;
    transition: all 0.2s ease;
}

/* Override default Bootstrap hover styles & text-white class conflicts */
.dropdown-item:hover,
.dropdown-item.text-white:hover,
.dropdown-item:focus {
    background-color: var(--bg-tertiary) !important;
    color: var(--accent-cyan) !important;
}

.dropdown-item.text-danger:hover {
    background-color: rgba(244, 63, 94, 0.12) !important;
    color: var(--accent-rose) !important;
}

.dropdown-divider {
    border-color: var(--border-color) !important;
    opacity: 1 !important;
}
