/* Vulani Suite portal shell theme. Takes its cue from the recovered old
   Vulani app's own AppHeader.tsx (AdvancedAppsRebuild/Vulani/web/src/
   components/AppHeader.tsx) — a sticky, blurred, dark top bar with a
   monospace wordmark and a system-switcher nav — per decisions/meta/0019
   this session's own read of that component, not a literal port (that
   app is React/Mantine; this is plain HTML/CSS, deliberately not a stack
   change, see decisions/0057). Colour values are this session's own
   choice, not lifted from Mantine defaults we never inspected.

   Deliberately NOT ported: the AI-assistant chrome (avatar, briefing
   badges, resizable footprint menu) — those are Vulani AI's own concerns
   and that module doesn't exist yet. Only eMapp and Documents are real,
   embeddable systems today, so only they appear in the nav.
*/

:root {
  --vs-ground: #0b0f14;
  --vs-panel: #11161d;
  --vs-thread: #232b35;
  --vs-thread-soft: #1a212a;
  --vs-text: #dbe4ec;
  --vs-text-dim: #8996a5;
  --vs-accent: #2dd4bf;
  --vs-accent-dim: #1a8a7d;
  --vs-danger: #e2604f;
  --vs-mono: 'Consolas', 'SFMono-Regular', Menlo, monospace;
  --vs-sans: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* , *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--vs-sans);
  background: var(--vs-ground);
  color: var(--vs-text);
  /* The module viewport fills exactly what's left below the header
     instead of a fixed calc(100vh - 120px) guess (that guess reserved
     120px against a 52px header + 40px of #vs-body padding -- a 28px
     margin nobody asked for, on top of whatever margin the embedded
     module itself already left at its own bottom edge). */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#vs-header { flex-shrink: 0; }

a { color: var(--vs-accent); }

/* Suite-wide dark scrollbar (decisions/0088) -- the default OS/browser
   scrollbar (light grey) looks out of place against every module's dark
   background; same light-on-transparent style applied identically in
   Portal/eMapp/Documents/Vulani's own theme files. */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }

/* ── Sticky header ── */
#vs-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 52px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--vs-ground) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--vs-thread-soft);
}

/* decisions/0081: brand and version sit on one baseline-aligned row, the
   way the reference header does it (AppHeader.tsx's own
   <Group gap={8} align="baseline">), rather than stacked -- the stacked
   pair crowded the 52px bar and read as two competing lines. */
#vs-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.vs-brand-divider {
  width: 1px;
  align-self: stretch;
  margin: 10px 0;
  background: var(--vs-thread);
  flex-shrink: 0;
}
#vs-brand .wordmark {
  font-family: var(--vs-mono);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  color: var(--vs-text);
}
/* David: "start versioning this" -- a real, hand-bumped semver (a git
   short-hash "doesn't help me"), so a stale browser tab is visibly
   distinguishable from a genuinely-updated one without opening devtools. */
.vs-version {
  font-family: var(--vs-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--vs-text-dim);
  opacity: .65;
}

#vs-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
}
/* decisions/0153 (Mark, 2026-10-06): an app the organisation hasn't paid for is shown red (it still opens, for demos). */
.vs-nav-btn.vs-nav-red { color: #f0646a; }
.vs-nav-btn.vs-nav-red:hover { color: #ff8a8f; background: rgba(240, 100, 106, 0.08); }
.vs-nav-btn.vs-nav-red.active { color: #ff8a8f; background: rgba(240, 100, 106, 0.14); border-color: rgba(240, 100, 106, 0.45); }
/* decisions/0153: shown in place of tabs when a person has no apps, or they couldn't be read. */
.vs-apps-message {
  color: var(--vs-text-dim);
  font-size: 0.8rem;
  padding: 6px 12px;
}
.vs-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: var(--vs-text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.vs-nav-btn:hover { color: var(--vs-text); background: var(--vs-thread-soft); }
.vs-nav-btn.active {
  color: var(--vs-accent);
  background: color-mix(in srgb, var(--vs-accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--vs-accent) 35%, transparent);
}
/* decisions/0076: Assets -- not buildable/sellable yet, shown as a
   disabled placeholder rather than hidden, so the four-module shape is
   visible even before it's real. */
.vs-nav-btn-placeholder { opacity: .4; cursor: not-allowed; }
.vs-nav-btn-placeholder:hover { color: var(--vs-text-dim); background: none; }
/* decisions/0081: the reference header's own per-system icons (Tabler
   outline, size 14, AppHeader.tsx's SYSTEMS array) replace this build's
   own invented generic dot -- stroke="currentColor" so each icon picks up
   its button's own state colour (dimmed grey inactive, accent teal active)
   exactly the way the reference's leftSection did, no per-state icon
   colour rules needed. */
.vs-nav-icon { flex-shrink: 0; opacity: .75; transition: opacity .15s; }
.vs-nav-btn:hover .vs-nav-icon, .vs-nav-btn.active .vs-nav-icon { opacity: 1; }
.vs-btn-icon { flex-shrink: 0; opacity: .8; }

/* ── Global Dept + Cycle picker (decisions/0072) ── */
/* decisions/0115: the global dept/cycle picker is gone -- each module owns
   its own now, so these rules have nothing left to style. */

#vs-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#vs-user .name { font-size: 0.78rem; color: var(--vs-text-dim); }
.vs-signout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--vs-thread);
  border-radius: 5px;
  background: none;
  color: var(--vs-text-dim);
  font-size: 0.75rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.vs-signout-btn:hover { color: var(--vs-danger); border-color: var(--vs-danger); }

/* decisions/0119: staff database switch. These rules only ever match for a
   user whose session may switch -- for anyone else the markup is not in the
   page at all, so there is nothing here to reveal. */
#vs-user-menu { position: relative; }
button#vs-user-name {
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  color: var(--vs-text-dim);
}
button#vs-user-name:hover { color: var(--vs-text); background: var(--vs-thread); }
#vs-admin-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 210px;
  padding: 12px;
  border: 1px solid var(--vs-thread);
  border-radius: 8px;
  background: var(--vs-surface, #12161c);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
#vs-admin-panel[hidden] { display: none; }
.vs-admin-who { font-size: 0.78rem; color: var(--vs-text); }
.vs-admin-tenant { font-size: 0.72rem; color: var(--vs-text-dim); margin-bottom: 10px; }
.vs-admin-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--vs-text-dim);
  margin-bottom: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--vs-thread);
}
.vs-db-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: var(--vs-text-dim);
  font-size: 0.76rem;
  cursor: pointer;
}
.vs-db-option:hover { background: var(--vs-thread); color: var(--vs-text); }
.vs-db-option.is-active {
  color: var(--vs-text);
  border-color: var(--vs-accent, #3f8cff);
}
.vs-db-option.is-active::after { content: " ¹3"; }
.vs-db-option:disabled { opacity: .5; cursor: progress; }

/* The safety net for this whole feature. Not subtle on purpose: the risk is
   someone reading one system's figures as if they came from the other. */
#vs-db-banner {
  padding: 6px 16px;
  background: var(--vs-danger, #b3261e);
  color: #fff;
  font-size: 0.76rem;
  text-align: center;
  letter-spacing: .02em;
}

/* ── Module viewport ── */
#vs-body {
  padding: 16px 20px 8px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.vs-module-frame {
  display: none;
  width: 100%;
  flex: 1;
  min-height: 400px;
  border: 1px solid var(--vs-thread-soft);
  border-radius: 8px;
  background: var(--vs-panel);
}
.vs-module-frame.active { display: block; }

/* decisions/0074: Vulani's floating widget as Portal chrome, not trapped
   inside its own tab's iframe -- present over every module, always. A
   modest corner box (Modules/Vulani's /widget route caps itself to
   Minimized/Compact, decisions/0075's widget_page), not the full viewport
   -- avoids the cross-origin-iframe click-passthrough problem a full-page
   transparent overlay would have (no CSS trick lets clicks fall through a
   cross-origin iframe's own empty space to the page behind it). Above
   #vs-header's z-index:100 so it stays visible over the header too, not
   just #vs-body.

   Real bug found live: this box defaulted to the full compact-panel size
   (420px x 75vh) even while the widget was only showing its small
   minimized bubble -- the empty rest of that box still had pointer-
   events:auto, silently swallowing clicks on whatever real page content
   happened to sit underneath it (eMapp's MultiSeg "Run Report" button,
   bottom-right of its own dialog, was directly under it). The widget now
   posts its own mode up via postMessage (vulani_widget.js's setMode);
   .vs-ambient-minimized below shrinks the hit box down to just the
   bubble's own footprint until the widget reports something bigger. */
#vs-ambient-widget-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  height: 75vh;
  max-height: 700px;
  border: none;
  background: transparent;
  z-index: 500;
  pointer-events: auto;
}
#vs-ambient-widget-frame.vs-ambient-minimized {
  /* Matches the bubble's own real footprint (Modules/Vulani/app/static/
     theme.css: 64px circle + 24px right/bottom margin), plus a small
     margin so the bubble's hover/click target isn't clipped at the edge. */
  width: 96px;
  height: 96px;
  /* Generic default -- close to the corner, no page-specific content to
     dodge. Modules with their own bottom-right chrome get an override
     below, keyed off vsShowModule's data-active-module attribute
     (decisions/0110). */
  right: 24px;
}
/* decisions/0110, 2026-09-17: over eMapp's Angle report, the bubble sat
   flush against the viewport's right edge and covered real grid cells.
   100px/180px/260px were tried by feel first and each landed on a wider,
   more material column (Balance) than the one being escaped (% Spent) --
   fixed instead by actually measuring the real rendered grid's column
   boundaries (getBoundingClientRect via a real Playwright session against
   real data, dept 170142/cycle 202627): "% Spent" is the grid's narrowest,
   least material rightmost column, and this value sits the whole 96px
   minimized frame inside it, clearing "Balance"'s real currency figures
   entirely. Column positions are grid-content-dependent, not a CSS
   constant -- revisit if eMapp's own column set or widths change. */
body[data-active-module="emapp"] #vs-ambient-widget-frame.vs-ambient-minimized {
  right: 32px;
}
/* decisions/0110, 2026-09-17: Assets' 3D map has its own bottom-right
   chrome (Cesium's compass control, ~70px, plus a LAT/LON readout below
   it) -- both real controls, no narrow gap to tuck into like eMapp's
   "% Spent" column. First tried moving to the opposite (left) corner;
   David preferred staying on the right, just lifted clear of the
   controls instead. Measured directly (assets_ui_react dev server,
   getBoundingClientRect on Cesium's own .compass element): the compass's
   top edge sits a fixed 158px above the viewport's bottom edge,
   invariant to window height since Cesium positions it via bottom/right
   CSS, not top -- so `bottom` here tracks it the same way, unlike
   eMapp's column fix above which is tied to one specific viewport width. */
body[data-active-module="assets"] #vs-ambient-widget-frame.vs-ambient-minimized {
  bottom: 170px;
}
/* decisions/0083: David -- "we dont have a max button to max vulani ino
   the whole screen". decisions/0074/0075 deliberately capped this iframe
   to a small corner box because Vulani's own fullscreen mode had a real
   full-page tab to expand into back then; decisions/0076 retired that tab,
   which left fullscreen with nowhere to go until now. Grows the iframe
   itself to the full viewport on request (the widget's own setMode posts
   its mode up, same mechanism .vs-ambient-minimized already uses) --
   top:0 too, above #vs-header's own z-index:100, so the header's real
   52px bar shows through this iframe's transparent top strip rather than
   the widget's own fullscreen panel needing to know Portal's header
   height itself (Modules/Vulani's theme.css positions its panel at
   top:52px specifically for this). */
#vs-ambient-widget-frame.vs-ambient-fullscreen {
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
}

/* ── Signed-out state ── */
#vs-signin-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
}
#vs-signin-screen .wordmark {
  font-family: var(--vs-mono);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.22em;
  color: var(--vs-text);
}
#vs-signin-screen .subtitle {
  font-size: 0.85rem;
  color: var(--vs-text-dim);
}
.vs-signin-btn {
  padding: 10px 22px;
  border: 1px solid var(--vs-accent-dim);
  border-radius: 6px;
  background: color-mix(in srgb, var(--vs-accent) 12%, transparent);
  color: var(--vs-accent);
  font-size: 0.85rem;
  text-decoration: none;
  transition: background .15s;
}
.vs-signin-btn:hover { background: color-mix(in srgb, var(--vs-accent) 22%, transparent); }

/* decisions/0158: the idle warning at 9 minutes. Above every frame,
   including the ambient Vulani widget, so it can't be missed. */
#vs-idle-warning {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 8, 12, 0.72);
}
#vs-idle-warning[hidden] { display: none; }
.vs-idle-box {
  width: min(360px, calc(100vw - 32px));
  padding: 22px 24px;
  background: var(--vs-panel);
  border: 1px solid var(--vs-thread);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.vs-idle-title { font-size: 1rem; color: var(--vs-text); margin-bottom: 8px; }
.vs-idle-text { font-size: 0.85rem; color: var(--vs-text-dim); margin: 0 0 18px; }
.vs-idle-text strong { color: var(--vs-text); font-family: var(--vs-mono); }
.vs-idle-stay {
  padding: 9px 20px;
  border: 1px solid var(--vs-accent-dim);
  border-radius: 6px;
  background: color-mix(in srgb, var(--vs-accent) 12%, transparent);
  color: var(--vs-accent);
  font-size: 0.85rem;
  cursor: pointer;
}
.vs-idle-stay:hover { background: color-mix(in srgb, var(--vs-accent) 22%, transparent); }

/* decisions/0187 step 3 (2026-11-10): the header menu's "My profile" and the My profile page. */
.vs-menu-link { display: block; padding: 6px 8px; margin-bottom: 8px; border-radius: 5px; color: var(--vs-text); text-decoration: none; font-size: 0.8rem; }
.vs-menu-link:hover { background: var(--vs-thread); color: var(--vs-accent); }
.vs-profile-body { min-height: 100vh; }
.vs-profile-back { margin-left: auto; color: var(--vs-text-dim); text-decoration: none; font-size: 0.8rem; }
.vs-profile-back:hover { color: var(--vs-accent); }
#vs-profile { max-width: 640px; margin: 24px auto; padding: 0 16px; color: var(--vs-text); font-family: var(--vs-sans); }
.vs-profile-title { font-size: 1.3rem; font-weight: 600; margin: 0 0 4px; }
.vs-profile-note, .vs-profile-intro, .vs-profile-since { color: var(--vs-text-dim); font-size: 0.85rem; margin: 0 0 12px; }
.vs-profile-form { display: flex; flex-direction: column; gap: 4px; }
.vs-profile-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; }
.vs-profile-label { flex: 0 0 160px; font-size: 0.85rem; color: var(--vs-text-dim); }
.vs-profile-input { flex: 1 1 260px; min-width: 0; box-sizing: border-box; padding: 7px 9px; border: 1px solid var(--vs-thread); border-radius: 6px; background: var(--vs-panel); color: var(--vs-text); font: inherit; font-size: 0.9rem; }
.vs-profile-people { display: flex; flex-direction: column; gap: 4px; margin-left: 170px; max-height: 200px; overflow-y: auto; }
.vs-profile-person { text-align: left; padding: 6px 9px; border: 1px solid var(--vs-thread); border-radius: 6px; background: transparent; color: var(--vs-text); cursor: pointer; font: inherit; font-size: 0.85rem; }
.vs-profile-person:hover { border-color: var(--vs-accent); }
.vs-profile-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.vs-profile-buttons[hidden], .vs-profile-ask[hidden] { display: none; }
.vs-profile-save, .vs-profile-small { padding: 7px 16px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 0.85rem; }
.vs-profile-save { border: 1px solid var(--vs-accent); background: var(--vs-accent-dim); color: #fff; }
.vs-profile-small { border: 1px solid var(--vs-thread); background: transparent; color: var(--vs-text-dim); }
.vs-profile-save:disabled, .vs-profile-small:disabled { opacity: .5; cursor: default; }
.vs-profile-ask { margin-top: 16px; padding: 12px; border: 1px solid var(--vs-thread); border-radius: 8px; background: var(--vs-panel); }
.vs-profile-ask-text { margin: 0 0 8px; font-weight: 600; }
.vs-profile-message { min-height: 1.2em; font-size: 0.85rem; margin-top: 10px; }
.vs-profile-message.is-ok { color: var(--vs-accent); }
.vs-profile-message.is-error { color: var(--vs-danger); }
@media (max-width: 560px) { .vs-profile-label { flex-basis: 100%; } .vs-profile-people { margin-left: 0; } }
