/* ── SPA Layout ─────────────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.spa-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.spa-view.active {
  display: flex;
}

/* ── Browser Chrome ───────────────────────────────── */
.bc-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
  padding: 0 var(--space-3);
  flex-shrink: 0;
  z-index: 12;
}

.bc-nav-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) 0;
}

.bc-nav-input {
  flex: 1;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  outline: none;
}
.bc-nav-input:focus { border-color: var(--border-focus); }

.bc-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.bc-icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.bc-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.bc-tool-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.bc-tool-btn .material-icons-outlined { font-size: 18px; }
.bc-tool-btn { position: relative; }
.bc-docs-badge {
  position: absolute; top: -2px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  background: var(--accent, #b30000); color: #fff;
  border-radius: 8px;
}
.bc-docs-badge.hidden { display: none; }
@keyframes badge-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); }
  100% { transform: scale(1); }
}
.bc-docs-badge.bump { animation: badge-bump 0.3s ease-out; }

/* ── Browser Chrome: Drawers ─────────────────────── */
.bc-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-default);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: right 0.2s ease;
  box-shadow: -4px 0 16px rgba(0,0,0,0.1);
}
.bc-drawer.open { right: 0; }
.bc-drawer-wide { width: 380px; right: -400px; }
.bc-drawer-wide.open { right: 0; }

.bc-drawer-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-default);
  font-weight: 600;
  font-size: var(--text-sm);
}
.bc-drawer-header > :first-child { flex: 1; }

.bc-clip-search {
  margin: var(--space-2) var(--space-3);
  padding: var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--text-sm);
}
.bc-clip-container { flex: 1; overflow-y: auto; padding: 0 var(--space-3); }

.bc-clipboard-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}
.bc-clipboard-item:hover { background: var(--bg-tertiary); }
.bc-clipboard-item.detected { opacity: 0.7; }
.bc-clipboard-item.selected { background: var(--accent-primary); color: #fff; }

.bc-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: var(--space-3) 0 var(--space-1);
  padding: 0 var(--space-3);
}

/* ── Browser Chrome: Popover ─────────────────────── */
.bc-popover {
  position: fixed;
  z-index: 100;
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  width: 220px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.bc-popover.visible { opacity: 1; }
.bc-popover-title { font-weight: 600; font-size: var(--text-sm); margin-bottom: var(--space-1); }
.bc-popover-desc { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Browser Chrome: Documents ───────────────────── */
.bc-docs-menu {
  position: absolute;
  top: 100%;
  right: 0;
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 60;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}
.bc-docs-menu.open { display: block; }
.bc-docs-header { padding: var(--space-2) var(--space-3); font-weight: 600; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border-default); }
.bc-docs-item {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.bc-docs-item:hover { background: var(--bg-tertiary); }
.bc-docs-empty { padding: var(--space-3); text-align: center; color: var(--text-muted); font-size: 12px; }
.bc-docs-section { border-bottom: 1px solid var(--border-default); }
.bc-docs-section:last-child { border-bottom: none; }
.bc-docs-section-title { padding: var(--space-2) var(--space-3); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.bc-docs-meta { float: right; font-size: 11px; color: var(--text-muted); }
.bc-docs-row { display: flex; align-items: stretch; }
.bc-docs-row .bc-docs-file-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-docs-save {
  width: 36px;
  border: none;
  border-left: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bc-docs-save:hover { background: var(--bg-tertiary); color: var(--accent-primary); }
.bc-docs-save:disabled { opacity: 0.45; cursor: wait; }
.bc-docs-save .material-icons-outlined { font-size: 17px; }
.bc-docs-download { display: flex; align-items: center; gap: var(--space-1); }
.bc-docs-download-icon { font-size: 16px; color: var(--text-muted); flex-shrink: 0; }
.bc-docs-download:hover .bc-docs-download-icon { color: var(--accent-primary); }

/* ── Browser Chrome: Add Words ───────────────────── */
.bc-word-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}
.bc-word-item input {
  padding: var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--text-sm);
}
.bc-word-sensitive { display: flex; gap: var(--space-2); }
.bc-word-sensitive input { flex: 1; }
.bc-word-toggle, .bc-word-remove {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
}
.bc-word-toggle:hover, .bc-word-remove:hover { color: var(--text-primary); }
.bc-word-error { padding: 0 var(--space-3); color: var(--color-error); font-size: var(--text-xs); }
.bc-word-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-default);
}

/* ── Focus View: Layout ────────────────────────────── */
.focus-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.focus-vnc-container {
  flex: 1;
  position: relative;
  background: var(--bg-tertiary);
  min-width: 0;
}

.focus-vnc-container .slot-iframe-placeholder {
  width: 100%;
  height: 100%;
}

.focus-debug-panel {
  display: none;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow: hidden;
  border-left: 1px solid var(--border-default);
}

.focus-layout.debug-mode .focus-vnc-container {
  flex: 0 0 67%;
}

.focus-layout.debug-mode .focus-debug-panel {
  display: flex;
  flex: 0 0 33%;
}

/* ── Debug Panel Header ──────────────────────────── */
.debug-panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
  min-height: 40px;
}

/* ── Debug Toggle Arrow ──────────────────────────── */
.debug-toggle-arrow {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  z-index: 15;
  padding: 8px 2px;
}

.debug-toggle-arrow:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.debug-toggle-arrow .material-icons-outlined {
  font-size: 18px;
}

.debug-toggle-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.focus-layout.debug-mode .debug-toggle-arrow {
  /* Arrow stays visible — chevron flips to 'chevron_right' via JS */
}

/* ── IframePool container ──────────────────────────── */
#iframe-pool {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  z-index: 5;
  pointer-events: none;
}

#iframe-pool iframe {
  position: absolute;
  border: none;
  pointer-events: auto;
}

#iframe-pool iframe.grid-mode {
  pointer-events: none;
}

#iframe-pool iframe.detached {
  display: none;
}

#iframe-pool iframe.vnc-pending {
  opacity: 0;
  pointer-events: none;
}

/* ── Pool slot overlays (above iframes for grid labels/buttons) ── */
.pool-slot-overlay {
  position: absolute;
  pointer-events: auto;
  z-index: 10;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.pool-slot-overlay:hover {
  z-index: 20;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12), 0 0 0 2px var(--accent, #b30000);
  border-radius: 8px;
}

/* Pool overlay header (matches slot-header) — hidden; template .slot-header is the visible one */
.pool-overlay-header {
  display: none;
}

.pool-overlay-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pool overlay attention area */
.pool-overlay-attention {
  position: absolute;
  inset: 32px 0 0 0;
  background: var(--bg-primary);
  display: none;
  flex-direction: column;
  padding: 8px 10px;
  z-index: 10;
}

/* ── Grid iframe placeholders ──────────────────────── */
.slot-iframe-placeholder {
  width: 100%;
  height: 100%;
}

/* ── Focus View: Loading Overlay ──────────────────── */
.zoomed-loading {
  position: absolute;
  top:0;right:0;bottom:0;left:0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.zoomed-loading.hidden {
  display: none;
}

.zoomed-loading .spinner {
  width: 48px;
  height: 48px;
}

.zoomed-loading .text {
  margin-top: var(--space-4);
  color: var(--text-secondary);
}

.zoomed-loading.is-error .spinner {
  border-color: var(--status-error);
  border-top-color: transparent;
  animation: none;
}

.zoomed-loading.is-error .text {
  color: var(--status-error);
}

/* ── Mobile: stack focus view VNC + chat ──────── */
@media (max-width: 768px) {
  .focus-layout {
    flex-direction: column;
  }
  .focus-layout.debug-mode .focus-vnc-container {
    flex: 0 0 45vh;
  }
  .focus-layout.debug-mode .focus-debug-panel {
    flex: 1;
    min-height: 0;
  }
  .debug-toggle-arrow {
    right: auto;
    left: 50%;
    top: auto;
    bottom: 0;
    transform: translateX(-50%);
    width: auto;
    height: 28px;
    flex-direction: row;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-right: 1px solid var(--border-default);
    border-bottom: none;
    padding: 2px 12px;
  }
  .debug-toggle-label {
    writing-mode: horizontal-tb;
    text-orientation: initial;
  }
  .debug-toggle-arrow .material-icons-outlined {
    transform: rotate(-90deg);
  }
  .focus-layout.debug-mode .debug-toggle-arrow .material-icons-outlined {
    transform: rotate(90deg);
  }
  .chat-input,
  .debug-chat-input {
    font-size: 16px;
  }

  /* ── Mobile: Zoom mode (full-screen VNC) ── */
  body.mobile-zoom .unified-toolbar { display: none; }
  body.mobile-zoom #focusBrowserChrome { display: none !important; }
  body.mobile-zoom .focus-debug-panel { display: none !important; }
  body.mobile-zoom .debug-toggle-arrow { display: none; }
  body.mobile-zoom .focus-vnc-container { flex: 1 !important; }
  body.mobile-zoom .spa-view.active { padding-bottom: 56px; }

  /* ── Mobile: Chat-only mode ── */
  body.mobile-chat .unified-toolbar { display: none; }
  body.mobile-chat #focusBrowserChrome { display: none !important; }
  body.mobile-chat .focus-vnc-container { display: none; }
  body.mobile-chat .debug-toggle-arrow { display: none; }
  body.mobile-chat .focus-debug-panel {
    display: flex !important;
    flex: 1;
    border-left: none;
  }
  body.mobile-chat .spa-view.active { padding-bottom: 56px; }
}

/* Create-tab styling now lives in css/concierge.css — the legacy form was
   replaced with an AI chat-driven authoring surface. */
