/* ====================================
   DARK MODE OVERRIDE - CSS
   Ensures dark mode is applied to all elements
   ==================================== */

:root {
  color-scheme: dark;
  --bs-body-bg: #0f172a;
  --bs-body-color: #e2e8f0;
}

html,
html[data-bs-theme="dark"],
html.dark-mode {
  --bs-body-bg: #0f172a;
  --bs-body-color: #e2e8f0;
  --bs-border-color: #1e293b;
  --bs-link-color: #818cf8;
  --bs-link-hover-color: #a5b4fc;
  color-scheme: dark;
  background-color: #0f172a !important;
}

body,
body[data-bs-theme="dark"],
body.dark-mode {
  background-color: #0f172a !important;
  color: #e2e8f0 !important;
  --bs-body-bg: #0f172a;
  --bs-body-color: #e2e8f0;
}

/* Force dark backgrounds */
*[data-bs-theme="dark"],
.dark-mode {
  --bs-body-bg: #0f172a !important;
  --bs-body-color: #e2e8f0 !important;
  --bs-border-color: #1e293b !important;
}

/* Prevent light backgrounds */
.bg-light,
.bg-white,
.bg-body {
  background-color: #1e293b !important;
}

/* Ensure text is readable */
p, span, div, a, li, h1, h2, h3, h4, h5, h6 {
  color: inherit;
}

/* Tables */
table {
  background-color: #1e293b !important;
}

thead {
  background-color: rgba(99, 102, 241, 0.1) !important;
}

tbody tr:hover {
  background-color: rgba(99, 102, 241, 0.08) !important;
}

/* Forms stay dark */
.form-control,
.form-select,
textarea,
input {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}

.form-control:focus,
.form-select:focus,
textarea:focus,
input:focus {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.25) !important;
}

/* Modals */
.modal-content {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
}

/* Alerts */
.alert {
  border-color: #334155 !important;
}

/* Cards remain dark */
.card {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}

/* Navigation */
nav {
  background-color: rgba(15, 23, 42, 0.95) !important;
}

.navbar {
  background-color: rgba(15, 23, 42, 0.95) !important;
}

.nav-link {
  color: #cbd5e1 !important;
}

.nav-link:hover,
.nav-link.active {
  color: #818cf8 !important;
}

/* Dropdown menus */
.dropdown-menu {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}

.dropdown-item {
  color: #cbd5e1 !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: rgba(99, 102, 241, 0.15) !important;
  color: #818cf8 !important;
}

/* Buttons */
.btn-outline-primary {
  color: #818cf8 !important;
  border-color: #818cf8 !important;
}

.btn-outline-primary:hover {
  background-color: #6366f1 !important;
  border-color: #6366f1 !important;
  color: #ffffff !important;
}

/* Lists */
.list-group-item {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

.list-group-item.active {
  background-color: #6366f1 !important;
  border-color: #6366f1 !important;
}

/* Footer */
footer {
  background-color: rgba(15, 23, 42, 0.95) !important;
  color: #cbd5e1 !important;
}

/* Badges */
.badge-success,
.badge-danger,
.badge-warning,
.badge-info {
  background-color: rgba(99, 102, 241, 0.2) !important;
  color: #c7d2fe !important;
}

/* Pagination */
.pagination .page-link {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

.pagination .page-link:hover {
  background-color: rgba(99, 102, 241, 0.15) !important;
  border-color: #6366f1 !important;
  color: #818cf8 !important;
}

.pagination .page-link.active {
  background-color: #6366f1 !important;
  border-color: #6366f1 !important;
}

/* Borders */
.border {
  border-color: #334155 !important;
}

.border-primary {
  border-color: rgba(99, 102, 241, 0.3) !important;
}

/* Spinners */
.spinner-border {
  border-color: rgba(99, 102, 241, 0.2) !important;
  border-right-color: #6366f1 !important;
}

/* Code blocks */
code,
pre {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1e293b;
}

::-webkit-scrollbar-thumb {
  background: #6366f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #818cf8;
}

/* Selection color */
::selection {
  background-color: #6366f1;
  color: #ffffff;
}

::-moz-selection {
  background-color: #6366f1;
  color: #ffffff;
}

/* Links */
a {
  color: #818cf8;
}

a:hover {
  color: #a5b4fc;
}

/* Text utilities */
.text-muted {
  color: #94a3b8 !important;
}

.text-secondary {
  color: #cbd5e1 !important;
}

.text-light {
  color: #e2e8f0 !important;
}

.text-white {
  color: #e2e8f0 !important;
}

/* Ensure accent color */
[data-bs-theme="dark"],
.dark-mode {
  accent-color: #6366f1;
}

/* Focus states */
*:focus {
  outline-color: #6366f1;
}

*:focus-visible {
  outline-color: #6366f1;
}

/* Inputs with dark background */
input,
textarea,
select {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
}

input::placeholder,
textarea::placeholder {
  color: #64748b !important;
  opacity: 1;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  appearance: textfield;
  -moz-appearance: textfield;
}

/* Tooltips */
.tooltip-inner {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
}

/* Popover */
.popover {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}

.popover-header {
  background-color: rgba(99, 102, 241, 0.1) !important;
  border-color: #334155 !important;
}

/* Ensure everything with explicit light theme is changed */
[data-mdb-theme="light"] {
  --mdb-body-bg: #0f172a;
  --mdb-body-color: #e2e8f0;
}
