/* Light theme is intentionally close to Frappe's own native palette (white
   navbar/sidebar, dark text, one blue accent) instead of a custom dark
   scheme — a custom dark navbar/sidebar fighting Frappe's light-mode
   defaults (e.g. its --sidebar-active-color being stark white) was the root
   cause of the invisible-text bugs found this session. Keeping our colors
   close to what Frappe already assumes means far less to override, and far
   less to keep fighting on every future Frappe upgrade. */
:root {
  --brand-primary: #007ad9;
  --brand-accent: #007ad9;
  --brand-link: #007ad9;
  --brand-navbar-bg: #ffffff;
  --brand-navbar-color: #1e293b;
  --brand-sidebar-bg: #ffffff;
  --brand-sidebar-color: #1e293b;
  --brand-dark-primary: #3b82f6;
  --brand-dark-navbar-bg: #111827;
  --brand-dark-navbar-color: #f9fafb;
  --brand-dark-sidebar-bg: #0f172a;
  --brand-dark-sidebar-color: #d1d5db;
}

html[data-theme="light"],
html[data-theme="light"] body,
html:not([data-theme]) {
  --navbar-bg: var(--brand-navbar-bg, #ffffff);
  --navbar-text-color: var(--brand-navbar-color, #1e293b);
  --sidebar-bg: var(--brand-sidebar-bg, #ffffff);
  --sidebar-text-color: var(--brand-sidebar-color, #1e293b);
  --primary: var(--brand-primary, #007ad9);
  --primary-color: var(--brand-primary, #007ad9);
  --primary-light: var(--brand-primary, #007ad9);
  --awesomplete-hover-bg: var(--brand-primary, #007ad9);
  /* Subtle blue-tinted highlight for the selected/hovered sidebar item —
     visible against the white sidebar without needing light text. */
  --sidebar-active-color: rgba(0, 122, 217, 0.08);
  --sidebar-hover-color: rgba(0, 122, 217, 0.04);
}

html[data-theme="dark"] {
  --navbar-bg: var(--brand-dark-navbar-bg, #111827);
  --navbar-text-color: var(--brand-dark-navbar-color, #f9fafb);
  --sidebar-bg: var(--brand-dark-sidebar-bg, #0f172a);
  --sidebar-text-color: var(--brand-dark-sidebar-color, #d1d5db);
  --primary: var(--brand-dark-primary, #3b82f6);
  --primary-color: var(--brand-dark-primary, #3b82f6);
  --primary-light: var(--brand-dark-primary, #3b82f6);
  --awesomplete-hover-bg: var(--brand-dark-primary, #3b82f6);
  --sidebar-active-color: rgba(255, 255, 255, 0.12);
  --sidebar-hover-color: rgba(255, 255, 255, 0.06);
}

.navbar {
  background-color: var(--navbar-bg) !important;
  border-bottom-color: var(--navbar-bg) !important;
}

.navbar .navbar-nav > li > a,
.navbar .navbar-nav .nav-link,
.navbar .navbar-header .navbar-home,
.navbar .navbar-brand,
.navbar .navbar-brand .navbar-home {
  color: var(--navbar-text-color) !important;
}

.navbar .navbar-nav > li > a:hover,
.navbar .navbar-nav .nav-link:hover,
.navbar .navbar-header .navbar-home:hover {
  color: var(--navbar-text-color) !important;
  opacity: 0.85;
}

.sidebar-menu,
.desk-sidebar,
.layout-side-section,
.layout-side-section .sidebar-menu,
.body-sidebar,
.body-sidebar-container .body-sidebar {
  background-color: var(--sidebar-bg) !important;
}

.sidebar-menu a,
.desk-sidebar a,
.sidebar-item-label,
.sidebar-section .sidebar-item-label,
.layout-side-section .sidebar-item-label,
.layout-side-section a.sidebar-link,
.body-sidebar a,
.body-sidebar .sidebar-item-label,
.body-sidebar .sidebar-item,
.body-sidebar .sidebar-link {
  color: var(--sidebar-text-color) !important;
}

.sidebar-menu a:hover,
.desk-sidebar a:hover,
.sidebar-item-label:hover,
.body-sidebar a:hover,
.body-sidebar .sidebar-item-label:hover {
  color: var(--sidebar-text-color) !important;
  opacity: 0.85;
}

.btn-primary,
.control-input .btn-primary,
.page-primary-action,
button[data-action="primary"],
.primary-action,
[data-theme] .btn-primary {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
}

.btn-primary:hover,
.btn-primary:focus,
.page-primary-action:hover {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  filter: brightness(0.92);
}

a,
a.text-muted,
[data-theme] a:not(.btn):not(.nav-link) {
  color: var(--brand-link, #007ad9);
}

a:hover {
  color: var(--brand-link, #007ad9);
  opacity: 0.85;
}

/* Awesomplete-style dropdowns (global search/command palette, Link-field
   autocomplete suggestions) rely on Frappe core's own contrast handling:
   it sets `color: var(--text-color)` on every result row, selected or not,
   so text stays readable against --awesomplete-hover-bg (set to our brand
   blue above) when a row is hovered/selected. Our blanket `a { color:
   var(--brand-link) }` rule above was overriding that back to the same
   blue as the selected row's background — link text became invisible
   there, leaving only the yellow fuzzy-match <mark> boxes visible.
   Confirmed live: typing in the global search (Ctrl+K) made the
   highlighted/selected result unreadable. Let Frappe's own color win
   inside these dropdowns instead of forcing brand blue. */
.awesomplete a,
.awesomplete a:hover {
  color: inherit !important;
}

.widget .widget-head .widget-title {
  color: var(--brand-primary, #007ad9);
}
