/* Design tokens for the back office (business dashboard and super admin console), light and dark.
   Rules elsewhere in admin/*.css use these instead of raw colours, so a theme is a change in this one file.

   - Bootstrap's own variables (--bs-body-bg, --bs-border-color, ...) are themed by data-bs-theme on <html>, set early by
     /js/theme.js; the dark block below only moves them from Bootstrap's default grey to a bluer, slightly deeper one.
   - The sidebar is dark in both themes, so its colours are tokens but don't change between themes.
   - --console-accent is a *fill* (white text goes on it); --console-accent-text is the accent as *text or an icon* on a
     page surface, which has to be lighter in dark mode. */

.admin-body {
  /* Page and sidebar */
  --console-surface: #f4f6fa;
  --console-sidebar: #111827;
  --console-sidebar-text: #cbd5e1;
  --console-sidebar-muted: #9ca3af;   /* about 7:1 on the sidebar; the old #6b7280 was under 4:1 */
  --console-sidebar-disabled: #6b7280;
  --console-sidebar-hover: rgba(255, 255, 255, .06);
  --console-sidebar-chip: rgba(255, 255, 255, .05);
  --console-sidebar-line: rgba(255, 255, 255, .1);

  /* Brand: business blue; the super admin console overrides these so it's clear whose data is on screen */
  --console-accent: #1b6ec2;
  --console-accent-text: #1b6ec2;
  --console-accent-soft: #e0ecf9;
  --console-label: #60a5fa;
  --console-label-text: #111827;

  /* Focus and elevation */
  --focus-ring: #258cfb;
  --card-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --card-shadow-soft: 0 1px 2px rgba(16, 24, 40, .05);
  --card-shadow-raised: 0 .75rem 1.5rem rgba(16, 24, 40, .08);
  --bottom-nav-shadow: 0 -2px 8px rgba(16, 24, 40, .06);

  /* Warning text on a page surface (amber #f59e0b is for fills and lines only) */
  --warn-text: #b45309;

  /* Charts: the first four are also the payment-method colours */
  --chart-1: #1b6ec2;
  --chart-2: #22a06b;
  --chart-3: #f59e0b;
  --chart-4: #8b5cf6;
  --chart-1-strong: #1861ac;
  --chart-1-fill: rgba(27, 110, 194, .35);
  --chart-compare: #f59e0b;
}

.admin-body.console-platform {
  --console-accent: #4f46e5;
  --console-accent-text: #4f46e5;
  --console-accent-soft: #e5e4fb;
  --console-label: #fbbf24;
}

[data-bs-theme="dark"] {
  --bs-body-bg: #151b26;
  --bs-body-bg-rgb: 21, 27, 38;
  --bs-body-color: #dde3ed;
  --bs-body-color-rgb: 221, 227, 237;
  --bs-secondary-color: rgba(221, 227, 237, .68);
  --bs-tertiary-color: rgba(221, 227, 237, .5);
  --bs-secondary-bg: #202938;
  --bs-secondary-bg-rgb: 32, 41, 56;
  --bs-tertiary-bg: #1b2330;
  --bs-tertiary-bg-rgb: 27, 35, 48;
  --bs-border-color: #2d3748;
  --bs-border-color-translucent: rgba(255, 255, 255, .12);
  --bs-emphasis-color: #fff;
  --bs-link-color: #6cb2f5;
  --bs-link-color-rgb: 108, 178, 245;
  --bs-link-hover-color: #9ccbf8;
  --bs-link-hover-color-rgb: 156, 203, 248;
}

[data-bs-theme="dark"] .admin-body {
  --console-surface: #0d121b;
  --console-sidebar: #0a0e15;
  --console-sidebar-chip: rgba(255, 255, 255, .06);
  --console-accent-text: #7ab8f5;
  --console-accent-soft: #1d3452;
  --console-label: #3b82f6;
  --console-label-text: #fff;
  --focus-ring: #6cb2f5;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --card-shadow-soft: 0 1px 2px rgba(0, 0, 0, .35);
  --card-shadow-raised: 0 .75rem 1.5rem rgba(0, 0, 0, .45);
  --bottom-nav-shadow: 0 -2px 8px rgba(0, 0, 0, .4);
  --warn-text: #fbbf24;
  --chart-1: #4c9be8;
  --chart-2: #34c38f;
  --chart-3: #fbbf24;
  --chart-4: #a78bfa;
  --chart-1-strong: #7ab8f5;
  --chart-1-fill: rgba(76, 155, 232, .4);
  --chart-compare: #fbbf24;
}

[data-bs-theme="dark"] .admin-body.console-platform {
  --console-accent-text: #a5b4fc;
  --console-accent-soft: #29275a;
  --console-label: #d97706;
  --console-label-text: #fff;
}

/* Bootstrap's "light" helpers are fixed light colours; across the back office they mean "a quiet surface", so in dark
   mode they become one. (Any page that used them keeps working without editing the markup.) */
[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-tertiary-bg);
  --bs-table-hover-bg: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .text-bg-light {
  background-color: var(--bs-secondary-bg) !important;
  color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .text-dark {
  color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .border-light {
  border-color: var(--bs-border-color) !important;
}

[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: #fff;
  --bs-btn-hover-bg: #2a3548;
  --bs-btn-hover-border-color: #3a475d;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #2a3548;
  --bs-btn-active-border-color: #3a475d;
  --bs-btn-disabled-color: var(--bs-secondary-color);
  --bs-btn-disabled-bg: var(--bs-secondary-bg);
  --bs-btn-disabled-border-color: var(--bs-border-color);
}

/* Bootstrap's grey outline button is about 3.8:1 on the dark page; "Cancel" is on most dialogs */
[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: #b4bcc9;
  --bs-btn-border-color: #4a5568;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #2a3548;
  --bs-btn-hover-border-color: #5c6a80;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #2a3548;
  --bs-btn-active-border-color: #5c6a80;
  --bs-btn-disabled-color: var(--bs-secondary-color);
  --bs-btn-disabled-border-color: var(--bs-border-color);
}

/* Theme switch in the account menu (see /js/theme.js) */
.theme-switch {
  display: flex;
  gap: .25rem;
  padding: .25rem;
  border-radius: .5rem;
  background-color: var(--bs-tertiary-bg);
}

.theme-switch .btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .25rem .4rem;
  border: 0;
  font-size: .8125rem;
  color: var(--bs-secondary-color);
}

.theme-switch .btn[aria-pressed="true"] {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-weight: 600;
  box-shadow: var(--card-shadow-soft);
}
