/* shell.css — app chrome: sidebar, topbar, queue drawer, .view container. */
/* ---------- shell layout: aside#sidebar + main ---------- */
html, body {
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
body {
  display: flex;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

/* ---------- sidebar ---------- */
/* Signed-out gate: the login view owns the whole screen, so the app
   chrome (sidebar + the signed-in bits of the topbar) must not render —
   clicking a hidden sidebar must never "enter" the panel pre-auth. */
body.signed-out #sidebar { display: none; }
body.signed-out .topbar .who,
body.signed-out .topbar #signout { display: none; }
#sidebar {
  width: 208px;
  flex: 0 0 auto;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  padding: 12px 8px;
  box-sizing: border-box;
  overscroll-behavior: contain;
}
#sidebar.collapsed { width: 56px; }
#sidebar button[data-view] {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s, color 0.15s;
}
#sidebar button[data-view]:hover { background: var(--bg-inset); color: var(--ink-primary); }
#sidebar button[data-view].active { background: var(--bg-inset); color: var(--ink-primary); font-weight: 600; }
.nav-ico {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.nav-lbl {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-group { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-tertiary); margin: 14px 10px 4px; }
#sb-collapse { display: block; width: 100%; margin-top: 14px; border: 1px solid var(--border); background: none; border-radius: 6px; padding: 4px 0; font-size: 13px; color: var(--ink-tertiary); cursor: pointer; }
#sb-collapse:hover { border-color: var(--border-strong); color: var(--ink-primary); }

/* collapsed: group headers hidden, buttons center their icons */
#sidebar.collapsed .sb-group { display: none; }
#sidebar.collapsed button[data-view] { justify-content: center; padding: 10px 0; }
#sidebar.collapsed .nav-lbl { display: none; }

main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ---------- topbar (44px chrome strip) ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  z-index: 20;
}
.topbar h1 { font-size: 16px; }
.topbar .crumb { font-family: var(--font-mono); font-size: 12px; color: var(--ink-tertiary); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12px; color: var(--ink-secondary); }
.topbar .who b { font-weight: 600; }
.signout { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; font-size: 12px; color: var(--ink-secondary); }
.signout:hover { border-color: var(--border-strong); color: var(--ink-primary); }
/* Theme toggle (dark ↔ light) — sits beside the language toggle; icon and
   accessible name are driven from main.js so they track the live state. */
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px; cursor: pointer; color: var(--ink-secondary); display: inline-flex; align-items: center; line-height: 1; }
.theme-toggle:hover { border-color: var(--border-strong); color: var(--ink-primary); }
.theme-toggle svg { width: 14px; height: 14px; }

/* Topbar Active Run Indicator */
.topbar-run-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
}
.topbar-run-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--bg-paper-subtle);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--c-ink);
  cursor: pointer;
  transition: all 0.15s ease;
}
.topbar-run-indicator:hover {
  background: var(--c-border-subtle);
}
.run-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--run-blue);
  box-shadow: 0 0 0 0 rgba(25, 118, 210, 0.7);
  animation: pulse-dot 1.8s infinite;
}
@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(25, 118, 210, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(25, 118, 210, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(25, 118, 210, 0); }
}

/* Topbar Run Popover Drawer */
.topbar-run-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  background: var(--bg-paper);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 200;
  display: none;
  overflow: hidden;
}
.topbar-run-popover.open {
  display: block;
}
.topbar-run-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-paper-subtle);
  border-bottom: 1px solid var(--c-border-subtle);
  font-size: 12px;
  font-weight: 600;
}
.topbar-run-popover-body {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 0;
}
.topbar-run-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border-subtle);
  font-size: 11.5px;
}
.topbar-run-item:last-child {
  border-bottom: none;
}
.topbar-run-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.topbar-run-item-sub {
  color: var(--c-ink-subtle);
  font-size: 10.5px;
}
.topbar-run-popover-footer {
  padding: 6px 12px;
  background: var(--bg-paper-subtle);
  border-top: 1px solid var(--c-border-subtle);
  text-align: right;
  font-size: 11.5px;
}

.view {
  display: none;
  padding: 20px 24px 60px;
  max-width: 1500px;
  width: 100%;
  box-sizing: border-box;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.view.active {
  display: block;
  animation: viewFadeIn 0.15s ease-out;
}
@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .view.active {
    animation: none;
  }
}

/* ---------- queue drawer ----------
   Bottom-right floating button is superseded by the topbar real-time indicator */
.queue-toggle { display: none; }
.queue-drawer { position: fixed; bottom: 76px; right: 20px; width: 460px; max-height: 60vh; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(35,42,38,.25); z-index: 30; display: none; flex-direction: column; overflow: hidden; }
.queue-drawer.open { display: flex; }
.queue-drawer header { padding: 13px 14px; border-bottom: 1px solid var(--border); font-family: var(--font-display); font-size: 16px; display: flex; justify-content: space-between; }
.queue-drawer .close { background: none; border: none; font-size: 18px; color: var(--ink-tertiary); }
.queue-list { overflow-y: auto; padding: 10px; }

/* ---------- Command Palette (Cmd+K / Ctrl+K) ---------- */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35, 42, 38, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding-top: 14vh;
}
.cmd-palette-backdrop.open {
  display: flex;
}
.cmd-palette-dialog {
  width: 540px;
  max-width: 90vw;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cmd-input-wrap input {
  flex: 1;
  border: none;
  background: none;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--ink-primary);
  outline: none;
}
.cmd-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-primary);
  transition: background 0.1s ease;
}
.cmd-item:hover, .cmd-item.selected {
  background: var(--bg-inset);
}
.cmd-item .cmd-ico {
  width: 16px;
  height: 16px;
  color: var(--ink-secondary);
}
.cmd-item .cmd-key {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--ink-tertiary);
  background: var(--bg-inset);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.queue-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--bg-card); cursor: pointer; }
.queue-item .qhead { display: flex; align-items: center; gap: 8px; }
.queue-item .qname { font-family: var(--font-mono); font-size: 12px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .bar { height: 5px; background: var(--bg-inset); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.queue-item .bar > div { height: 100%; background: var(--accent); transition: width .4s; }
.queue-item .qmeta { font-size: 11px; color: var(--ink-tertiary); margin-top: 6px; font-family: var(--font-mono); }
.queue-item .qcancel { flex: none; padding: 1px 7px; font-size: 11px; line-height: 1.4; }
.queue-item .qcancelling { flex: none; font-size: 11px; color: var(--ink-tertiary); font-family: var(--font-mono); }
.queue-empty { padding: 30px; text-align: center; color: var(--ink-tertiary); font-size: 13px; }

/* ---------- reduced motion ----------
   Must sit AFTER the rules they override (the .dot animation and .bar width
   transition are defined above) — in base.css they were cascade-latent
   because shell.css loads later. Carried fix from Task 1. */
@media (prefers-reduced-motion: reduce) {
  .queue-toggle .dot { animation: none; }
  .queue-item .bar > div { transition: none; }
  .run-dot { animation: none; }
}
