/* json-shared.css — Shared styles for JSON/JSONL viewer tools */

:root {
  --bg: #1e1e2e;
  --bg-surface: #252536;
  --bg-hover: #2e2e42;
  --bg-selected: #3a3a55;
  --border: #3a3a55;
  --text: #cdd6f4;
  --text-dim: #7f849c;
  --accent: #89b4fa;
  --accent-hover: #b4d0fb;
  --green: #a6e3a1;
  --peach: #fab387;
  --red: #f38ba8;
  --yellow: #f9e2af;
  --mauve: #cba6f7;
  --teal: #94e2d5;
  --toolbar-h: 44px;
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── Toolbar ──────────────────────────────────────── */
.toolbar {
  height: var(--toolbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
}
.toolbar .filename {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.toolbar .sep {
  width: 1px; height: 20px; background: var(--border); margin: 0 4px;
}
.toolbar .counter {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 80px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.toolbar button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 30px; height: 30px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.toolbar button:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.toolbar button:active { background: var(--bg-selected); }
.toolbar button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.toolbar .spacer { flex: 1; }
.toolbar .view-toggle {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  gap: 4px;
}
.toolbar .view-toggle span { font-size: 12px; }
.toolbar .btn-new-file {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  gap: 4px;
  color: var(--text-dim);
}
.toolbar .btn-new-file:hover { color: var(--text); }

/* ── Split panes ──────────────────────────────────── */
.split-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.left-panel {
  width: 340px;
  min-width: 200px;
  max-width: 600px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.left-panel .search-bar {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.left-panel .search-bar input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.left-panel .search-bar input:focus {
  border-color: var(--accent);
}
.left-panel .search-bar input::placeholder { color: var(--text-dim); }

/* ── Line list ────────────────────────────────────── */
.line-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.line-list::-webkit-scrollbar { width: 6px; }
.line-list::-webkit-scrollbar-track { background: transparent; }
.line-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.line-item {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(58,58,85,.4);
  cursor: pointer;
  transition: background .12s;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.line-item:hover { background: var(--bg-hover); }
.line-item.selected { background: var(--bg-selected); }
.line-item .line-num {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.line-item .line-snippet {
  font-size: 12px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: .85;
}
.line-item.selected .line-snippet { opacity: 1; }
.line-item.parse-error .line-snippet { color: var(--red); }

/* ── Resize handle ────────────────────────────────── */
.resize-handle {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  transition: background .15s;
  flex-shrink: 0;
  z-index: 5;
}
.resize-handle:hover, .resize-handle.active {
  background: var(--accent);
}

/* ── Right panel ──────────────────────────────────── */
.right-panel {
  flex: 1;
  overflow: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.right-panel::-webkit-scrollbar { width: 8px; }
.right-panel::-webkit-scrollbar-track { background: transparent; }
.right-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.right-panel .empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ── Raw JSON view (highlight.js) ─────────────────── */
.raw-json {
  flex: 1;
  overflow: auto;
  margin: 0;
}
.raw-json pre {
  margin: 0;
  padding: 16px;
  font-size: 13px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  line-height: 1.5;
  background: transparent !important;
}

/* ── Tree view ────────────────────────────────────── */
.tree-view {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
}
.tree-view::-webkit-scrollbar { width: 8px; }
.tree-view::-webkit-scrollbar-track { background: transparent; }
.tree-view::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.tv-node { position: relative; }
.tv-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  cursor: pointer;
  user-select: none;
  color: var(--text-dim);
  font-size: 10px;
  transition: transform .15s;
  vertical-align: middle;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  margin-left: -1rem;
}
.tv-toggle.collapsed { transform: rotate(-90deg); }
.tv-key { color: var(--accent); }
.tv-colon { color: var(--text-dim); margin: 0 4px; }
.tv-string { color: var(--green); }
.tv-number { color: var(--peach); }
.tv-boolean { color: var(--mauve); }
.tv-null { color: var(--red); font-style: italic; }
.tv-bracket { color: var(--text-dim); }
.tv-children {
  padding-left: 20px;
  border-left: 1px solid rgba(58,58,85,.5);
  margin-left: 7px;
}
.tv-children.collapsed { display: none; }
.tv-comma { color: var(--text-dim); }
.tv-count { color: var(--text-dim); font-size: 11px; font-style: italic; margin-left: 4px; }

/* Multi-line text block */
.tv-text-block {
  display: block;
  background: rgba(166,227,161,.06);
  border: 1px solid rgba(166,227,161,.15);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 4px 0 4px 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--green);
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 400px;
  overflow: auto;
  cursor: text;
  position: relative;
}
.tv-text-block::-webkit-scrollbar { width: 6px; height: 6px; }
.tv-text-block::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tv-text-label {
  font-size: 10px;
  color: var(--text-dim);
  position: relative;
  top: 0;
  margin-bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  opacity: .7;
  font-style: italic;
}

.tv-text-kind {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border: 1px solid rgba(137,180,250,.3);
  border-radius: 999px;
  color: var(--accent);
  font-size: 10px;
  font-style: normal;
}

.tv-text-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Copy button */
.tv-copy-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
  transition: color .15s, border-color .15s;
}
.tv-copy-btn:hover { color: var(--text); border-color: var(--accent); }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 700px) {
  .left-panel { width: 100% !important; max-width: none; }
  .split-container { flex-direction: column; }
  .resize-handle { display: none; }
  .right-panel { border-top: 1px solid var(--border); }
}
