body.dark {
    background-color: #121212 !important;
    color: #e0e0e0 !important;
}

/* Universal background/text fixes for inputs and containers */
body.dark .card,
body.dark .dropdown-menu,
body.dark .navbar,
body.dark .table,
body.dark .list-group-item,
body.dark .form-control,
body.dark .form-select,
body.dark textarea {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

/* Text elements */
body.dark .card-title,
body.dark .card-text,
body.dark .list-group-item,
body.dark .dropdown-item,
body.dark label,
body.dark input,
body.dark select,
body.dark textarea,
body.dark th,
body.dark td,
body.dark .text-muted,
body.dark footer,
body.dark code,
body.dark pre {
    color: #e0e0e0 !important;
}

/* Enforce inner table cell text contrast (catches spans/divs inside td) */
body.dark .table td *,
body.dark .table th * {
    color: #f0f0f0 !important;
}

/* Table formatting */
body.dark .table thead,
body.dark .table thead th {
    background-color: #222 !important;
    color: #fff !important;
}

body.dark .table-striped > tbody > tr:nth-of-type(odd) {
    background-color: #1e1e1e;
}

body.dark .table-striped > tbody > tr:nth-of-type(even) {
    background-color: #2a2a2a;
}

body.dark .table td,
body.dark .table th {
    color: #f0f0f0 !important;
}

/* Code blocks inside table cells */
body.dark .table td code {
    color: #f8f8f8 !important;
    font-size: 0.9rem;
    word-break: break-word;
    white-space: pre-wrap;
}

/* Alerts */
body.dark .alert {
    color: #f8f9fa;
}

body.dark .alert-warning {
    background-color: #5c3d00;
    color: #f5e2b8;
    border-color: #aa7900;
}

body.dark .alert-danger {
    background-color: #4d0000;
    color: #f2c0c0;
    border-color: #aa0000;
}

body.dark .alert-success {
    background-color: #003300;
    color: #aaffaa;
    border-color: #007700;
}

/* Navbar and dropdown */
body.dark .navbar {
    background-color: #1a1a1a !important;
}

body.dark .navbar-brand,
body.dark .nav-link,
body.dark .dropdown-toggle,
body.dark .dropdown-menu,
body.dark .dropdown-item {
    color: #e0e0e0 !important;
}

body.dark .dropdown-menu {
    background-color: #2a2a2a !important;
    border-color: #444;
}

body.dark .dropdown-item:hover {
    background-color: #3a3a3a;
    color: #fff;
}

/* Theme toggle button */
body.dark #themeToggle {
    color: #e0e0e0 !important;
    border-color: #888;
    background-color: #1f1f1f;
}

/* Improve alert-info contrast for dark mode */
body.dark .alert-info {
    background-color: #005b82 !important;
    color: #d9f1ff !important;
    border-color: #0077a6;
}
