/* Page chrome around the three webview frames: a pared-down VSCode window
   (title bar, activity bar, sidebar, editor tabs, status bar). The app inside
   the frames is styled by the extension's own styles.css. */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --titlebar-bg: #181818;
  --titlebar-fg: #cccccc;
  --activity-bg: #181818;
  --activity-fg: #d7d7d7;
  --activity-dim: #868686;
  --sidebar-bg: #181818;
  --editor-bg: #1f1f1f;
  --tabs-bg: #181818;
  --tab-fg: #9d9d9d;
  --tab-active-bg: #1f1f1f;
  --tab-active-fg: #ffffff;
  --border: #2b2b2b;
  --accent: #0078d4;
  --accent-hover: #026ec1;
  --muted: #9d9d9d;
  --btn-hover: rgba(90, 93, 94, 0.31);
  --status-bg: #181818;
  --status-fg: #cccccc;
  --widget-bg: #202020;
  --widget-fg: #cccccc;
  --widget-border: #454545;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  --qp-hover: #04395e;
}

:root[data-theme="light"] {
  color-scheme: light;
  --titlebar-bg: #f8f8f8;
  --titlebar-fg: #1e1e1e;
  --activity-bg: #f8f8f8;
  --activity-fg: #1f1f1f;
  --activity-dim: #616161;
  --sidebar-bg: #f8f8f8;
  --editor-bg: #ffffff;
  --tabs-bg: #f8f8f8;
  --tab-fg: #616161;
  --tab-active-bg: #ffffff;
  --tab-active-fg: #3b3b3b;
  --border: #e5e5e5;
  --accent: #005fb8;
  --accent-hover: #0258a8;
  --muted: #6b6b6b;
  --btn-hover: rgba(184, 184, 184, 0.31);
  --status-bg: #f8f8f8;
  --status-fg: #3b3b3b;
  --widget-bg: #f8f8f8;
  --widget-fg: #3b3b3b;
  --widget-border: #cecece;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  --qp-hover: #e8e8e8;
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--editor-bg);
  color: var(--titlebar-fg);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { font: inherit; color: inherit; }

:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }

/* ─── Title bar ────────────────────────────────────────────────────── */
.titlebar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 38px;
  padding: 0 8px 0 14px;
  background: var(--titlebar-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.brand-icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.brand-name { font-weight: 600; letter-spacing: 0.01em; }
.brand-tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 7px;
  white-space: nowrap;
}

.actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}
.tb-btn {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--titlebar-fg);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.tb-btn:hover { background: var(--btn-hover); }
.tb-primary {
  margin-left: 6px;
  background: var(--accent);
  color: #ffffff;
}
.tb-primary:hover { background: var(--accent-hover); }

/* ─── Workbench ────────────────────────────────────────────────────── */
.workbench {
  --sidebar-w: 340px;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 48px var(--sidebar-w) 4px minmax(0, 1fr);
}

.activitybar {
  background: var(--activity-bg);
  border-right: 1px solid var(--border);
}
.ab-item {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 2px solid transparent;
}
.ab-item.is-active { border-left-color: var(--accent); }
.ab-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--activity-fg);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pane-sidebar { background: var(--sidebar-bg); }
.pane-title {
  flex: none;
  height: 35px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 20px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.view-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
}
.view-action {
  width: 24px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--titlebar-fg);
  cursor: pointer;
}
.view-action:hover { background: var(--btn-hover); }
.view-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

iframe {
  display: block;
  width: 100%;
  border: 0;
  flex: 1;
  min-height: 0;
  background: transparent;
}

.sash {
  cursor: col-resize;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  touch-action: none;
}
.sash:hover, .sash.is-dragging, .sash:focus-visible { background: var(--accent); }
.workbench.is-resizing iframe { pointer-events: none; }

.pane-main { background: var(--editor-bg); }

.tabs {
  flex: none;
  display: flex;
  height: 35px;
  background: var(--tabs-bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--border);
  border-top: 1px solid transparent;
  background: transparent;
  color: var(--tab-fg);
  white-space: nowrap;
  cursor: pointer;
}
.tab[aria-selected="true"] {
  background: var(--tab-active-bg);
  color: var(--tab-active-fg);
  border-top-color: var(--accent);
  margin-bottom: -1px;
}
.tab-sidebar-only { display: none; }

.editors {
  flex: 1;
  min-height: 0;
  display: flex;
}
.editor { display: none; }
.workbench[data-main="board"] .editor[data-view="board"],
.workbench[data-main="graph"] .editor[data-view="graph"] { display: block; }

/* ─── Status bar ───────────────────────────────────────────────────── */
.statusbar {
  flex: none;
  display: flex;
  align-items: center;
  height: 22px;
  font-size: 12px;
  background: var(--status-bg);
  color: var(--status-fg);
  border-top: 1px solid var(--border);
}
.sb-item {
  min-width: 0;
  line-height: 22px;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-accent { background: var(--accent); color: #ffffff; }
.sb-muted { color: var(--muted); }
.sb-spacer { flex: 1; }

/* ─── Notifications (VSCode-style toasts) ──────────────────────────── */
.toasts {
  position: fixed;
  right: 12px;
  bottom: 34px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  background: var(--widget-bg);
  color: var(--widget-fg);
  border: 1px solid var(--widget-border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.toast-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.toast[data-kind="warning"] .toast-dot { background: #cca700; }
.toast[data-kind="error"] .toast-dot { background: #f14c4c; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close {
  flex: none;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.toast-close:hover { background: var(--btn-hover); color: var(--widget-fg); }

/* ─── Quick pick (import mode, reset) ──────────────────────────────── */
.quickpick-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 64px 16px 0;
  background: rgba(0, 0, 0, 0.25);
}
.quickpick-backdrop[hidden] { display: none; }
.quickpick {
  width: min(560px, 100%);
  background: var(--widget-bg);
  color: var(--widget-fg);
  border: 1px solid var(--widget-border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.qp-title {
  padding: 6px 8px 8px;
  color: var(--muted);
}
.qp-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.qp-option:hover, .qp-option:focus-visible {
  background: var(--qp-hover);
  outline: none;
}
.qp-detail {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

/* ─── Narrow screens: one pane at a time ───────────────────────────── */
@media (max-width: 820px) {
  .brand-tag, .actions a:not(.tb-primary), .sb-muted { display: none; }
  .tb-primary { margin-left: 2px; }
  .workbench { display: flex; flex-direction: column; }
  .activitybar, .sash { display: none; }
  .pane-sidebar {
    order: 2;
    flex: 1;
    display: none;
  }
  .pane-main {
    display: contents;
  }
  .tabs { order: 1; }
  .editors { order: 3; }
  .tab-sidebar-only { display: flex; }
  .workbench[data-pane="sidebar"] .pane-sidebar { display: flex; }
  .workbench[data-pane="sidebar"] .editors { display: none; }
}
