/* JSON Formatter — layout on top of the shared design tokens in styles.css */

.jf-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.jf-toolbar button, .jf-toolbar select {
  background: var(--panel-2); cursor: pointer; padding: 8px 14px; font-size: 13px;
}
.jf-toolbar button:hover, .jf-toolbar select:hover { border-color: var(--accent); }
.jf-toolbar button.primary { background: var(--accent); color: var(--on-accent); font-weight: 700; border: none; }
.jf-toolbar button.primary:hover { filter: brightness(1.1); }
.jf-toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.jf-toolbar .grow { flex: 1; }
.jf-toolbar label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.jf-main { flex: 1; display: flex; overflow: hidden; }
.jf-pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.jf-pane.left { border-right: 1px solid var(--border); }
.jf-pane-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px; border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.jf-pane-head .tabs-mini { display: flex; gap: 4px; }
.jf-pane-head .tabs-mini span {
  cursor: pointer; padding: 3px 10px; border-radius: 6px; letter-spacing: 0; text-transform: none; font-size: 12px;
}
.jf-pane-head .tabs-mini span.active { background: var(--panel-2); color: var(--text); }

textarea#jsonInput {
  flex: 1; width: 100%; resize: none; border: none; border-radius: 0;
  background: var(--bg); padding: 16px; font-family: var(--mono);
  font-size: 13px; line-height: 1.6; tab-size: 2;
}
textarea#jsonInput:focus { border: none; }

.jf-output { flex: 1; overflow: auto; padding: 14px 16px; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.jf-output.hidden { display: none; }
.jf-empty { color: var(--muted); padding: 40px; text-align: center; }

/* text (pretty) view with line numbers */
pre#textView { margin: 0; white-space: pre; }
pre#textView .ln {
  display: inline-block; width: 3ch; margin-right: 16px; text-align: right;
  color: #5a5a5a; user-select: none;
}

/* collapsible tree view */
.tree .node { position: relative; }
.tree .row { display: flex; align-items: flex-start; }
.tree .twisty {
  width: 14px; flex: 0 0 14px; cursor: pointer; color: var(--muted);
  user-select: none; text-align: center; transition: transform .12s;
}
.tree .twisty.leaf { visibility: hidden; }
.tree .children { margin-left: 14px; border-left: 1px solid var(--border); padding-left: 8px; }
.tree .k { color: var(--accent-2); }
.tree .colon { color: var(--muted); margin: 0 6px 0 2px; }
.tree .brace, .tree .bracket { color: var(--muted); }
.tree .count { color: #6f6f6f; margin-left: 8px; font-size: 11px; }
.tree .preview { color: #6f6f6f; }
.tree .node:not(.collapsed) > .row > .preview { display: none; }
.tree .node.collapsed > .row > .preview { display: inline; }
.tree .node.collapsed > .children,
.tree .node.collapsed > .close { display: none; }
.tree .node.collapsed > .row > .twisty { transform: rotate(-90deg); }
.tree .v-str { color: var(--green); }
.tree .v-num { color: var(--yellow); }
.tree .v-bool { color: #c084fc; }
.tree .v-null { color: var(--muted); }
.tree .row:hover { background: rgba(255,255,255,.03); }

/* status bar */
.jf-status {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px;
}
.jf-status .badge { font-family: var(--mono); font-weight: 700; padding: 3px 10px; border-radius: 6px; }
.jf-status .badge.ok { background: rgba(52,211,153,.15); color: var(--green); }
.jf-status .badge.bad { background: rgba(248,113,113,.15); color: var(--red); }
.jf-status .badge.idle { background: var(--panel-2); color: var(--muted); }
.jf-status .stat { color: var(--muted); }
.jf-status .stat b { color: var(--text); font-family: var(--mono); }
.jf-status .err { color: var(--red); font-family: var(--mono); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .jf-main { flex-direction: column; }
  .jf-pane.left { border-right: none; border-bottom: 1px solid var(--border); }
}
