/*
 * Light/dark mode.
 *
 * Section 1 styles the topbar toggle (both modes). Section 2 is the dark
 * theme: every rule is scoped to html[data-app-mode='dark'] (set by
 * assets/custom/js/theme-mode.js), so light mode is untouched. The scope
 * prefix also out-ranks the !important rules in main.css / es.css, which
 * share the same importance but have lower specificity.
 *
 * Loaded last in header.php.
 */

/* ── 1. topbar actions: mode toggle + notification bell ─────────────────── */
.topbar-actions {
  position: absolute;
  top: 1rem;
  right: 2rem;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-actions #notification-bell {
  position: static;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 1rem;
  border: 0;
  border-radius: 50px;
  background-color: var(--color-1, #241ef9);
  color: #fff;
  line-height: 1.5;
  cursor: pointer;
  user-select: none;
}

.mode-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.mode-toggle .mode-icon-light {
  display: none;
}

html[data-app-mode='dark'] .mode-toggle .mode-icon-dark {
  display: none;
}

html[data-app-mode='dark'] .mode-toggle .mode-icon-light {
  display: inline;
}

/* ── 2. dark theme ─────────────────────────────────────────────────────── */
html[data-app-mode='dark'] {
  color-scheme: dark;

  --df-bg: #0f1117;
  --df-surface: #1a1d26;
  --df-surface-2: #232733;
  --df-border: #343a48;
  --df-text: #e6e8ee;
  --df-muted: #a3a9b8;
  --df-link-hover: #8c88ff;

  /* Bootstrap 5.2 */
  --bs-body-bg: var(--df-bg);
  --bs-body-color: var(--df-text);
  --bs-border-color: var(--df-border);

  /* FullCalendar 5 */
  --fc-border-color: var(--df-border);
  --fc-page-bg-color: var(--df-surface);
  --fc-neutral-bg-color: var(--df-surface-2);
  --fc-list-event-hover-bg-color: var(--df-surface-2);
  --fc-today-bg-color: rgba(140, 136, 255, 0.15);
}

/* page */
html[data-app-mode='dark'] body {
  background: var(--df-bg) !important;
  background-image: none !important;
  color: var(--df-text);
}

html[data-app-mode='dark'] .page-title,
html[data-app-mode='dark'] h1,
html[data-app-mode='dark'] h2,
html[data-app-mode='dark'] h3,
html[data-app-mode='dark'] h4,
html[data-app-mode='dark'] h5,
html[data-app-mode='dark'] h6 {
  color: var(--df-text);
}

html[data-app-mode='dark'] hr {
  border-color: var(--df-border);
}

html[data-app-mode='dark'] .text-muted {
  color: var(--df-muted) !important;
}

html[data-app-mode='dark'] .text-primary,
html[data-app-mode='dark'] a.text-primary:focus,
html[data-app-mode='dark'] a.text-primary:hover {
  color: var(--df-text) !important;
}

html[data-app-mode='dark'] .bg-white,
html[data-app-mode='dark'] .bg-light {
  background-color: var(--df-surface) !important;
  color: var(--df-text);
}

/* links: es.css hovers to black / the dark brand blue */
html[data-app-mode='dark'] a:not(.btn):hover,
html[data-app-mode='dark'] a:not(.btn):focus,
html[data-app-mode='dark'] .table.w-hover tbody tr:hover td,
html[data-app-mode='dark'] .active .quiz-btn:hover {
  color: var(--df-link-hover) !important;
}

/* mobile hamburger */
html[data-app-mode='dark'] .navbar-toggler-bar {
  background-color: var(--df-text) !important;
}

/* sidebar logo panel: same navy family as the content, a step lighter than
   the cards. The logo PNG is transparent and its "Review and Training Center"
   text is black, so a thin white outline keeps that text readable. */
html[data-app-mode='dark'] .sidebar .logo,
html[data-app-mode='dark'] .off-canvas-sidebar .logo {
  background-color: #2b3040;
}

html[data-app-mode='dark'] .sidebar .logo-img {
  filter:
    drop-shadow(1px 0 0 #fff)
    drop-shadow(-1px 0 0 #fff)
    drop-shadow(0 1px 0 #fff)
    drop-shadow(0 -1px 0 #fff);
}

html[data-app-mode='dark'] .sidebar .profile {
  color: var(--df-text);
}

/* sidebar: already dark; hover "tab" joins the dark page instead of white */
html[data-app-mode='dark'] .sidebar .nav li:hover,
html[data-app-mode='dark'] .sidebar .nav li:hover a,
html[data-app-mode='dark'] .sidebar .nav li:hover p {
  background-color: var(--df-bg) !important;
  color: var(--df-text) !important;
}

/* cards */
html[data-app-mode='dark'] .card {
  background-color: var(--df-surface);
  color: var(--df-text);
  box-shadow: none;
}

html[data-app-mode='dark'] .card-title,
html[data-app-mode='dark'] .card-subtitle,
html[data-app-mode='dark'] .card label,
html[data-app-mode='dark'] .card-header,
html[data-app-mode='dark'] .card-footer {
  color: var(--df-text);
}

html[data-app-mode='dark'] .card-header,
html[data-app-mode='dark'] .card-footer {
  background-color: var(--df-surface-2);
  border-color: var(--df-border);
}

html[data-app-mode='dark'] .card-box,
html[data-app-mode='dark'] .box {
  background: var(--df-surface-2);
  color: var(--df-text);
}

html[data-app-mode='dark'] .box.active,
html[data-app-mode='dark'] .box.inactive,
html[data-app-mode='dark'] .box-dark,
html[data-app-mode='dark'] .box-dark-header,
html[data-app-mode='dark'] .bbox-text,
html[data-app-mode='dark'] .big-small-text .big-text,
html[data-app-mode='dark'] .big-small-text .small-text,
html[data-app-mode='dark'] .vl.mini-video,
html[data-app-mode='dark'] .vl.mini-video.active,
html[data-app-mode='dark'] .vl-watch .bbox-text,
html[data-app-mode='dark'] .vl-watch button:not(.dropdown-item),
html[data-app-mode='dark'] .video-title,
html[data-app-mode='dark'] .video-description,
html[data-app-mode='dark'] .overlay-msg,
html[data-app-mode='dark'] .prog-txt,
html[data-app-mode='dark'] .progressbar-text,
html[data-app-mode='dark'] .komen-text,
html[data-app-mode='dark'] .media-heading,
html[data-app-mode='dark'] .btn-post-comment i,
html[data-app-mode='dark'] .col-form-label,
html[data-app-mode='dark'] .sticky-footer span {
  color: var(--df-text) !important;
}

/* score ring on quiz / daily-elements result pages (quizzes_end.php,
   daily_elements_end.php): the inner disc is hardcoded white there */
html[data-app-mode='dark'] .circle-wrap .inside-circle {
  background: var(--df-surface-2);
  color: var(--df-text);
}

/* forms (main.css / es.css force white fields with !important) */
html[data-app-mode='dark'] input.form-control,
html[data-app-mode='dark'] select.form-control,
html[data-app-mode='dark'] textarea.form-control,
html[data-app-mode='dark'] .form-control,
html[data-app-mode='dark'] .form-select,
html[data-app-mode='dark'] .input-group-text {
  background-color: var(--df-surface-2) !important;
  color: var(--df-text) !important;
}

html[data-app-mode='dark'] .form-control[readonly]:not(.datepicker),
html[data-app-mode='dark'] .form-control[disabled],
html[data-app-mode='dark'] fieldset[disabled] .form-control {
  background-color: #2c3140 !important;
  color: var(--df-muted) !important;
}

html[data-app-mode='dark'] ::placeholder {
  color: var(--df-muted);
}

html[data-app-mode='dark'] option {
  background-color: var(--df-surface-2);
  color: var(--df-text);
}

html[data-app-mode='dark'] .form-check-input:not(:checked) {
  background-color: var(--df-surface-2);
  border-color: var(--df-border);
}

/* tables */
html[data-app-mode='dark'] .table {
  --bs-table-color: var(--df-text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--df-border);
  --bs-table-striped-color: var(--df-text);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.04);
  --bs-table-active-color: var(--df-text);
  --bs-table-active-bg: rgba(255, 255, 255, 0.08);
  --bs-table-hover-color: var(--df-text);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
  color: var(--df-text);
  border-color: var(--df-border);
}

html[data-app-mode='dark'] .table th,
html[data-app-mode='dark'] .table td {
  color: var(--df-text);
  border-color: var(--df-border);
}

html[data-app-mode='dark'] .table thead th,
html[data-app-mode='dark'] .thead-light th,
html[data-app-mode='dark'] .table-light {
  background-color: var(--df-surface-2);
  color: var(--df-text);
}

/* DataTables + pagination */
html[data-app-mode='dark'] .dataTables_wrapper,
html[data-app-mode='dark'] .dataTables_wrapper label,
html[data-app-mode='dark'] .dataTables_wrapper .dataTables_info {
  color: var(--df-text);
}

html[data-app-mode='dark'] .page-link {
  background-color: var(--df-surface-2);
  border-color: var(--df-border);
  color: var(--df-text);
}

html[data-app-mode='dark'] .page-item.disabled .page-link {
  background-color: var(--df-surface);
  color: var(--df-muted);
}

/* modals */
html[data-app-mode='dark'] .modal-content {
  background-color: var(--df-surface);
  color: var(--df-text);
  border-color: var(--df-border);
}

html[data-app-mode='dark'] .modal-header,
html[data-app-mode='dark'] .modal-footer {
  border-color: var(--df-border);
}

html[data-app-mode='dark'] .modal-title,
html[data-app-mode='dark'] .modal-body {
  color: var(--df-text) !important;
}

html[data-app-mode='dark'] .modal-header .btn-close,
html[data-app-mode='dark'] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* dropdowns, list groups, tabs, accordions */
html[data-app-mode='dark'] .dropdown-menu {
  background-color: var(--df-surface-2);
  border-color: var(--df-border);
}

html[data-app-mode='dark'] .dropdown-item {
  color: var(--df-text);
}

html[data-app-mode='dark'] .dropdown-item:hover,
html[data-app-mode='dark'] .dropdown-item:focus {
  background-color: var(--df-border);
  color: var(--df-text);
}

html[data-app-mode='dark'] .list-group-item {
  background-color: var(--df-surface);
  border-color: var(--df-border);
  color: var(--df-text);
}

html[data-app-mode='dark'] .nav-tabs {
  border-color: var(--df-border);
}

html[data-app-mode='dark'] .nav-tabs .nav-link.active {
  background-color: var(--df-surface);
  border-color: var(--df-border) var(--df-border) var(--df-surface);
  color: var(--df-text);
}

html[data-app-mode='dark'] .accordion {
  --bs-accordion-bg: var(--df-surface);
  --bs-accordion-color: var(--df-text);
  --bs-accordion-border-color: var(--df-border);
  --bs-accordion-btn-color: var(--df-text);
  --bs-accordion-active-bg: var(--df-surface-2);
  --bs-accordion-active-color: var(--df-text);
}

/* notifications + popovers */
html[data-app-mode='dark'] .notification-list {
  background-color: var(--df-surface);
  color: var(--df-text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

html[data-app-mode='dark'] .notification {
  background-color: var(--df-surface-2);
}

html[data-app-mode='dark'] .popovertext {
  background-color: var(--df-surface-2) !important;
  color: var(--df-text);
}

/* FullCalendar hardcodes a few colors outside its variables */
html[data-app-mode='dark'] .fc,
html[data-app-mode='dark'] .fc .fc-toolbar-title,
html[data-app-mode='dark'] .fc .fc-col-header-cell-cushion,
html[data-app-mode='dark'] .fc .fc-daygrid-day-number {
  color: var(--df-text);
}

html[data-app-mode='dark'] .fc-theme-standard td,
html[data-app-mode='dark'] .fc-theme-standard th,
html[data-app-mode='dark'] .fc-theme-standard .fc-scrollgrid {
  border-color: var(--df-border);
}
