/* Dark mode adjustments for Bootstrap classes that keep fixed light colors.
 * Color tokens for the app's own styles are in theme-tokens.css. */

[data-bs-theme="dark"] .bg-white {
  background-color: var(--bs-body-bg) !important;
}

[data-bs-theme="dark"] .bg-light {
  background-color: var(--bs-tertiary-bg) !important;
}

[data-bs-theme="dark"] .text-dark:not(.bg-warning):not(.bg-info):not(.btn-warning):not(.btn-info) {
  color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .table-light {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: var(--bs-tertiary-bg);
  --bs-table-border-color: var(--bs-border-color);
  --bs-table-striped-bg: var(--bs-secondary-bg);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-hover-bg: var(--bs-secondary-bg);
  --bs-table-hover-color: var(--bs-body-color);
}

[data-bs-theme="dark"] .table-primary {
  --bs-table-color: var(--bs-primary-text-emphasis);
  --bs-table-bg: var(--bs-primary-bg-subtle);
  --bs-table-border-color: var(--bs-primary-border-subtle);
  --bs-table-striped-bg: var(--bs-primary-bg-subtle);
  --bs-table-striped-color: var(--bs-primary-text-emphasis);
  --bs-table-hover-bg: var(--bs-primary-bg-subtle);
  --bs-table-hover-color: var(--bs-primary-text-emphasis);
}

[data-bs-theme="dark"] .table-warning {
  --bs-table-color: var(--bs-warning-text-emphasis);
  --bs-table-bg: var(--bs-warning-bg-subtle);
  --bs-table-border-color: var(--bs-warning-border-subtle);
  --bs-table-striped-bg: var(--bs-warning-bg-subtle);
  --bs-table-striped-color: var(--bs-warning-text-emphasis);
  --bs-table-hover-bg: var(--bs-warning-bg-subtle);
  --bs-table-hover-color: var(--bs-warning-text-emphasis);
}

[data-bs-theme="dark"] .btn-light {
  --bs-btn-color: var(--bs-body-color);
  --bs-btn-bg: var(--bs-secondary-bg);
  --bs-btn-border-color: var(--bs-border-color);
  --bs-btn-hover-color: var(--bs-emphasis-color);
  --bs-btn-hover-bg: var(--bs-tertiary-bg);
  --bs-btn-hover-border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .alert-light {
  --bs-alert-color: var(--bs-body-color);
  --bs-alert-bg: var(--bs-tertiary-bg);
  --bs-alert-border-color: var(--bs-border-color);
}

/* Black logos on transparent backgrounds */
[data-bs-theme="dark"] img[src*="nuitee_black"],
[data-bs-theme="dark"] img[src*="airplane.png"] {
  filter: invert(1);
}

/* FlightHub wordmark: black "flight" turns light, hue-rotate keeps "hub" blue */
[data-bs-theme="dark"] img.fh-wordmark {
  filter: invert(1) hue-rotate(180deg);
}

/* Brand lockup (header and sign-in): nuitée | flighthub at the same height, on the same baseline.
 * nuitée's letters end at its image's bottom; flighthub's baseline is 80% down its image (the "g"
 * hangs below), so the wordmark drops by the rest. */
.fh-brand {
  display: flex;
  align-items: flex-end;
}

.fh-brand img {
  height: 28px;
  width: auto;
}

.fh-brand h1 {
  display: flex;
}

.fh-brand .fh-wordmark {
  margin-bottom: -5px;
}

.fh-brand-divider {
  align-self: center;
  width: 1px;
  height: 22px;
  margin: 0 14px;
  background-color: var(--bs-border-color);
}

.theme-toggle-btn i {
  width: 1em;
}

[data-bs-theme="dark"] .text-bg-light {
  color: var(--bs-body-color) !important;
  background-color: var(--bs-tertiary-bg) !important;
}

/* Bootstrap keeps #6c757d for these in dark mode, which is too dim on dark surfaces */
[data-bs-theme="dark"] .text-secondary {
  color: var(--bs-secondary-color) !important;
}

[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: #adb5bd;
  --bs-btn-border-color: #6c757d;
}

/* Bootstrap keeps the light-mode #0d6efd / #dc3545 / #198754 for text in dark mode
 * (contrast ~3.4 on dark surfaces); use its own dark-mode emphasis shades instead. */
[data-bs-theme="dark"] .text-primary {
  color: var(--bs-primary-text-emphasis) !important;
}

[data-bs-theme="dark"] .text-danger {
  color: var(--bs-danger-text-emphasis) !important;
}

[data-bs-theme="dark"] .text-success {
  color: var(--bs-success-text-emphasis) !important;
}

[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: var(--bs-primary-text-emphasis);
}

[data-bs-theme="dark"] .btn-outline-danger {
  --bs-btn-color: var(--bs-danger-text-emphasis);
}

[data-bs-theme="dark"] .btn-outline-success {
  --bs-btn-color: var(--bs-success-text-emphasis);
}

/* Solid yellow/cyan cards (e.g. Offer Expiration): light card text lands on a bright
 * background in dark mode; render them as Bootstrap's subtle warning/info surface. */
[data-bs-theme="dark"] .card.bg-warning {
  background-color: var(--bs-warning-bg-subtle) !important;
  border-color: var(--bs-warning-border-subtle) !important;
  color: var(--bs-warning-text-emphasis);
}

[data-bs-theme="dark"] .card.bg-info {
  background-color: var(--bs-info-bg-subtle) !important;
  border-color: var(--bs-info-border-subtle) !important;
  color: var(--bs-info-text-emphasis);
}

[data-bs-theme="dark"] .card.bg-warning .text-muted,
[data-bs-theme="dark"] .card.bg-info .text-muted {
  color: inherit !important;
  opacity: 0.85;
}

/* White text on light badge/bar colors (yellow, cyan, teal, orange, pink): dark text,
 * as Bootstrap's text-bg-warning / text-bg-info do. The attribute selectors cover
 * badges and bars whose background is set inline by the admin metrics JS. */
[data-bs-theme="dark"] :is(.badge, .popup-tab-status-badge).bg-warning:not(.text-dark),
[data-bs-theme="dark"] :is(.badge, .popup-tab-status-badge).bg-info:not(.text-dark),
[data-bs-theme="dark"] :is(.badge, .progress-bar):is(
  [style*="#ffc107"], [style*="#0dcaf0"], [style*="#17a2b8"],
  [style*="#20c997"], [style*="#fd7e14"], [style*="#e35d6a"]) {
  color: #000 !important;
}

/* Provider logos (class provider-logo, data-provider = the provider code) in dark mode.
 * Sabre, Travelport and FlightHub are black wordmarks: drawn light (invert flips lightness,
 * hue-rotate keeps the hue, so FlightHub's blue "hub" stays blue and Travelport's white "T" turns
 * dark so its icon stays readable). Atlas and Travelfusion keep their colours, brightened so their
 * blues read on the dark background (inverting would turn Travelfusion's light "travel" dark). Any
 * provider without a rule here sits on a light chip; content-box keeps each logo's own size and the
 * chip adds its padding around it. */
[data-bs-theme="dark"] img.provider-logo:not([data-provider="SABRE"], [data-provider="TRAVELPORT"], [data-provider="FLIGHTHUB"], [data-provider="ATLAS"], [data-provider="TRAVELFUSION"]) {
  box-sizing: content-box;
  padding: 3px 6px;
  border-radius: 6px;
  background-color: #f8f9fa;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] img.provider-logo:is([data-provider="SABRE"], [data-provider="TRAVELPORT"], [data-provider="FLIGHTHUB"]) {
  filter: invert(1) hue-rotate(180deg);
}

[data-bs-theme="dark"] img.provider-logo[data-provider="ATLAS"] {
  filter: brightness(1.5);
}

[data-bs-theme="dark"] img.provider-logo[data-provider="TRAVELFUSION"] {
  filter: brightness(1.6);
}

/* Leg-by-leg provider circles (main.css .ls-mark): Travelport's near-black circle would
 * disappear on a dark card, so it is drawn light, like its logo above. */
[data-bs-theme="dark"] .ls-mark[data-provider="TRAVELPORT"] {
  --ls-mark-bg: #e2e8f0;
  --ls-mark-fg: #101820;
}

/* Leaflet map controls (benchmark map) */
[data-bs-theme="dark"] .leaflet-container {
  background: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] .leaflet-bar a {
  background-color: var(--bs-secondary-bg);
  border-bottom-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] .leaflet-bar a.leaflet-disabled {
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
}

[data-bs-theme="dark"] .leaflet-container .leaflet-control-attribution {
  background: rgba(33, 37, 41, 0.8);
  color: var(--bs-secondary-color);
}
