/* ─── Fonts (served by the WebUI; SIL OFL, assets/fonts/OFL.txt) ─── */
@font-face {
  font-family: 'Geist'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('../assets/fonts/Geist-Variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('../assets/fonts/GeistMono-Variable.woff2') format('woff2');
}

/* ─── Reset ──────────────────────────────────────────── */
* { box-sizing: border-box; }

/* Themed scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb); border-radius: var(--r-xs);
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

html, body { margin: 0; padding: 0; height: 100%; }

/* ─── App shell ──────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  border-bottom: 1px solid var(--border);
  border-right: none;
  background: var(--bg-elev);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

/* Hamburger button — only renders on narrow screens. */
.menu-toggle {
  display: none;
  position: fixed;
  top: var(--sp-6); left: var(--sp-6);
  z-index: var(--z-shell);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg);
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.menu-toggle svg { width: 20px; height: 20px; display: block; }

.menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--z-backdrop);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  /* The bar is packed edge to edge (space-between) at most widths: the name
     needs its own breathing room before the first screen button. */
  margin-right: var(--sp-6);
}
.sidebar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
}
.sidebar .brand .name { font-weight: var(--fw-bold); font-size: var(--fs-xl); letter-spacing: -0.5px; white-space: nowrap; }

.sidebar .nav-links {
  display: flex;
  flex-direction: row;
  gap: var(--sp-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  transition: all var(--t-fast) ease;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--fg); }
.nav-item.active { background: var(--bg-elev-2); color: var(--fg); border: 1px solid var(--border); }
.nav-item .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  opacity: 0.85;
}
.nav-item .icon svg { width: 18px; height: 18px; display: block; }
.nav-item.active .icon { opacity: 1; }
/* A count, not an action: neutral, so the lime stays the one primary action
   and the amber stays "waiting on you". */
.nav-item .badge {
  background: var(--bg-elev-2); color: var(--fg-dim);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: var(--fs-2xs); font-weight: var(--fw-semi); padding: 1px var(--sp-2); border-radius: var(--r-sm);
  border: 1px solid var(--border); margin-left: var(--sp-2);
}

.sidebar .footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--sp-6);
}
.sidebar .footer .foot-metrics {
  display: flex;
  gap: var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}
.sidebar .footer .foot-pill {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  height: 32px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--fg-dim);
}

/* The host at a glance (CPU · memory · temperature), and the count of what
   waits on the operator. Mono digits so they do not dance as they update. */
.host-pill, .attn-chip {
  height: 32px; padding: 0 var(--sp-4); border-radius: var(--r-md);
  display: inline-flex; align-items: center; gap: var(--sp-3);
  font: inherit; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
}
.host-pill {
  background: transparent; border: 1px solid var(--border); color: var(--fg-dim);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.host-pill:hover { color: var(--fg); border-color: var(--border-strong); }
.attn-chip {
  background: var(--attention-soft); border: 1px solid transparent; color: var(--attention);
  font-weight: var(--fw-semi);
}
.attn-chip[hidden] { display: none; }
.attn-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--attention); }
.host-pill:focus-visible, .attn-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Settings menu — appearance + change password + sign out in one dropdown */
.settings-dropdown {
  position: relative;
  display: inline-block;
}
.settings-dropdown .settings-btn {
  height: 32px;
  padding: 0 var(--sp-5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  background: var(--bg-elev-2);
  border-color: var(--border);
}
.settings-dropdown .settings-btn svg { width: 16px; height: 16px; display: block; }
.settings-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + var(--sp-3));
  min-width: 190px;
  padding: var(--sp-2);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  z-index: var(--z-menu);
}
.settings-dropdown.open .settings-menu { display: block; }
.settings-menu .menu-section-label {
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-mute);
}
.settings-menu .menu-theme {
  display: flex;
  gap: var(--sp-1);
  padding: 0 var(--sp-1) var(--sp-1);
}
.settings-menu .menu-theme button {
  flex: 1;
  padding: var(--sp-2) 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg-dim);
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  transition: all var(--t-fast);
}
.settings-menu .menu-theme button:hover {
  background: var(--bg-elev);
  color: var(--fg);
}
.settings-menu .menu-theme button.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.settings-menu .menu-divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-2) var(--sp-1);
}
/* The notifications switch: the label left, its state right. */
.settings-menu .menu-item.notify-item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.notify-state { font-size: var(--fs-sm); color: var(--fg-mute); white-space: nowrap; }
.notify-item[aria-checked="true"] .notify-state { color: var(--accent); }
.settings-menu .menu-item.notify-item:disabled { cursor: default; opacity: 0.7; }
.settings-menu .menu-item {
  display: block;
  width: 100%;
  padding: var(--sp-3);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--fg-dim);
  text-align: left;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  transition: all var(--t-fast);
}
.settings-menu .menu-item:hover {
  background: var(--bg-elev);
  color: var(--fg);
}
.settings-menu #logout-btn:hover { color: var(--red); }

/* ─── Main ─────────────────────────────────────────── */
.main { padding: 30px 40px 60px; max-width: 1400px; width: 100%; margin: 0 auto; min-width: 0; }

/* ─── Layout primitives ──────────────────────────────── */
/* align-items:start for the same reason .split needs it: grid items stretch to
   the row height by default, so the shorter column trails an empty block. */
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-8); align-items: start; }
/* align-items:start, not the grid default of stretch: otherwise both columns
   grow to the taller one's height and the shorter card trails a large empty
   block (a short workspace list next to a long session list, or the reverse). */
.split { display: grid; grid-template-columns: 280px 1fr; gap: var(--sp-8); align-items: start; }
.spacer { flex: 1; }

/* ─── Responsive: shell ──────────────────────────────── */
@media (max-width: 900px) {
  .sidebar .nav-links { gap: 2px; }
  .nav-item { padding: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); }
  .sidebar .footer .foot-metrics { display: none; }
}

@media (max-width: 720px) {
  /* A navegação sai do topo e vira gaveta; o que sobra no caminho de quem
     gruda é o botão flutuante do menu (16px do topo, 38px de altura). */
  :root { --nav-h: 56px; }
  .app { display: grid; grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 240px; height: 100vh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: var(--sp-6);
    padding: 60px var(--sp-6) var(--sp-8);
    transform: translateX(-100%);
    transition: transform var(--t-fast) ease-out;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4);
    border-right: 1px solid var(--border);
    border-bottom: none;
    z-index: var(--z-nav);
  }
  .app.menu-open .sidebar { transform: translateX(0); }
  .app.menu-open .menu-backdrop { display: block; }
  .menu-toggle { display: inline-flex; }

  .sidebar .brand {
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-3);
  }
  .sidebar .nav-links {
    flex-direction: column;
    gap: var(--sp-1);
  }
  .nav-item {
    font-size: var(--fs-md);
    padding: var(--sp-4) var(--sp-5);
  }
  .nav-item .badge {
    margin-left: auto;
  }
  .sidebar .footer {
    flex-direction: column;
    align-items: stretch;
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: var(--sp-6);
    gap: var(--sp-5);
  }
  .sidebar .footer .foot-metrics {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
  }
  .sidebar .footer .foot-pill {
    display: flex;
    justify-content: space-between;
  }
  .settings-dropdown { width: 100%; }
  .settings-dropdown .settings-btn { width: 100%; }
  .settings-menu { left: 0; right: 0; min-width: 0; }

  .main { padding: 74px var(--sp-5) 60px; }
  .grid-3 { grid-template-columns: 1fr; gap: var(--sp-5); }
  .split { grid-template-columns: 1fr; }
}

/* On a phone the sidebar is a drawer and its footer sits at the bottom of the
   screen, so a menu anchored below the settings button opens off-screen. Flip
   it upward there, and cap its height so a short screen can still scroll it. */
@media (max-width: 720px) {
  .settings-menu {
    top: auto; bottom: calc(100% + var(--sp-3));
    max-height: 60vh; overflow-y: auto;
  }
}

/* Alerts is a notification, not a destination: it sits apart from the nav
   proper, icon-only, pushed to the far end. */
/* Alerts is a notification, not a destination, so it lives in the right-hand
   group with the live pill and the settings gear rather than in the nav — which
   stays centred between the brand and that group. */
.nav-item.nav-alerts { padding: var(--sp-3) var(--sp-4); }
.nav-item.nav-alerts .badge { margin-left: var(--sp-1); }
@media (max-width: 720px) {
  /* In the drawer the nav is a column, so "far right" has no meaning — it just
     sits last, with its label restored since there is room for it. */
  .nav-item.nav-alerts::after { content: "Alerts"; }
}

/* The top bar's natural width is ~1450px (with "O1-AgentDeck"). Below that the
   host pill goes (System has the full picture) and the palette button keeps
   only its icon; below ~1140px the screens keep only their icons — the name stays in the DOM for a
   screen reader and in the title for a pointer. */
@media (min-width: 721px) and (max-width: 1460px) {
  .host-pill { display: none; }
  .pal-open kbd { display: none; }
  .pal-open { padding: 0 var(--sp-4); }
}
/* "O1-AgentDeck" is two characters longer than the old "agent-deck": just
   above the phone layout the bar has no room left for them. */
@media (min-width: 721px) and (max-width: 800px) {
  .sidebar .brand .name { font-size: var(--fs-md); letter-spacing: -0.4px; }
  .sidebar .brand { gap: var(--sp-2); }
  .sidebar { padding: 0 var(--sp-6); }
}
@media (min-width: 721px) and (max-width: 1140px) {
  .sidebar .nav-links .nav-item { font-size: 0; gap: var(--sp-2); }
  .sidebar .nav-links .nav-item .badge { font-size: var(--fs-xs); }
}
