/* ==============================================================================
   DuckDB Studio - Navicat Style Desktop UI Theme
   Strictly complies with BoxyKit /shared/v1/tokens.css design specifications.
   Zero hardcoded dark/light values - dynamic tokens throughout.
   ============================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Sizing tokens */
  --header-height: 56px;
  --toolbar-height: 42px;
  --statusbar-height: 30px;
  --sidebar-default-width: 280px;
  --sidebar-min-width: 200px;
  --sidebar-max-width: 600px;
  --editor-min-height: 120px;
  --grid-min-height: 140px;

  /* Custom grid & component accents mapped to design tokens */
  --grid-row-height: 32px;
  --grid-border: var(--border-color, var(--border-subtle));
  --grid-hover-bg: var(--primary-light, rgba(99, 102, 241, 0.08));
  --grid-selected-bg: var(--primary-light, rgba(99, 102, 241, 0.16));
  --grid-header-bg: var(--bg-surface-elevated, var(--bg-secondary));
  --grid-zebra-bg: rgba(125, 125, 125, 0.03);

  --cm-keyword: #818cf8;
  --cm-operator: #38bdf8;
  --cm-string: #34d399;
  --cm-number: #fbbf24;
  --cm-comment: #64748b;
  --cm-builtin: #c084fc;
}

[data-theme="light"] {
  --grid-border: rgba(0, 0, 0, 0.12);
  --grid-header-bg: #e2e8f0;
  --grid-zebra-bg: rgba(0, 0, 0, 0.02);
  --grid-hover-bg: rgba(79, 70, 229, 0.06);
  --grid-selected-bg: rgba(79, 70, 229, 0.12);

  --cm-keyword: #4338ca;
  --cm-operator: #0284c7;
  --cm-string: #059669;
  --cm-number: #d97706;
  --cm-comment: #94a3b8;
  --cm-builtin: #7c3aed;
}

/* Global Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Decorative subtle aura glows */
.bg-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.aurora-orb-1 {
  position: absolute;
  top: -150px;
  right: 10%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  filter: blur(80px);
  opacity: 0.45;
}

.aurora-orb-2 {
  position: absolute;
  bottom: -150px;
  left: 5%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  filter: blur(80px);
  opacity: 0.35;
}

/* App Outer Container */
.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Top Navigation / Header Actions Slot */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-engine {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.25);
  letter-spacing: 0.3px;
}

/* Navicat Top Toolbar */
.quick-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--toolbar-height);
  padding: 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 8px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

/* Desktop Action Buttons */
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast, 150ms ease);
}

.tool-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.tool-btn:active {
  transform: translateY(0);
}

.tool-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.tool-btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.tool-btn.danger {
  background: var(--color-danger-bg);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--color-danger);
}

.tool-btn.danger:hover {
  background: var(--color-danger);
  color: #ffffff;
}

.tool-btn.disabled, .tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.tool-icon {
  font-size: 14px;
  line-height: 1;
}

.tool-select {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.tool-select:focus {
  border-color: var(--primary);
}

/* Main Workspace: Three-Pane / Split-Pane Container */
.workspace-container {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* ==============================================================================
   1. Left Sidebar: Object Tree (Navicat Explorer)
   ============================================================================== */
.sidebar-pane {
  width: var(--sidebar-default-width);
  min-width: var(--sidebar-min-width);
  max-width: var(--sidebar-max-width);
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}

.sidebar-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-secondary);
}

.db-connection-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.db-connection-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
}

.db-status-pill {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--border-subtle);
}

.sidebar-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-search-input {
  width: 100%;
  height: 26px;
  padding: 0 8px 0 24px;
  font-size: 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.sidebar-search-input:focus {
  border-color: var(--primary);
}

.sidebar-search-icon {
  position: absolute;
  left: 7px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Object Tree View */
.object-tree-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

.tree-node {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
  border-left: 2px solid transparent;
  transition: background var(--transition-fast);
  white-space: nowrap;
}

.tree-node:hover {
  background: var(--grid-hover-bg);
}

.tree-node.active {
  background: var(--grid-selected-bg);
  border-left-color: var(--primary);
  font-weight: 500;
}

.tree-indent {
  display: inline-block;
  width: 14px;
  flex-shrink: 0;
}

.tree-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.tree-caret.expanded {
  transform: rotate(90deg);
}

.tree-icon {
  margin-right: 6px;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-badge {
  font-size: 10px;
  padding: 0 5px;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  margin-left: 6px;
}

.tree-type-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
  font-style: normal;
}

.sidebar-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Horizontal Drag Resizer (Sidebar Separator) */
.resizer-h {
  width: 5px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 10;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.resizer-h:hover, .resizer-h.dragging {
  background: var(--primary);
}

/* ==============================================================================
   2. Center & Right Main Workspace (Editor + Result Grid)
   ============================================================================== */
.main-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
  overflow: hidden;
}

/* SQL Tabs Bar */
.sql-tabs-bar {
  display: flex;
  align-items: center;
  height: 36px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  gap: 2px;
}

.sql-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all var(--transition-fast);
}

.sql-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.sql-tab.active {
  color: var(--text-primary);
  background: var(--bg-primary);
  border-color: var(--primary);
  border-bottom: 1px solid var(--bg-primary);
  font-weight: 500;
  box-shadow: 0 -2px 0 var(--primary);
}

.sql-tab-title {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sql-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}

.sql-tab-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.btn-add-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  border: 1px dashed var(--border-color);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  margin-left: 4px;
  transition: all var(--transition-fast);
}

.btn-add-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* SQL Editor Container */
.sql-editor-container {
  flex: 1;
  min-height: var(--editor-min-height);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Error Shake Animation & Red Outline when SQL fails */
@keyframes shake-error {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.sql-editor-container.input-error-highlight {
  animation: shake-error 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  box-shadow: 0 0 0 2px var(--color-danger), 0 0 16px rgba(239, 68, 68, 0.35) !important;
}

/* CodeMirror Integration & Custom High-Contrast Theme */
.CodeMirror {
  height: 100% !important;
  font-family: var(--font-mono) !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
}

.CodeMirror-gutters {
  background: var(--bg-secondary) !important;
  border-right: 1px solid var(--border-color) !important;
  padding: 0 4px;
}

.CodeMirror-linenumber {
  color: var(--text-muted) !important;
  font-size: 11.5px;
}

.CodeMirror-cursor {
  border-left: 2px solid var(--primary) !important;
}

.CodeMirror-selected {
  background: var(--grid-selected-bg) !important;
}

.CodeMirror-focused .CodeMirror-selected {
  background: var(--primary-light) !important;
}

.cm-s-duckdb span.cm-keyword { color: var(--cm-keyword); font-weight: 600; }
.cm-s-duckdb span.cm-operator { color: var(--cm-operator); }
.cm-s-duckdb span.cm-string { color: var(--cm-string); }
.cm-s-duckdb span.cm-number { color: var(--cm-number); }
.cm-s-duckdb span.cm-comment { color: var(--cm-comment); font-style: italic; }
.cm-s-duckdb span.cm-builtin { color: var(--cm-builtin); font-weight: 500; }
.cm-s-duckdb span.cm-variable { color: var(--text-primary); }
.cm-s-duckdb span.cm-def { color: var(--primary); }

/* CodeMirror Hint / Autocomplete Dropdown */
.CodeMirror-hints {
  background: var(--bg-surface-elevated) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  z-index: 1000 !important;
}

.CodeMirror-hint {
  padding: 4px 8px !important;
  color: var(--text-primary) !important;
}

li.CodeMirror-hint-active {
  background: var(--primary) !important;
  color: #ffffff !important;
}

/* Vertical Drag Resizer (Between Editor & Result Grid) */
.resizer-v {
  height: 5px;
  width: 100%;
  cursor: row-resize;
  background: var(--border-color);
  position: relative;
  z-index: 10;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.resizer-v:hover, .resizer-v.dragging {
  background: var(--primary);
}

/* ==============================================================================
   3. Bottom Data Grid & Console Panel (Navicat Output)
   ============================================================================== */
.result-panel {
  height: 320px;
  min-height: var(--grid-min-height);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

/* Result Header Tabs */
.result-nav-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 8px;
  flex-shrink: 0;
}

.result-tabs-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.result-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.result-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.result-tab-btn.active {
  color: var(--primary);
  background: var(--primary-light);
  border-color: rgba(99, 102, 241, 0.25);
}

.result-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.grid-filter-input {
  height: 22px;
  width: 140px;
  padding: 0 6px;
  font-size: 11px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
}

.grid-filter-input:focus {
  border-color: var(--primary);
}

.btn-mini {
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-mini:hover {
  background: var(--bg-surface-elevated);
}

/* Result Content Stages */
.result-content-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: none;
}

.result-content-stage.active {
  display: flex;
  flex-direction: column;
}

/* Virtual Scroll Table Architecture */
.virtual-grid-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: auto;
  position: relative;
  background: var(--bg-primary);
}

.virtual-grid-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  background: var(--grid-header-bg);
  border-bottom: 2px solid var(--grid-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  min-width: 100%;
  width: max-content;
}

.grid-header-cell {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-right: 1px solid var(--grid-border);
  user-select: none;
  cursor: pointer;
  background: inherit;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.grid-header-cell:hover {
  background: var(--grid-hover-bg);
}

.grid-header-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-sort-icon {
  margin-left: 4px;
  font-size: 10px;
  color: var(--primary);
  opacity: 0.3;
}

.grid-sort-icon.sorted {
  opacity: 1;
}

.virtual-grid-canvas {
  position: relative;
  width: max-content;
  min-width: 100%;
}

.virtual-grid-row {
  position: absolute;
  left: 0;
  display: flex;
  height: var(--grid-row-height);
  line-height: var(--grid-row-height);
  border-bottom: 1px solid var(--grid-border);
  min-width: 100%;
  width: max-content;
  transition: background var(--transition-fast);
}

.virtual-grid-row:nth-child(even) {
  background: var(--grid-zebra-bg);
}

.virtual-grid-row:hover {
  background: var(--grid-hover-bg);
}

.virtual-grid-row.selected {
  background: var(--grid-selected-bg) !important;
}

.grid-cell {
  height: 100%;
  padding: 0 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  border-right: 1px solid var(--grid-border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: text;
}

.grid-cell.cell-null {
  color: var(--text-muted);
  font-style: italic;
}

.grid-cell.cell-num {
  text-align: right;
  color: var(--cm-number);
}

.grid-cell.cell-index {
  background: var(--grid-header-bg);
  color: var(--text-muted);
  text-align: center;
  user-select: none;
  font-size: 11px;
}

/* Empty or Loading Grid States */
.grid-placeholder-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 10px;
  padding: 30px;
  text-align: center;
}

.grid-placeholder-icon {
  font-size: 36px;
  opacity: 0.7;
}

/* Error Console View */
.console-output-container {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-input);
  color: var(--text-primary);
}

.console-entry {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  border-left: 3px solid transparent;
}

.console-entry.error {
  background: var(--color-danger-bg);
  border-left-color: var(--color-danger);
  color: var(--text-primary);
}

.console-entry.info {
  background: var(--primary-light);
  border-left-color: var(--primary);
}

.console-stack {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(239, 68, 68, 0.25);
  color: var(--color-danger);
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Table Schema & DDL View */
.schema-view-container {
  flex: 1;
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.schema-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.schema-table th, .schema-table td {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.schema-table th {
  background: var(--bg-secondary);
  font-weight: 600;
}

/* Status Bar */
.app-statusbar {
  height: var(--statusbar-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11.5px;
  color: var(--text-secondary);
  flex-shrink: 0;
  user-select: none;
}

.statusbar-left, .statusbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-metric {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-metric-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.status-dot.busy {
  background: var(--color-warning);
  box-shadow: 0 0 6px var(--color-warning);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* Context Menu (Desktop Navicat Right-Click) */
.desktop-context-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 160px;
  user-select: none;
  animation: context-menu-fade 0.12s ease;
}

@keyframes context-menu-fade {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.context-menu-item:hover {
  background: var(--primary);
  color: #ffffff;
}

.context-menu-item.danger:hover {
  background: var(--color-danger);
  color: #ffffff;
}

.context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* Modal Dialogs (Import / Export / Confirm) */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay, rgba(3, 7, 18, 0.65));
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.dialog-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.dialog-box {
  background: var(--bg-surface-solid, var(--bg-surface));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(10px) scale(0.98);
  transition: transform var(--transition-fast);
}

.dialog-backdrop.open .dialog-box {
  transform: translateY(0) scale(1);
}

.dialog-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.dialog-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.dialog-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
}

.dialog-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
}

/* SEO Content Section (Collapsible / Bottom for Crawler indexability) */
.seo-knowledge-section {
  display: none; /* Accessible in DOM for SEO pre-rendering and crawler bots */
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar-pane {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }
  .sidebar-pane.mobile-open {
    transform: translateX(0);
  }
}

/* Subtools Switcher Tabs Bar */
.subtool-nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  overflow-x: auto;
}

.subtool-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.subtool-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.subtool-tab-btn.active {
  color: var(--primary);
  background: var(--primary-light);
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 600;
}

/* Tool Isolated Views Container */
.tool-view {
  display: none !important;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.tool-view.active {
  display: flex !important;
}

.tool-view-flex-row {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  flex-direction: row;
}

.tool-view-full {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 20px;
  overflow-y: auto;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-primary);
}

.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Drag & Drop File Zone */
.dropzone-container {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 36px 20px;
  text-align: center;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.dropzone-container:hover, .dropzone-container.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone-icon {
  font-size: 38px;
  opacity: 0.85;
}

.dropzone-text-main {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-text-sub {
  font-size: 12px;
  color: var(--text-muted);
}

