/* ============================================================
   NEXORA · Component / Workspace chrome (shared by both labs)
   Full-bleed workspace shell, toolbars, panels, tabs, splitters,
   status bar. Built entirely from NEXORA theme tokens.
   ============================================================ */

/* Workspace screens run wider than standard content */
body.workspace-mode .app-content {
  max-width: none;
  margin-bottom: 1.25rem;
}

@media (max-width: 767px) {
  body.workspace-mode .app-content {
    margin-bottom: 6rem;
  }
}

/* ---------- Shell -------------------------------------------- */

.ws {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: calc(100vh - var(--tb-top) - var(--tb-h) - 2.6rem);
  min-height: 540px;
}

/* Fullscreen mode (both CSS-class and browser native) */
.ws.is-fullscreen,
:fullscreen .ws,
:-webkit-full-screen .ws {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  margin: 0 !important;
  padding: 0.65rem 0.85rem !important;
  background: var(--bg-1, #04060c) !important;
  border-radius: 0 !important;
  box-sizing: border-box !important;
}

[data-theme="light"] .ws.is-fullscreen,
[data-theme="light"] :fullscreen .ws,
[data-theme="light"] :-webkit-full-screen .ws {
  background: #f8fafc !important;
}

.ws.is-fullscreen .ws-body,
:fullscreen .ws .ws-body,
:-webkit-full-screen .ws .ws-body {
  flex: 1;
  min-height: 0;
  height: auto;
}

.ws-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.ws-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.ws-title .icon-tile {
  width: 40px;
  height: 40px;
}

img.asset-icon {
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
  flex-shrink: 0;
}

.icon-tile img.asset-icon {
  width: 22px;
  height: 22px;
}

.ws-title h1 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-1);
  line-height: 1.15;
}

.ws-title p {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 0.15rem;
}

/* ---------- Body: glass workspace surface --------------------- */

.ws-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--depth-lg), var(--glass-edge);
}

/* ---------- Toolbar ------------------------------------------- */

.ws-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.7rem;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .ws-toolbar {
  background: rgba(255, 255, 255, 0.5);
}

.ws-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.7rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur), transform var(--dur-fast);
}

.ws-btn .icon {
  width: 1em;
  height: 1em;
}

.ws-btn:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .ws-btn {
  color: #334155;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .ws-btn:hover {
  color: #0f172a;
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.14);
}

.ws-btn:active {
  transform: translateY(1px);
}

.ws-btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

/* Primary / Run button — high contrast vibrant green */
.ws-btn.primary {
  color: #ffffff !important;
  background: #16a34a !important;
  box-shadow: 0 2px 10px rgba(22, 163, 74, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  font-weight: 600;
}

.ws-btn.primary:hover {
  background: #15803d !important;
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.5);
  color: #ffffff !important;
}

[data-theme="light"] .ws-btn.primary {
  color: #ffffff !important;
  background: #16a34a !important;
  border-color: #15803d !important;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

[data-theme="light"] .ws-btn.primary:hover {
  background: #15803d !important;
}

.ws-btn.danger {
  color: #ef4444;
}

[data-theme="light"] .ws-btn.danger {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.2);
}

.ws-btn.danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.ws-btn.is-on {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.12);
}

[data-theme="dark"] .ws-btn.is-on {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
}

.ws-sep {
  width: 1px;
  height: 22px;
  margin-inline: 0.25rem;
  background: var(--border-strong);
  flex: none;
}

.ws-spacer {
  flex: 1;
  min-width: 0.5rem;
}

.ws-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-3);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
}

.ws-chip.live {
  color: var(--success);
}

.ws-chip.live .status-dot {
  animation: pulse-dot 1.6s infinite;
}

/* ---------- Main split area ----------------------------------- */

.ws-main {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* Left rail (activity bar) */
.ws-rail {
  width: 48px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0;
  background: rgba(3, 6, 16, 0.22);
  border-right: 1px solid var(--border);
}

[data-theme="light"] .ws-rail {
  background: rgba(255, 255, 255, 0.4);
}

.ws-rail-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.ws-rail-btn:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.07);
}

.ws-rail-btn.is-active {
  color: var(--accent-2);
  background: rgba(47, 210, 242, 0.1);
}

.ws-rail-btn.is-active::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5px;
  height: 55%;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
  box-shadow: 0 0 8px var(--glow-accent);
}

/* Side panel (explorer / library / inspector) */
.ws-side {
  width: var(--side-w, 230px);
  flex: none;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(3, 6, 16, 0.16);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

[data-theme="light"] .ws-side {
  background: rgba(255, 255, 255, 0.35);
}

.ws-side.right {
  border-right: 0;
  border-left: 1px solid var(--border);
  width: var(--side-w-r, 250px);
}

.ws-side.is-hidden {
  display: none;
}

.ws-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.ws-side-actions {
  display: flex;
  gap: 0.15rem;
}

.ws-mini {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  color: var(--text-3);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.ws-mini:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.09);
}

.ws-side-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.45rem;
}

/* Splitters */
.ws-split {
  flex: none;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  transition: background var(--dur-fast);
}

.ws-split:hover,
.ws-split:focus-visible {
  background: var(--border-accent);
}

.ws-split.horizontal {
  width: auto;
  height: 5px;
  cursor: row-resize;
}

/* Center column */
.ws-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Center workspace area & docking layout */
.ws-center-work {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Dock: Bottom (Default) */
.ws-center-work.dock-bottom {
  flex-direction: column;
}
.ws-center-work.dock-bottom .cl-editor-host {
  flex: 1;
  min-height: 0;
  order: 1;
}
.ws-center-work.dock-bottom .ws-split#cl-split-bottom {
  height: 5px;
  width: 100%;
  cursor: row-resize;
  order: 2;
}
.ws-center-work.dock-bottom .ws-bottom {
  height: var(--bottom-h, 220px);
  width: 100%;
  border-top: 1px solid var(--border);
  border-left: none;
  border-right: none;
  order: 3;
}

/* Dock: Left */
.ws-center-work.dock-left {
  flex-direction: row;
}
.ws-center-work.dock-left .ws-bottom {
  width: var(--panel-w, 420px);
  height: 100%;
  border-right: 1px solid var(--border);
  border-top: none;
  border-left: none;
  order: 1;
}
.ws-center-work.dock-left .ws-split#cl-split-bottom {
  width: 5px;
  height: 100%;
  cursor: col-resize;
  order: 2;
}
.ws-center-work.dock-left .cl-editor-host {
  flex: 1;
  min-width: 0;
  height: 100%;
  order: 3;
}

/* Dock: Right */
.ws-center-work.dock-right {
  flex-direction: row;
}
.ws-center-work.dock-right .cl-editor-host {
  flex: 1;
  min-width: 0;
  height: 100%;
  order: 1;
}
.ws-center-work.dock-right .ws-split#cl-split-bottom {
  width: 5px;
  height: 100%;
  cursor: col-resize;
  order: 2;
}
.ws-center-work.dock-right .ws-bottom {
  width: var(--panel-w, 420px);
  height: 100%;
  border-left: 1px solid var(--border);
  border-top: none;
  border-right: none;
  order: 3;
}

/* Dock Switcher in Panel Tab Bar */
.ws-dock-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

[data-theme="light"] .ws-dock-switch {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

.ws-dock-switch .ws-mini {
  width: 22px;
  height: 22px;
}

.ws-dock-switch .ws-mini.is-active {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .ws-dock-switch .ws-mini.is-active {
  color: #0f172a;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ---------- Editor tabs ---------------------------------------- */

.ws-tabs {
  display: flex;
  align-items: stretch;
  gap: 1px;
  overflow-x: auto;
  flex: none;
  background: rgba(3, 6, 16, 0.24);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.ws-tabs::-webkit-scrollbar { height: 0; }

[data-theme="light"] .ws-tabs {
  background: rgba(255, 255, 255, 0.4);
}

.ws-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-3);
  white-space: nowrap;
  border-right: 1px solid var(--border);
  transition: color var(--dur-fast), background var(--dur-fast);
  cursor: pointer;
}

.ws-tab:hover {
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.04);
}

.ws-tab.is-active {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 2px 0 var(--accent);
}

.ws-tab .dirty {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  flex: none;
}

.ws-tab-close {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  color: inherit;
  opacity: 0.55;
}

.ws-tab-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}

/* ---------- Bottom panel --------------------------------------- */

.ws-bottom {
  height: var(--bottom-h, 208px);
  flex: none;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: rgba(3, 6, 16, 0.2);
  min-height: 0;
}

[data-theme="light"] .ws-bottom {
  background: rgba(255, 255, 255, 0.4);
}

.ws-bottom.is-collapsed {
  height: 38px;
}

.ws-bottom.is-collapsed .ws-panes {
  display: none;
}

.ws-panel-tabs {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem 0.5rem;
  flex: none;
  border-bottom: 1px solid var(--border);
}

.ws-ptab {
  padding: 0.35rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  border-radius: var(--radius-xs);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.ws-ptab:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.06);
}

.ws-ptab.is-active {
  color: var(--accent-2);
  background: rgba(47, 210, 242, 0.1);
}

.ws-ptab .count {
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.62rem;
  color: var(--text-2);
}

.ws-ptab .count.err {
  background: rgba(255, 107, 129, 0.22);
  color: var(--danger);
}

.ws-panes {
  flex: 1;
  min-height: 0;
  position: relative;
}

.ws-pane {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 0;
}

.ws-pane.is-active {
  display: block;
}

/* ---------- Status bar ----------------------------------------- */

.ws-status {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.8rem;
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-3);
  background: rgba(3, 6, 16, 0.3);
  border-top: 1px solid var(--border);
}

[data-theme="light"] .ws-status {
  background: rgba(255, 255, 255, 0.5);
}

.ws-status .st {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ws-status .st .icon {
  width: 0.9em;
  height: 0.9em;
}

.ws-status .st.ok { color: var(--success); }
.ws-status .st.warn { color: var(--warning); }
.ws-status .st.err { color: var(--danger); }
.ws-status .st.accent { color: var(--accent-2); }

/* ---------- Empty states ---------------------------------------- */

.ws-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.6rem;
  height: 100%;
  padding: 2rem;
  text-align: center;
  color: var(--text-3);
}

.ws-empty .icon {
  width: 2.2em;
  height: 2.2em;
  opacity: 0.5;
}

.ws-empty kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2);
}

/* ---------- Mobile: drawers + view switch ------------------------ */

.ws-mobile-switch {
  display: none;
  gap: 0.25rem;
  padding: 0.3rem;
  margin-bottom: 0.1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
}

.ws-mobile-switch button {
  flex: 1;
  padding: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  border-radius: var(--radius-sm);
}

.ws-mobile-switch button.is-active {
  color: #fff;
  background: var(--gradient-brand);
  box-shadow: 0 6px 16px -8px var(--glow-accent);
}

@media (max-width: 900px) {
  .ws {
    height: auto;
    min-height: 0;
  }

  .ws-body {
    height: 78vh;
  }

  .ws-mobile-switch {
    display: flex;
  }

  .ws-rail {
    flex-direction: row;
    width: auto;
    height: 44px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    justify-content: flex-start;
    padding: 0 0.4rem;
  }

  .ws-main {
    flex-direction: column;
  }

  .ws-side {
    width: auto;
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .ws-side.right {
    border-left: 0;
    border-top: 1px solid var(--border);
    width: auto;
  }

  .ws-split {
    display: none;
  }

  /* Mobile view modes hide the non-selected region */
  .ws[data-view="editor"] .ws-side,
  .ws[data-view="panel"] .ws-side {
    display: none;
  }

  .ws[data-view="side"] .ws-center {
    display: none;
  }

  .ws[data-view="editor"] .ws-bottom {
    height: 150px;
  }
}
