/* ════════════════════════════════════════════════════════════════════════
   workspace.css — the Workspace Shell surface, panels, docking
   ────────────────────────────────────────────────────────────────────────
   Themed entirely through the design tokens (var(--bg/surface/border/text/
   gold…)) so it re-skins with every appearance, including the Jarvis HUD
   (extra glow gated at the bottom). The surface overlays #content and is
   shown only when <body class="workspace-active"> and #workspace is not
   [hidden].
   ════════════════════════════════════════════════════════════════════════ */

#workspace {
  position: absolute;
  inset: 0;
  z-index: 20;                 /* above the normal panes, below FAB/sheets */
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
#workspace[hidden] { display: none; }

/* The workspace is its own full-bleed environment with its own toolbar
   (＋ Panel / Tile / Modes / Close), so the app sidebar is hidden while it's
   active and #main reclaims the full width. Closing the workspace removes
   `workspace-active` and the sidebar returns. */
body.workspace-active #sidebar { display: none; }

/* ── Toolbar ──────────────────────────────────────────────────────────────── */

.ws-toolbar {
  flex-shrink: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.ws-brand {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-right: 6px;
  user-select: none;
}

.ws-tool {
  font: inherit;
  font-size: 13px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--speed), color var(--speed), background var(--speed);
}
.ws-tool:hover { border-color: var(--gold); color: var(--gold); }
.ws-tool-close:hover { border-color: var(--red); color: var(--red); }

.ws-tool-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.ws-spacer { flex: 1; }

.ws-layout-select {
  width: auto;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

/* Page picker */
.ws-add { position: relative; }
.ws-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ws-add-menu[hidden] { display: none; }
.ws-add-item {
  text-align: left;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.ws-add-item:hover { background: var(--gold-soft); color: var(--gold); }

/* ── Canvas (panel surface) ───────────────────────────────────────────────── */

.ws-canvas {
  position: relative;
  flex: 1;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--gold-soft), transparent 60%),
    var(--bg);
}

/* ── Panel ────────────────────────────────────────────────────────────────── */

.ws-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 280px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  overflow: hidden;
  transition: box-shadow var(--speed), border-color var(--speed);
}
.ws-panel.is-focused {
  border-color: var(--gold);
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
}
.ws-panel.is-dragging { transition: none; user-select: none; }
.ws-panel.is-docked { border-radius: 0; }

.ws-panel-bar {
  flex-shrink: 0;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 12px;
  background: var(--bg-warm);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
  touch-action: none;        /* let pointer-drag work on touchscreens */
}
.ws-panel.is-dragging .ws-panel-bar { cursor: grabbing; }

.ws-panel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.ws-panel.is-focused .ws-panel-dot { background: var(--gold); }

.ws-panel-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-panel-controls { display: flex; gap: 2px; flex-shrink: 0; }
.ws-panel-btn {
  width: 26px; height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--speed), color var(--speed);
}
.ws-panel-btn:hover { background: var(--gold-soft); color: var(--gold); }
.ws-panel-btn[data-act="close"]:hover { background: var(--red-soft); color: var(--red); }

.ws-panel-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
  position: relative;
}
/* Adopted page nodes fill the panel body. */
.ws-panel-body > .page.active { display: block; min-height: 100%; }

.ws-panel.is-min .ws-panel-body { display: none; }
.ws-panel.is-min { height: 38px !important; min-height: 38px; }

/* ── Resize handles ───────────────────────────────────────────────────────── */

.ws-resize { position: absolute; z-index: 2; touch-action: none; }
.ws-resize-n { top: -3px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.ws-resize-s { bottom: -3px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.ws-resize-e { right: -3px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.ws-resize-w { left: -3px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.ws-resize-ne { top: -4px; right: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.ws-resize-nw { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.ws-resize-se { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.ws-resize-sw { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: nesw-resize; }

/* Maximized / minimized panels don't resize. */
.ws-panel.is-max .ws-resize,
.ws-panel.is-min .ws-resize { display: none; }

/* Docked panels expose ONLY their inner-facing edge handle (it adjusts the
   dock thickness). */
.ws-panel.is-docked .ws-resize { display: none; }
.ws-panel.is-docked[data-dock="left"]   .ws-resize-e,
.ws-panel.is-docked[data-dock="right"]  .ws-resize-w,
.ws-panel.is-docked[data-dock="top"]    .ws-resize-s,
.ws-panel.is-docked[data-dock="bottom"] .ws-resize-n { display: block; }

/* ── Dock snap preview ────────────────────────────────────────────────────── */

.ws-dock-preview {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  background: var(--gold-soft);
  border: 2px dashed var(--gold);
  border-radius: 8px;
}
.ws-dock-preview[hidden] { display: none; }

/* ════════════════════════════════════════════════════════════════════════
   Jarvis HUD accents — gated to the theme, cyan glow on the workspace chrome.
   ════════════════════════════════════════════════════════════════════════ */
:root[data-theme="jarvis"] .ws-toolbar {
  box-shadow: 0 1px 12px rgba(63,208,255,0.10);
}
:root[data-theme="jarvis"] .ws-panel.is-focused {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(63,208,255,0.35), 0 10px 30px rgba(63,208,255,0.18);
}
:root[data-theme="jarvis"] .ws-panel-bar {
  background: linear-gradient(180deg, rgba(63,208,255,0.06), transparent);
}
:root[data-theme="jarvis"] .ws-dock-preview {
  box-shadow: inset 0 0 30px rgba(63,208,255,0.18);
}
