/* SkyDock Hub theme: light ("Clean corporate") + dark ("Operations console").
   Loaded after style.css. js/theme.js sets <html data-theme="light|dark"> before first paint.
   Tokens differ per theme; spacing, sizes and layout are shared, so switching never shifts the page.
   Brand: charcoal #1C1E22, neon green #00E58E (accent/fills), deep green #00A86B, amber #F5B83D. */
:root {
  --sd-charcoal: #1c1e22;
  --sd-neon: #00e58e;
  --sd-green: #00a86b;
  --sd-font-head: "Arial Narrow", "Liberation Sans Narrow", "Helvetica Neue", Arial, sans-serif;
  --sd-font-body: Arial, Helvetica, sans-serif;
  --sd-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  /* Shared layout: midway between the A (light) and B (dark) drafts */
  --content-max: 1360px;      /* A 1240, B 1480 */
  --content-gutter: 40px;     /* total side margin on narrow screens; A 32, B 28 */
  --panel-pad: 20px;          /* A 26, B 14 */
  --stat-pad-y: 16px;         /* A 22, B 10 */
  --stat-pad-x: 22px;         /* A 28, B 16 */
  --radius: 6px;             /* A 8, B 4 */
}

:root, :root[data-theme="light"] {
  color-scheme: light;
  --page: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f0f2f5;
  --surface-strong: #e6e9ee;
  --ink: #1c1e22;
  --ink-soft: #4a505b;
  --muted: #5d6471;
  --border: #e2e5ea;
  --border-strong: #c5cad2;
  --brand: #007a4d;
  --brand-strong: #00603b;
  --brand-dark: #1c1e22;
  --brand-pale: #dff9ee;
  --amber: #8f5300;
  --amber-pale: #fff3d6;
  --blue: #2f6fbd;
  --danger: #b3363b;
  --danger-strong: #8c2a2e;
  --danger-pale: #fbe8e8;
  --success: #006b43;
  --success-pale: #dff9ee;
  --shadow-sm: 0 1px 2px rgba(28, 30, 34, 0.05);
  --shadow-md: 0 12px 32px rgba(28, 30, 34, 0.09);
  --series-1: #00a86b;
  --series-2: #b87800;
  --gridline: #e9ecf0;
  --baseline: #a9afb9;
  --tooltip-bg: #ffffff;
  --header-bg: #ffffff;
  --header-ink: #1c1e22;
  --header-ink-soft: #4a505b;
  --header-line: var(--border);
  --header-glow: 0 3px 0 var(--sd-neon);
  --nav-hover: var(--surface-muted);
  --nav-active-bg: transparent;
  --nav-active-ink: #1c1e22;
  --nav-active-line: var(--sd-neon);
  --focus: #007a4d;
  --focus-ring: rgba(0,229,142,.28);
  --placeholder: #6b7280;
  --btn-primary-bg: #00e58e;
  --btn-primary-ink: #1c1e22;
  --btn-primary-hover: #007a4d;
  --btn-primary-hover-ink: #ffffff;
  --input-bg: #ffffff;
  --row-hover: #f7fbf9;
  --warn-ink: #7a4b00;
  --stat-ink: var(--ink);
  --good-ink: #006b43;
  --danger-quiet-line: #e5bcbc;
  --dot-glow: rgba(0,229,142,.28);
  --term-bg: #1c1e22;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #141619;
  --surface: #1c1e22;
  --surface-muted: #23262b;
  --surface-strong: #2a2d33;
  --ink: #eceef2;
  --ink-soft: #c3c8d0;
  --muted: #a0a7b3;
  --border: #2f333a;
  --border-strong: #4a505b;
  --brand: #00e58e;
  --brand-strong: #7ff2c4;
  --brand-dark: #111315;
  --brand-pale: rgba(0,229,142,.14);
  --amber: #f5b83d;
  --amber-pale: rgba(245,184,61,.15);
  --blue: #6aa8ff;
  --danger: #ff7a7a;
  --danger-strong: #ff9a9a;
  --danger-pale: rgba(255,90,90,.16);
  --success: #00e58e;
  --success-pale: rgba(0,229,142,.14);
  --shadow-sm: none;
  --shadow-md: 0 0 0 1px rgba(0,229,142,.35), 0 8px 24px rgba(0,0,0,.4);
  --series-1: #00e58e;
  --series-2: #f5b83d;
  --gridline: #2a2d33;
  --baseline: #5d6471;
  --tooltip-bg: #23262b;
  --header-bg: #111315;
  --header-ink: #eceef2;
  --header-ink-soft: #c3c8d0;
  --header-line: var(--sd-neon);
  --header-glow: 0 1px 14px rgba(0,229,142,.35);
  --nav-hover: var(--surface-strong);
  --nav-active-bg: var(--brand-pale);
  --nav-active-ink: #00e58e;
  --nav-active-line: transparent;
  --focus: #00e58e;
  --focus-ring: rgba(0,229,142,.25);
  --placeholder: #9aa1ad;
  --btn-primary-bg: #00e58e;
  --btn-primary-ink: #1c1e22;
  --btn-primary-hover: #7ff2c4;
  --btn-primary-hover-ink: #1c1e22;
  --input-bg: #141619;
  --row-hover: #23262b;
  --warn-ink: #f5b83d;
  --stat-ink: #00e58e;
  --good-ink: #00e58e;
  --danger-quiet-line: #7a3a3d;
  --dot-glow: rgba(0,229,142,.55);
  --term-bg: #0b0c0e;
}

body { font-family: var(--sd-font-body); font-size: 15px; line-height: 1.45; }
h1, h2, h3, .eyebrow, .brand-sub, th, .metric .label, .summary-label, .station-cell span, .badge {
  font-family: var(--sd-font-head);
}
h1, h2 { text-transform: uppercase; letter-spacing: .02em; }
.page-heading h1, .station-heading h1 { font-weight: 700; letter-spacing: .015em; }
.eyebrow { color: var(--brand); font-weight: 700; letter-spacing: .12em; }
:root[data-theme="dark"] .metric .value,
:root[data-theme="dark"] .pose-gauge-value,
:root[data-theme="dark"] .station-cell strong,
:root[data-theme="dark"] .summary-stat strong,
:root[data-theme="dark"] td { font-family: var(--sd-mono); }
.metric .value { font-size: 1rem; }
.metric .value.good { color: var(--good-ink); }

/* Header: same height/padding in both modes; colours via tokens */
.app-header { background: var(--header-bg); color: var(--header-ink); border-bottom: 1px solid var(--header-line); box-shadow: var(--header-glow); min-height: 62px; padding-top: 8px; padding-bottom: 8px; }
.brand-logo { display: block; width: 92px; height: 27px; }
.brand-logo-dark { display: none; }
:root[data-theme="dark"] .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand-logo-dark { display: block; }
.auth-brand .brand-logo-light { display: none; }
.auth-brand .brand-logo-dark { display: block; }
.brand-sub { padding-left: 11px; border-left: 2px solid var(--sd-neon); color: var(--header-ink-soft); font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.header-nav a { color: var(--header-ink-soft); border-radius: 0; padding: 9px 13px; box-shadow: inset 0 -3px 0 transparent; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; font-family: var(--sd-font-head); font-weight: 700; }
.header-nav a:hover { background: var(--nav-hover); color: var(--header-ink); }
.header-nav a.active { background: var(--nav-active-bg); color: var(--nav-active-ink); box-shadow: inset 0 -3px 0 var(--nav-active-line); }
.user-email { color: var(--header-ink-soft); }
.btn-header { border-color: var(--border-strong); color: var(--header-ink); background: transparent; }
.btn-header:hover { background: var(--nav-hover); }

/* Theme toggle: shows the icon of the mode you would switch to */
.theme-toggle { display: inline-grid; place-items: center; flex: 0 0 auto; width: 36px; min-height: 34px; padding: 0; cursor: pointer; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-toggle-float { position: fixed; top: 14px; right: 14px; z-index: 30; background: var(--surface); color: var(--ink); }
.theme-toggle-float:hover { background: var(--surface-muted); }

/* Shared layout: margins, content width, panel padding */
.app-container { width: min(var(--content-max), calc(100% - var(--content-gutter))); padding: 38px 0 56px; }
.page-heading { margin-bottom: 22px; }
.panel { padding: var(--panel-pad); border-radius: var(--radius); }
:root[data-theme="dark"] .panel { border-top: 2px solid var(--border-strong); }
.panel-heading { margin-bottom: 15px; }
.panel-heading h2 { font-size: 1.05rem; font-weight: 700; }
.station-page { gap: 16px; }
.summary-strip { border-radius: var(--radius); border-top: 3px solid var(--sd-neon); margin-bottom: 16px; }
.summary-stat { padding: var(--stat-pad-y) var(--stat-pad-x); min-height: 78px; }
.summary-stat strong { font-family: var(--sd-font-head); font-size: 1.8rem; color: var(--stat-ink); }
:root[data-theme="dark"] .summary-stat strong { font-size: 1.7rem; }
.station-list { gap: 8px; }
.station-card { border-radius: var(--radius); border-left: 3px solid var(--border-strong); }
.station-card:hover { border-left-color: var(--sd-neon); transform: none; background: var(--surface-muted); }
.station-name { font-size: 1rem; font-weight: 700; }
.metric { min-height: 68px; padding: 9px 11px; }
th, td { padding: 8px 10px; }
th { background: var(--surface-muted); letter-spacing: .08em; }
tbody tr:hover { background: var(--row-hover); }

/* Controls */
.btn { border-radius: var(--radius); font-weight: 700; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }
.btn-primary:hover { background: var(--btn-primary-hover); color: var(--btn-primary-hover-ink); }
.btn-secondary { border-color: var(--border-strong); background: var(--surface); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-muted); border-color: var(--sd-green); }
:root[data-theme="dark"] .btn-secondary { background: var(--surface-muted); }
:root[data-theme="dark"] .btn-secondary:hover { background: var(--surface-strong); border-color: var(--sd-neon); }
.btn-danger { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn-danger { background: #ff7a7a; color: #1c1e22; }
:root[data-theme="dark"] .btn-danger:hover { background: #ff9a9a; }
.btn-danger-quiet { background: transparent; border-color: var(--danger-quiet-line); color: var(--danger); }
input, select { min-height: 38px; border-radius: var(--radius); border-color: var(--border-strong); background: var(--input-bg); color: var(--ink); }
select option { background: var(--input-bg); color: var(--ink); }
input::placeholder { color: var(--placeholder); }
input:focus, select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.segmented-control { background: var(--input-bg); border: 1px solid var(--border); }
.segment.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), inset 0 -2px 0 var(--sd-neon); }
:root[data-theme="dark"] .segment.active { background: var(--surface-strong); color: var(--sd-neon); box-shadow: none; }
.hint-small { color: var(--muted); }
.row-delete-btn:hover { border-color: var(--danger-quiet-line); }

/* Status */
.badge.warning { background: var(--amber-pale); color: var(--warn-ink); }
.badge.neutral { color: var(--ink-soft); }
.status-dot.online { background: var(--sd-green); box-shadow: 0 0 0 3px var(--dot-glow); }
:root[data-theme="dark"] .status-dot.online { background: var(--sd-neon); }
.status-dot.offline { background: var(--danger); }
.role-pill.enterprise { color: var(--warn-ink); }

/* Login: charcoal hero panel in both modes; form side follows the theme */
.auth-brand { background: var(--sd-charcoal) url("../assets/skydock-hero.jpg") center / cover no-repeat; }
.auth-brand::after { display: none; }
.auth-brand .brand-logo { width: 150px; height: 44px; }
.auth-brand .brand-sub { color: #fff; }
.auth-brand-copy .eyebrow { color: var(--sd-neon); }
.auth-brand-copy h1 { font-family: var(--sd-font-head); text-transform: uppercase; }
.auth-heading h2 { font-weight: 700; }
.auth-page, .auth-panel { background: var(--surface); }

/* Console page: terminal panel follows the theme (xterm colours set in js/console.js) */
.console-page { background: var(--term-bg); }
.console-header { background: var(--header-bg); color: var(--header-ink); border-bottom: 1px solid var(--header-line); box-shadow: var(--header-glow); }
.console-header .theme-toggle { margin-left: auto; margin-right: 12px; }

@media (max-width: 720px) {
  .app-container { width: min(100% - 22px, var(--content-max)); padding: 24px 0 48px; }
  .app-header { min-height: 56px; }
  .brand-sub { display: none; }
  .panel { padding: 16px; }
}
