/* ============================================================
 * json-studio.css - JSON 解析工具专用样式
 * 全屏左右分栏布局，依赖 common.css 的全局变量
 * ============================================================ */

/* 占满整个视口，不滚动 body */
body.json-page {
  height: 100vh;
  overflow: hidden;
}
body.json-page.tool-page {
  min-height: 0;
  padding-bottom: 0;
}

.json-shell {
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- 顶部功能指引入口 ---------- */
.json-funcbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.func-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.func-tabs::-webkit-scrollbar { display: none; }
.func-btn {
  background: none;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 15px 12px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 8px 8px 0 0;
  transition: 0.16s;
}
.func-btn:hover { color: var(--text); background: rgba(255,255,255,.03); }
.func-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-soft);
}
.func-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  padding-bottom: 8px;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: livePulse 2s infinite;
}
@keyframes livePulse { 50% { opacity: .45; } }

/* ---------- 操作工具栏 ---------- */
.json-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.tb-group { display: flex; gap: 6px; flex-wrap: wrap; }
.tb-act {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  transition: 0.16s;
  white-space: nowrap;
}
.tb-act:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.tb-act:active { transform: translateY(1px); }
.tb-act.danger:hover { color: var(--danger); border-color: var(--danger); }
.tb-sep { width: 1px; height: 22px; background: var(--border); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.indent-label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.indent-label select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 12px;
}

/* ---------- 左右分栏主体 ---------- */
.json-main {
  flex: 1;
  display: flex;
  min-height: 0; /* 关键：允许子项收缩以启用内部滚动 */
}
.jpane {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.jpane-left { border-right: none; }

.jpane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  min-height: 42px;
}
.jp-title { font-size: 12.5px; font-weight: 700; color: var(--text); }
.jp-sub { color: var(--text-dim); font-weight: 400; margin-left: 6px; }
.jp-tools { display: flex; align-items: center; gap: 6px; }
.jp-mini {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  transition: 0.16s;
}
.jp-mini:hover { color: var(--text); border-color: var(--border-strong); }

.jpane-body {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* ---------- 输入区（带行号） ---------- */
.gutter {
  flex: 0 0 46px;
  padding: 14px 8px 14px 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-dim);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  white-space: pre;
  user-select: none;
  box-sizing: border-box;
}
#json-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  resize: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  padding: 14px 16px;
  white-space: pre;
  tab-size: 2;
  overflow: auto;
}
#json-input::placeholder { color: var(--text-dim); }

/* ---------- 可拖动分隔条 ---------- */
.jsplit {
  flex: 0 0 8px;
  cursor: col-resize;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.16s;
  z-index: 5;
}
.jsplit:hover, .jsplit.dragging { background: var(--primary-soft); }
.jsplit-grip {
  width: 3px;
  height: 34px;
  border-radius: 3px;
  background: var(--border-strong);
}
.jsplit:hover .jsplit-grip, .jsplit.dragging .jsplit-grip { background: var(--primary); }

/* ---------- 结果区 ---------- */
.jpane-result { display: block; overflow: auto; }
/* 树形/文本 分段切换器（本页独立引入，不依赖 tools.css） */
.segment {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.segment button {
  background: none;
  border: none;
  color: var(--text-muted);
  border-radius: 6px;
  font-weight: 600;
  transition: 0.16s;
}
.segment button:hover { color: var(--text); }
.segment button.active { background: var(--primary-soft); color: var(--primary); }
.segment button.disabled { opacity: 0.35; cursor: not-allowed; }
.segment button.disabled:hover { color: var(--text-muted); }
.seg-sm button { padding: 4px 10px; font-size: 11.5px; }

.json-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 13px;
  pointer-events: none;
}
.empty-icon {
  font-family: var(--mono);
  font-size: 40px;
  font-weight: 700;
  color: var(--border-strong);
}
.readonly-out {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  padding: 14px 16px;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}

.json-error {
  position: absolute;
  left: 16px; right: 16px; top: 16px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 12px 14px;
  color: #ffb3bc;
  font-size: 12.5px;
  font-family: var(--mono);
  line-height: 1.7;
  z-index: 3;
}
.json-error b { color: var(--danger); }

/* ---------- JSON 树 ---------- */
.json-tree {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  padding: 12px 0 40px;
  color: var(--text);
  min-height: 100%;
}
.jnode { position: relative; }
.jnode-row {
  display: flex;
  align-items: flex-start;
  padding: 1px 16px;
  white-space: pre;
  min-height: 21px;
}
.jnode-row:hover { background: rgba(255,255,255,.035); }
.jtoggle {
  width: 15px;
  flex: 0 0 15px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  text-align: center;
  transition: transform 0.12s;
}
.jtoggle:hover { color: var(--primary); }
.jtoggle.collapsed { transform: rotate(-90deg); }
.jtoggle.leaf { cursor: default; opacity: 0.25; }
.jkey { color: #9db4ff; }
.jcolon { color: var(--text-dim); }
.jstring { color: #6fe3c6; }
.jnumber { color: #f7cd82; }
.jboolean { color: #c6a1ff; }
.jnull { color: #8892a6; font-style: italic; }
.jbrace { color: var(--text-muted); }
.jbadge {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 8px;
}
.jchildren { padding-left: 22px; }
.jchildren.hidden { display: none; }
.jellipsis { color: var(--text-dim); font-style: italic; }

/* ---------- 底部状态栏 ---------- */
.json-status {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 7px 20px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.json-status::-webkit-scrollbar { display: none; }
.json-status b { color: var(--text); font-weight: 700; font-family: var(--mono); }
.st-right { margin-left: auto; color: var(--text-dim); }
.pill-bad { color: var(--danger); font-weight: 600; }

@media (max-width: 760px) {
  .func-meta { display: none; }
  .jp-sub { display: none; }
  .json-status { gap: 12px; }
  .st-right { display: none; }
}
