/* sys/web/app.css — LOCKED styles for Symbi's chat + sidebar components.
   Served from sys/, not user-editable (SYMBI.md §5). The editable shell
   (web-main.css) may OVERRIDE the palette variables below and set the page
   background; it loads after this file so its :root values win. Component
   structure lives here and is not meant to be user-edited. */

:root {
  --bg: #1a1a1a;
  --panel: #232323;
  --border: #333333;
  --ink: #ececec;
  --muted: #999999;
  --accent: #cb7fff;
  --accent-ink: #1a1a1a;
  --user: #2f2f2f;
  --assistant: #262626;
  --system: #3a2a2a;
  --online: #4ade80;
  --offline: #5a5a5a;
  --radius: 10px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.5;
}

/* ------------------------------- chat ------------------------------- */

.symbi {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px;
  font-size: 16px;
}

#symbi-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  position: relative; /* anchors the settings dropdown */
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.state {
  font-size: 12px;
  color: var(--muted);
  text-transform: lowercase;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

/* Chip vocabulary matches the sidebar: WORKING (a step is running),
   ONLINE (idle + reachable), OFFLINE (down). */
.state[data-state="WORKING"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}
.state[data-state="ONLINE"] {
  color: var(--online);
  border-color: var(--border);
}
.state[data-state="OFFLINE"] {
  color: var(--muted);
  border-color: var(--border);
}

/* ------------- top-bar buttons: mode toggles + settings gear (M7) ---------- */

/* Shared round icon button in the top bar (ghost, blind, gear). */
.bar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s, transform 0.2s ease;
}
.bar-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.bar-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* Mode toggle ON: filled accent, like the "working" chip/dot vocabulary. */
.mode-btn.active {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

/* Gear tilts open (it's a .bar-btn too, set in the markup). */
.set-gear[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(45deg);
}

.set-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 4px;
  z-index: 60;
  width: 300px;
  max-height: 78vh;
  overflow-y: auto;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.set-menu[hidden] {
  display: none;
}
.set-menu::-webkit-scrollbar {
  width: 8px;
}
.set-menu::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.set-menu::-webkit-scrollbar-track {
  background: transparent;
}

.set-head {
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 10px;
}

.set-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.set-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.set-field input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 9px;
  font-family: inherit;
  font-size: 13px;
}
.set-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.set-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.set-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-bottom: 12px;
}
.set-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
}
.set-swatch span {
  color: var(--ink);
  font-size: 11px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.set-swatch input[type="color"] {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
}
.set-swatch input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}
.set-swatch input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.set-save {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 6px;
  padding: 8px;
  font: inherit;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.set-save:hover {
  filter: brightness(1.08);
}
.set-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Bottom action row: one save + one reset, under their own divider. */
.set-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Secondary action — revert identity + palette to defaults. Quieter than save. */
.set-reset {
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px;
  font: inherit;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.set-reset:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.set-reset:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Destructive action (reset all data): red on hover, and while armed (confirm). */
.set-danger:hover {
  color: #ff6b6b;
  border-color: #ff6b6b;
}
.set-reset.armed {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

.output {
  flex: 1;
  overflow-y: auto;
  padding: 26px 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.output::-webkit-scrollbar {
  width: 8px;
}
.output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.output::-webkit-scrollbar-track {
  background: transparent;
}

.msg {
  padding: 10px 16px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: 88%;
}

.msg.user {
  background: var(--user);
  align-self: flex-end;
}

.msg.assistant {
  background: var(--assistant);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.msg.system {
  background: var(--system);
  color: #ffcccc;
  align-self: center;
  font-size: 13px;
}

/* Echo of a local slash-command the user typed. */
.msg.command {
  align-self: center;
  background: transparent;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 4px 12px;
}

/* Successful command output (neutral, not an error). */
.msg.notice {
  align-self: center;
  background: var(--assistant);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.input {
  display: flex;
  gap: 8px;
  padding: 12px 0 20px;
  border-top: 1px solid var(--border);
  align-items: flex-end; /* button stays put while the textarea grows upward */
}

.input textarea {
  flex: 1;
  resize: none;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.5;
  min-height: 48px;
  max-height: 40vh; /* grows to here; JS shows the scrollbar only past this */
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.input textarea::-webkit-scrollbar {
  width: 8px;
}
.input textarea::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.input textarea::-webkit-scrollbar-track {
  background: transparent;
}

.input textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.input button {
  height: 48px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  padding: 0 18px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ------------------------------ sidebar ----------------------------- */

#symbi-sidebar,
#symbi-data {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  font-size: 12px;
}
#symbi-sidebar {
  left: 0;
}
/* the Data sidebar mirrors the network one on the right edge; row-reverse puts
   its pull tab on the inner (left) edge of the panel. */
#symbi-data {
  right: 0;
  flex-direction: row-reverse;
}
#symbi-data .sb-panel {
  border-radius: var(--radius) 0 0 var(--radius);
}
/* The data tab mirrors the network tab on the right edge: it needs its OUTER
   (left) border back — the base rule drops border-left for the network tab,
   which left the data tab's visible edge borderless (the "layering" gap on the
   pull tab). Restore the left border and drop the panel-facing right one. */
#symbi-data .sb-tab {
  border-left: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}
#symbi-data .sb-tab:hover {
  border-color: var(--accent);
}
/* no config drawer on the Data side — its tree is the scroll region */
#symbi-data .sb-tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.sb-panel {
  width: 0;
  opacity: 0;
  overflow: hidden;
  max-height: 88vh;
  background: var(--panel);
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: width 0.22s ease, opacity 0.18s ease;
}

/* thin, themed scrollbar shared by the panel, the config drawer, the data tree */
.sb-panel::-webkit-scrollbar,
.sb-config-body::-webkit-scrollbar,
#symbi-data .sb-tree::-webkit-scrollbar {
  width: 8px;
}
.sb-panel::-webkit-scrollbar-thumb,
.sb-config-body::-webkit-scrollbar-thumb,
#symbi-data .sb-tree::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.sb-panel::-webkit-scrollbar-track,
.sb-config-body::-webkit-scrollbar-track,
#symbi-data .sb-tree::-webkit-scrollbar-track {
  background: transparent;
}

#symbi-sidebar.open .sb-panel,
#symbi-data.open .sb-panel {
  width: 280px;
  opacity: 1;
  overflow: hidden; /* the panel itself never scrolls — only the inner scroll region does */
  border: 1px solid var(--border);
}
#symbi-sidebar.open .sb-panel {
  border-left: none;
}
#symbi-data.open .sb-panel {
  border-right: none;
}

.sb-inner {
  width: 280px; /* fixed so content doesn't reflow during the width transition */
  padding: 12px 14px;
  box-sizing: border-box;
  max-height: 88vh;
  display: flex; /* column so the drawer can flex-fill + scroll while the tree stays put */
  flex-direction: column;
}

.sb-title {
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 10px;
}

.sb-tab {
  flex: 0 0 auto;
  width: 20px;
  height: 60px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.sb-tab:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.sb-tab.working {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  animation: sb-pulse 1s ease-in-out infinite;
}
.sb-tab.has-offline {
  color: var(--offline);
}

.sb-node {
  margin-bottom: 8px;
}

.sb-node-head {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sb-node-name {
  color: var(--ink);
  font-weight: 700;
}

.sb-node-models {
  margin: 4px 0 4px 18px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sb-model {
  display: flex;
  align-items: center;
}

.sb-model-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sb-model-label {
  color: var(--ink);
}

.sb-model-id {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 196px;
}

.sb-model-lat {
  margin-left: auto;
  padding-left: 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sb-empty {
  color: var(--muted);
}

.sb-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}

.sb-tree {
  flex: 0 0 auto; /* stays full height; the config drawer is what flexes/scrolls */
}

.sb-legend {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
}
.sb-legend span {
  display: flex;
  align-items: center;
}

/* config pull-down (model/endpoint swap) — a pull handle + sliding drawer.
   When open, .sb-config flex-fills the remaining panel height and its drawer
   is the ONLY scroll region (the handle above stays pinned + clickable). */
.sb-config {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sb-config.open {
  /* Hug the (capped) drawer instead of filling the whole panel, so the drawer
     stays compact and scrolls internally rather than growing tall. */
  flex: 0 1 auto;
  min-height: 0;
}
/* the handle — a rounded grip tab echoing the sidebar's open/close tab */
.sb-config-tab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
}
.sb-config-tab:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.sb-config-caret {
  font-size: 11px;
  line-height: 1;
  transition: transform 0.2s ease;
}
.sb-config.open .sb-config-caret {
  transform: rotate(180deg);
}
.sb-config-body {
  flex: 0 0 auto;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.2s ease;
}
.sb-config.open .sb-config-body {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 38vh; /* smaller cap; the drawer scrolls past this instead of growing */
  overflow-y: auto;
  opacity: 1;
  margin-top: 10px;
  padding-right: 4px;
}
.sb-config.busy .sb-config-body {
  opacity: 0.5;
  pointer-events: none;
}

/* Data sidebar — memory/external bins (toggle · label+size · reset) */
.sb-bin {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sb-bin-toggle {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.sb-bin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
.sb-bin-label {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-bin-size {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.sb-bin-reset {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 8px;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}
.sb-bin-reset:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.sb-bin-reset.armed {
  color: #ff6b6b;
  border-color: #ff6b6b;
}
.sb-cfg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sb-cfg-label {
  color: var(--ink);
  font-weight: 700;
  font-size: 12px;
}
.sb-cfg-select,
.sb-cfg-endpoint {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 6px;
  padding: 4px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}
.sb-cfg-select:focus,
.sb-cfg-endpoint:focus {
  outline: none;
  border-color: var(--accent);
}
.sb-cfg-select:disabled {
  color: var(--muted);
}
.sb-cfg-note {
  color: var(--muted);
  font-size: 11px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  flex: 0 0 auto;
  background: var(--offline);
}
.dot.online {
  background: var(--online);
}
.dot.offline {
  background: var(--offline);
}
.dot.working {
  background: var(--accent);
  animation: sb-pulse 1s ease-in-out infinite;
}

@keyframes sb-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
