/* JSON formatter - input textarea + collapsible output tree, indent toggle, error + size stats.
   Reuses base .btn / .btn-outline / .seg / .copy-btn; colors come from theme tokens only. */

/* Toolbar: actions on the left, indent control on the right. */
.jf-toolbar {
    display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
    justify-content: space-between; margin-bottom: 16px;
}
.jf-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.jf-indent { display: flex; align-items: center; gap: 10px; }
.jf-indent-label { font-size: 14px; color: var(--muted); font-weight: 600; }

/* Panes: side by side on wide screens, stacked on narrow. */
.jf-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .jf-panes { grid-template-columns: 1fr; } }

.jf-pane { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.jf-pane-head { display: flex; align-items: center; justify-content: space-between; min-height: 28px; }
.jf-pane-label { font-size: 14px; color: var(--muted); font-weight: 600; }

.jf-out-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Input textarea + the output tree share box metrics so the two panes line up. */
.jf-area, .jf-tree {
    width: 100%; box-sizing: border-box; min-height: 320px; resize: vertical;
    font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
    font-size: 14px; line-height: 1.6; padding: 12px;
    color: var(--text); border: 1px solid var(--border); border-radius: 12px;
    overflow: auto;
}
.jf-area { background: var(--surface); tab-size: 2; white-space: pre; }
.jf-area:focus, .jf-tree:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* Output: collapsible, syntax-highlighted tree of the parsed JSON. */
.jf-tree { background: var(--bg); white-space: nowrap; }
.jf-children { padding-left: 18px; margin-left: 6px; border-left: 1px solid var(--border); }

.jf-toggle {
    appearance: none; border: 0; background: none; cursor: pointer; padding: 0;
    width: 14px; height: 14px; margin-right: 4px; vertical-align: middle;
    display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.jf-toggle:hover { color: var(--accent); }
.jf-toggle:focus-visible { outline: 2px solid var(--accent); border-radius: 3px; }
.jf-toggle::before {
    content: ""; border-left: 5px solid currentColor;
    border-top: 4px solid transparent; border-bottom: 4px solid transparent;
    transform: rotate(90deg); transition: transform .12s ease;
}
.jf-node.is-collapsed > .jf-open .jf-toggle::before { transform: rotate(0deg); }

/* Collapsed: hide the children and closing bracket, reveal the inline summary. */
.jf-summary { display: none; color: var(--muted); }
.jf-node.is-collapsed > .jf-open .jf-summary { display: inline; }
.jf-node.is-collapsed > .jf-children,
.jf-node.is-collapsed > .jf-close { display: none; }

/* Syntax colors - theme tokens only. */
.jf-key { color: var(--accent); }
.jf-punct { color: var(--muted); }
.jf-str { color: var(--good); }
.jf-num { color: var(--text); }
.jf-bool { color: var(--accent-strong); }
.jf-null { color: var(--muted); font-style: italic; }

.jf-toobig { margin: 0; color: var(--muted); white-space: normal; }

.jf-error { margin: 14px 0 0; font-variant-numeric: tabular-nums; }
.jf-stats {
    margin: 12px 0 0; color: var(--muted); font-size: 14px;
    font-variant-numeric: tabular-nums; min-height: 1.2em;
}
