/* WG branding for the scheduler, in light and dark themes.
 *
 * Adapted from wg_branding.css (a Bootstrap 5.3 theme). This app is built with Tailwind, so instead of
 * loading Bootstrap (whose .badge/.border/.rounded/.table classes clash with Tailwind's) we take its
 * design tokens and components:
 *   - Tailwind's palette, font, radius and shadow are mapped to the brand in base.html
 *     (tailwind.config), through the --c-* theme tokens below so they switch with the theme
 *   - this file adds the brand's components: navbar, buttons, form fields, focus ring, chips
 * The theme is chosen by data-theme on <html> (set before first paint in base.html): the viewer's
 * saved choice, else the device's light/dark setting.
 */
:root {
  --wg-blue: #0f61fd;
  --wg-blue-hover: #0251e6;
  --wg-blue-active: #0c4eca;
  --wg-charcoal: #383838;
  --wg-charcoal-hover: #262626;
  --wg-disabled-bg: #c6c6c6;
  --wg-disabled-ink: #8d8d8d;
}

/* ---------------------------------------------------------------- Theme tokens
 * Light is the WG brand as supplied; dark keeps the brand blue on a black base (Carbon-style
 * greys). --c-* are RGB triplets behind the Tailwind palette in base.html; the rest are used
 * directly by brand.css / app.css and read by the charts. */
:root {
  color-scheme: light;
  --c-n-50: 245 245 245;
  --c-n-100: 240 240 240;
  --c-n-200: 224 224 224;
  --c-n-300: 198 198 198;
  --c-n-400: 168 168 168;
  --c-n-500: 111 111 111;
  --c-n-600: 82 82 82;
  --c-n-700: 57 57 57;
  --c-n-800: 38 38 38;
  --c-n-900: 22 22 22;
  --c-n-950: 13 13 13;
  --c-blue-50: 237 243 255;
  --c-blue-100: 207 226 255;
  --c-blue-200: 158 197 254;
  --c-blue-300: 120 169 255;
  --c-blue-400: 69 137 255;
  --c-blue-500: 38 112 253;
  --c-blue-600: 15 97 253;
  --c-blue-700: 15 97 253;
  --c-blue-800: 2 81 230;
  --c-blue-900: 12 78 202;
  --c-blue-950: 5 44 101;
  --c-red-50: 255 241 241;
  --c-red-100: 248 215 218;
  --c-red-200: 241 174 181;
  --c-red-300: 255 131 137;
  --c-red-400: 250 77 86;
  --c-red-500: 218 30 40;
  --c-red-600: 218 30 40;
  --c-red-700: 218 30 40;
  --c-red-800: 162 25 31;
  --c-red-900: 88 21 28;
  --c-red-950: 45 7 9;
  --c-green-50: 222 251 230;
  --c-green-100: 209 231 221;
  --c-green-200: 163 207 187;
  --c-green-300: 66 190 101;
  --c-green-400: 36 161 72;
  --c-green-500: 36 161 72;
  --c-green-600: 25 128 56;
  --c-green-700: 25 128 56;
  --c-green-800: 14 96 39;
  --c-green-900: 10 54 34;
  --c-green-950: 2 45 13;
  --c-yellow-50: 255 248 225;
  --c-yellow-100: 255 243 205;
  --c-yellow-200: 255 230 156;
  --c-yellow-300: 253 209 58;
  --c-yellow-400: 253 209 58;
  --c-yellow-500: 241 194 27;
  --c-yellow-600: 210 161 6;
  --c-yellow-700: 142 106 0;
  --c-yellow-800: 102 77 3;
  --c-yellow-900: 72 55 0;
  --c-yellow-950: 43 32 0;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --page: #f5f5f5;
  --line: #e0e0e0;
  --line-strong: #c6c6c6;
  --line-soft: #f0f0f0;
  --hover: #f7f7f7;
  --hover-strong: #e8e8e8;
  --ink: #161616;
  --ink-2: #393939;
  --ink-3: #525252;
  --muted: #6f6f6f;
  --muted-2: #8d8d8d;
  --faint: #a8a8a8;
  --link: #0f61fd;
  --tint-blue: #edf3ff;
  --tint-blue-soft: #f2f6ff;
  --sel: #cfe2ff;
  --night-cell: #e0e0e0;
  --weekend-cell: #f0f0f0;
  --night-stripe: rgba(0, 0, 0, .045);
  --field: #f5f5f5;
  --field-hover: #f0f0f0;
  --field-border: #e0e0e0;
  --brand-ink: #223845;
  --chip-bg: #eeeeee;
  --chip-ink: #434343;
  --tooltip-bg: #161616;
  --tooltip-ink: #f7f7f7;
  --tooltip-key: #a8a8a8;
  --tooltip-alert: #ffb3b8;
  --shadow: rgba(0, 0, 0, .075);
  --focus-gap: #ffffff;
  --bar-scheduled: #2a78d6;
  --bar-manual: #6250d6;
  --bar-late: #e34948;
  --bar-other: #9ca3af;
  --bar-lock-ring: #0b0b0b;
  --now-line: #eb6834;
  --hm-u1: #cde2fb;
  --hm-u2: #9ec5f4;
  --hm-u3: #6da7ec;
  --hm-u4: #2a78d6;
  --hm-u5: #104281;
  --hm-u1-ink: #0b0b0b;
  --hm-u2-ink: #0b0b0b;
  --hm-u3-ink: #0b0b0b;
  --hm-u4-ink: #ffffff;
  --hm-u5-ink: #ffffff;
  --hm-off-a: #f0f0f0;
  --hm-off-b: #e0e0e0;
  --badge-bg: #eeeeee;
  --badge-ink: #434343;
  --badge-sched-bg: #cfe2ff;
  --badge-sched-ink: #052c65;
  --badge-manual-bg: #ebe8fb;
  --badge-manual-ink: #3c2f99;
  --badge-warn-bg: #fff3cd;
  --badge-warn-ink: #664d03;
  --badge-late-bg: #f8d7da;
  --badge-late-ink: #58151c;
  --badge-brk-bg: #ffe2cc;
  --badge-brk-ink: #6b2a00;
  --chart-ink: #525252;
  --chart-muted: #6f6f6f;
  --chart-grid: #e0e0e0;
  --chart-axis: #c6c6c6;
  --chart-target: #161616;
  --chart-capacity: #8d8d8d;
  --chart-blue: #2a78d6;
  --chart-orange: #eb6834;
  --chart-p1: #104281;
  --chart-p2: #256abf;
  --chart-p3: #5598e7;
  --chart-p4: #86b6ef;
  --chart-pnone: #c6c6c6;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --c-n-50: 0 0 0;
  --c-n-100: 38 38 38;
  --c-n-200: 57 57 57;
  --c-n-300: 82 82 82;
  --c-n-400: 141 141 141;
  --c-n-500: 168 168 168;
  --c-n-600: 198 198 198;
  --c-n-700: 224 224 224;
  --c-n-800: 240 240 240;
  --c-n-900: 244 244 244;
  --c-n-950: 255 255 255;
  --c-blue-50: 11 26 51;
  --c-blue-100: 16 42 76;
  --c-blue-200: 28 66 128;
  --c-blue-300: 61 111 196;
  --c-blue-400: 69 137 255;
  --c-blue-500: 69 137 255;
  --c-blue-600: 15 97 253;
  --c-blue-700: 69 137 255;
  --c-blue-800: 120 169 255;
  --c-blue-900: 166 200 255;
  --c-blue-950: 208 226 255;
  --c-red-50: 45 7 9;
  --c-red-100: 82 4 8;
  --c-red-200: 117 14 19;
  --c-red-300: 162 25 31;
  --c-red-400: 250 77 86;
  --c-red-500: 250 77 86;
  --c-red-600: 218 30 40;
  --c-red-700: 255 131 137;
  --c-red-800: 255 179 184;
  --c-red-900: 255 215 217;
  --c-red-950: 255 241 241;
  --c-green-50: 7 25 8;
  --c-green-100: 2 45 13;
  --c-green-200: 4 67 23;
  --c-green-300: 14 96 39;
  --c-green-400: 36 161 72;
  --c-green-500: 36 161 72;
  --c-green-600: 25 128 56;
  --c-green-700: 66 190 101;
  --c-green-800: 111 220 140;
  --c-green-900: 167 240 186;
  --c-green-950: 222 251 230;
  --c-yellow-50: 28 21 0;
  --c-yellow-100: 48 36 0;
  --c-yellow-200: 72 55 0;
  --c-yellow-300: 104 78 0;
  --c-yellow-400: 210 161 6;
  --c-yellow-500: 241 194 27;
  --c-yellow-600: 241 194 27;
  --c-yellow-700: 241 194 27;
  --c-yellow-800: 253 220 105;
  --c-yellow-900: 252 244 214;
  --c-yellow-950: 255 248 225;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --page: #000000;
  --line: #393939;
  --line-strong: #525252;
  --line-soft: #262626;
  --hover: #262626;
  --hover-strong: #333333;
  --ink: #f4f4f4;
  --ink-2: #e0e0e0;
  --ink-3: #c6c6c6;
  --muted: #a8a8a8;
  --muted-2: #8d8d8d;
  --faint: #6f6f6f;
  --link: #4589ff;
  --tint-blue: #0b1a33;
  --tint-blue-soft: #0d1626;
  --sel: #102a4c;
  --night-cell: #262626;
  --weekend-cell: #1f1f1f;
  --night-stripe: rgba(255, 255, 255, .04);
  --field: #262626;
  --field-hover: #333333;
  --field-border: #525252;
  --brand-ink: #f4f4f4;
  --chip-bg: #393939;
  --chip-ink: #e0e0e0;
  --tooltip-bg: #f4f4f4;
  --tooltip-ink: #161616;
  --tooltip-key: #8d8d8d;
  --tooltip-alert: #a2191f;
  --shadow: rgba(0, 0, 0, .6);
  --focus-gap: #000000;
  --bar-scheduled: #3987e5;
  --bar-manual: #9085e9;
  --bar-late: #e66767;
  --bar-other: #6f6f6f;
  --bar-lock-ring: #f4f4f4;
  --now-line: #d95926;
  --hm-u1: #0d366b;
  --hm-u2: #184f95;
  --hm-u3: #256abf;
  --hm-u4: #5598e7;
  --hm-u5: #b7d3f6;
  --hm-u1-ink: #f0f0f0;
  --hm-u2-ink: #ffffff;
  --hm-u3-ink: #ffffff;
  --hm-u4-ink: #000000;
  --hm-u5-ink: #000000;
  --hm-off-a: #1a1a1a;
  --hm-off-b: #2c2c2c;
  --badge-bg: #333333;
  --badge-ink: #e0e0e0;
  --badge-sched-bg: #102a4c;
  --badge-sched-ink: #a6c8ff;
  --badge-manual-bg: #272052;
  --badge-manual-ink: #c4bdf5;
  --badge-warn-bg: #302400;
  --badge-warn-ink: #fddc69;
  --badge-late-bg: #520408;
  --badge-late-ink: #ffb3b8;
  --badge-brk-bg: #4a2000;
  --badge-brk-ink: #ffc59e;
  --chart-ink: #c6c6c6;
  --chart-muted: #8d8d8d;
  --chart-grid: #2c2c2a;
  --chart-axis: #383835;
  --chart-target: #f0f0f0;
  --chart-capacity: #8d8d8d;
  --chart-blue: #3987e5;
  --chart-orange: #d95926;
  --chart-p1: #b7d3f6;
  --chart-p2: #6da7ec;
  --chart-p3: #3987e5;
  --chart-p4: #1c5cab;
  --chart-pnone: #525252;
}

body { background-color: var(--page); color: var(--ink); }
a:not([class*="btn"]) { text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Dark mode: Tailwind's bg-white panels sit on the dark surface; "bg-slate-900 text-white" chips
 * (selected toggles, info toasts) invert to a light chip with dark text. */
:root[data-theme="dark"] .bg-white { background-color: var(--surface); }
:root[data-theme="dark"] .bg-slate-900.text-white,
:root[data-theme="dark"] .bg-slate-900 .text-white { color: #000; }
:root[data-theme="dark"] .shadow, :root[data-theme="dark"] .shadow-sm {
  box-shadow: 0 0 0 1px var(--line), 0 .125rem .25rem var(--shadow);
}

/* ---------------------------------------------------------------- Navbar (.wg-navbar) */
.wg-navbar { background: var(--surface); box-shadow: 0 .125rem .25rem var(--shadow); position: relative; z-index: 40; }
:root[data-theme="dark"] .wg-navbar { box-shadow: 0 1px 0 var(--line); }
.wg-brand { display: inline-flex; align-items: center; gap: .6rem; font-size: 1.1rem; font-weight: 700;
  color: var(--brand-ink); white-space: nowrap; }
.wg-brand .mark-2 { fill: var(--brand-ink); }
.wg-nav-link { display: inline-flex; align-items: center; color: var(--ink); font-weight: 600; font-size: .9rem;
  border-bottom: 2.5px solid transparent; border-top: 2.5px solid transparent; transition: color .15s; }
.wg-nav-link:hover { color: var(--link); }
.wg-nav-link.active { color: var(--link); border-bottom-color: #0f61fd; }
.wg-chip { font-size: .75rem; font-weight: 600; padding: .2rem .55rem; border-radius: .375rem;
  background: var(--chip-bg); color: var(--chip-ink); }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem;
  color: var(--ink); border-radius: 9999px; }
.theme-toggle:hover { background: var(--hover); color: var(--link); }
.theme-toggle .icon-sun { display: none; }

/* Navbar layout: brand, page links, then (right) asset, theme and account menu. Below 1200 px the page
   links fold into a menu behind the ☰ button; the right-hand side stays in the bar. */
.wg-nav-inner { display: flex; align-items: center; gap: 2rem; min-height: 4rem; }
.nav-menu { display: flex; align-self: stretch; min-width: 0; }
.nav-links { display: flex; gap: 1.5rem; align-self: stretch; }
.wg-nav-link { white-space: nowrap; }
.nav-end { margin-left: auto; display: flex; align-items: center; gap: .75rem; min-width: 0; }
.nav-toggle { display: none; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; color: var(--ink); }
.nav-toggle:hover { background: var(--hover); }
.asset-switch { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: .875rem; font-weight: 600;
  color: var(--ink); padding-right: .75rem; border-right: 1px solid var(--line); }
.asset-switch svg { flex: none; color: var(--ink-3); }
.asset-switch .asset-link, .asset-switch .asset-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 16rem; color: inherit; text-decoration: none; }
.asset-switch .asset-link:hover { color: var(--link); text-decoration: underline; }
/* Account menu */
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem;
  border-radius: 9999px; color: var(--ink); background: var(--chip-bg); }
.user-btn:hover, .user-btn[aria-expanded="true"] { color: var(--link); box-shadow: 0 0 0 2px #0f61fd; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 15rem; max-width: calc(100vw - 2rem);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: 0 6px 16px rgba(0, 0, 0, .2); }
.user-pop[hidden] { display: none; }
.user-pop-head { padding: .75rem 1rem; border-bottom: 1px solid var(--line); display: grid; gap: .4rem; justify-items: start; }
.user-pop-email { font-weight: 600; font-size: .875rem; overflow-wrap: anywhere; }
.user-pop-item { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .65rem 1rem; font-size: .875rem;
  font-weight: 600; text-align: left; color: var(--ink); }
.user-pop-item:hover { background: var(--hover); color: var(--link); }
/* Footer (scrolls with the page) */
.app-footer { border-top: 1px solid var(--line); color: var(--ink-3); font-size: .8rem; background: var(--surface); }
@media (max-width: 1199px) {
  .wg-nav-inner { gap: .75rem; flex-wrap: wrap; }
  .nav-toggle { display: inline-flex; }
  .nav-menu { display: none; order: 3; flex-basis: 100%; flex-direction: column; padding: 0 0 .75rem; }
  .nav-menu.open { display: flex; }
  .nav-links { flex-direction: column; gap: 0; }
  .nav-links .wg-nav-link { padding: .65rem .75rem; border-top: 0; border-bottom: 0; border-left: 3px solid transparent; }
  .nav-links .wg-nav-link.active { border-left-color: #0f61fd; background: var(--hover); }
}
@media (max-width: 479px) {
  .wg-brand { font-size: 0; gap: 0; }                  /* the logo mark only, to leave room for the asset name */
  .nav-end { gap: .4rem; }
  .asset-switch { padding-right: .4rem; }
  .asset-switch .asset-link, .asset-switch .asset-name { max-width: 9rem; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------------------------------------------------------------- Buttons (.btn) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .625rem 1.25rem;
  font-size: .9rem; font-weight: 500; line-height: 1.25; border: 0; border-radius: 0; cursor: pointer;
  transition: background-color .15s ease-in-out, color .15s ease-in-out; white-space: nowrap; }
.btn-sm { padding: .4rem .875rem; font-size: .85rem; }
.btn-xs { padding: .2rem .625rem; font-size: .8rem; gap: .35rem; }
.btn[hidden] { display: none; }

/* ---------------------------------------------------------------- Info tips
 * An (i) button that opens a short help panel on click (api.js wires every .info-tip). */
.info-tip { position: relative; display: inline-flex; }
.info-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  padding: 0; border: 0; border-radius: 9999px; background: transparent; color: var(--muted); cursor: pointer; }
.info-btn:hover { color: var(--ink); background: var(--hover); }
.info-btn[aria-expanded="true"] { color: var(--link); }
.info-btn:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--focus-gap), 0 0 0 3px var(--wg-blue); }
.info-pop { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 22rem;
  max-width: calc(100vw - 32px); padding: .625rem .875rem;
  background: var(--tooltip-bg); color: var(--tooltip-ink); font-size: .8rem; line-height: 1.45;
  box-shadow: 0 4px 12px var(--shadow); }
.info-pop[hidden] { display: none; }
.info-pop::before { content: ""; position: absolute; top: -5px; left: 9px; width: 10px; height: 10px;
  background: var(--tooltip-bg); transform: rotate(45deg); }
.info-pop ul { list-style: disc; padding-left: 1.1rem; margin: 0; }
.info-pop li + li { margin-top: .3rem; }
.info-pop code { color: inherit; font-size: .75rem; padding: 0 .25rem; background: rgb(127 127 127 / .35); }
.btn-primary { background: var(--wg-blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--wg-blue-hover); }
.btn-primary:active:not(:disabled) { background: var(--wg-blue-active); }
.btn-secondary { background: var(--wg-charcoal); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: var(--wg-charcoal-hover); }
:root[data-theme="dark"] .btn-secondary { background: #525252; }
:root[data-theme="dark"] .btn-secondary:hover:not(:disabled) { background: #6f6f6f; }
.btn-ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--field-hover); }
.btn:disabled, .btn.disabled { background: var(--wg-disabled-bg); color: var(--wg-disabled-ink); cursor: not-allowed; }
:root[data-theme="dark"] .btn:disabled, :root[data-theme="dark"] .btn.disabled { background: #393939; color: #6f6f6f; }

/* ---------------------------------------------------------------- Focus ring (brand: surface gap + blue ring) */
:where(a, button, summary, [tabindex], input[type="checkbox"], input[type="radio"]):focus-visible {
  outline: none; box-shadow: 0 0 0 1px var(--focus-gap), 0 0 0 3px var(--wg-blue);
}

/* ---------------------------------------------------------------- Form fields (.form-control / .wg-input-text) */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
select, textarea {
  background-color: var(--field);
  border-color: var(--field-border);
  border-radius: 0;
  color: var(--ink);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):hover,
select:hover, textarea:hover { background-color: var(--field-hover); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):focus,
select:focus, textarea:focus { outline: 2px solid var(--wg-blue); outline-offset: -2px; box-shadow: none; }
input:disabled, select:disabled, textarea:disabled { color: var(--faint); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--wg-blue); }
input[type="file"] { color: var(--ink); }
input[type="file"]::file-selector-button { background: var(--wg-charcoal); color: #fff; border: 0; padding: .45rem 1rem;
  margin-right: .75rem; font-weight: 500; cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--wg-charcoal-hover); }
:root[data-theme="dark"] input[type="file"]::file-selector-button { background: #525252; }
label { color: var(--ink); }
.wg-form-label { font-weight: 700; font-size: .875rem; color: var(--ink); }
code { color: var(--ink-2); }

/* Text that differs by theme (e.g. "darker" vs "brighter" in a colour legend). */
.theme-dark-only { display: none; }
:root[data-theme="dark"] .theme-dark-only { display: inline; }
:root[data-theme="dark"] .theme-light-only { display: none; }

/* A count on a navigation link (e.g. connections waiting for review). */
.nav-count { display: inline-block; min-width: 1.25rem; padding: 0 .35rem; margin-left: .25rem; border-radius: 9999px;
  font-size: 11px; font-weight: 700; line-height: 1.25rem; text-align: center; background: #0f61fd; color: #fff; }
