/* No title-bar banner and no card padding, matching the original jsonparser tool's own layout -
   the toolbar sits directly at the top of a zero-padding card, edge to edge, like the original's
   .card.p-0 > .card-body.p-0. Each section below adds its own padding instead. */
/* Dynamic height: the whole card fits the visible viewport below the topbar instead of growing
   past the fold - toolbar/stats-bar/message keep their natural height, and whichever section
   holds the scrollable content (workspace, or the validator's own workspace) grows to fill
   whatever room is left, scrolling internally instead of the page scrolling. */
.jp-card { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 100px); min-height: 480px; overflow: hidden; }
.jp-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

/* ---- Toolbar ---- */
.jp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; background: #f7f8fa; border-bottom: 1px solid #eee; }

/* White pill-free buttons with a colored left-accent border and colored icon, filling solid with
   that accent color on hover - matches the original jsonparser toolbar exactly, and is kept as an
   explicit exception to this site's "colors come from common.css only" rule (approved for this
   tool specifically). Each .jp-c-* class only sets --jp-accent; the shared rules below do the
   rest, the same pattern the original used with --jt-accent. */
.jp-btn { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #d7dbe1; border-left: 3px solid var(--jp-accent, var(--site-accent)); color: #23272f; padding: 7px 13px; border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s ease; }
.jp-btn:hover { background: var(--jp-accent, var(--site-dark)); border-color: var(--jp-accent, var(--site-dark)); color: #fff; }
.jp-btn i { color: var(--jp-accent, var(--site-accent)); }
.jp-btn:hover i { color: #fff; }
.jp-btn:active { transform: translateY(1px); }
.jp-btn-primary { --jp-accent: var(--site-dark); }
.jp-btn.jp-btn-active { background: var(--site-accent); border-color: var(--site-accent); color: #fff; }
.jp-btn.jp-btn-active i { color: #fff; }

.jp-btn.jp-c-format { --jp-accent: var(--site-blue); }
.jp-btn.jp-c-minify { --jp-accent: var(--site-slate); }
.jp-btn.jp-c-copy { --jp-accent: var(--site-success); }
.jp-btn.jp-c-download { --jp-accent: var(--site-violet); }
.jp-btn.jp-c-sample { --jp-accent: var(--site-cyan); }
.jp-btn.jp-c-clear { --jp-accent: var(--site-danger); }
.jp-btn.jp-c-classgen { --jp-accent: var(--site-orange); }

/* Full-width exception (approved for this tool only) - the tool card sits in its own
   container-fluid ABOVE the normal ad-rail page-layout grid (see json-parser.html), matching the
   original jsonparser tool's own layout, so the two-pane input/tree workspace gets the full page
   width instead of sharing it with the 280px side ad rails. */
.jp-full-width { max-width: 100%; padding: 0 15px; }

.jp-select { border: 1px solid #d7dbe1; border-radius: 7px; padding: 7px 10px; font-size: 13px; font-family: inherit; color: #23272f; background: #fff; cursor: pointer; }
.jp-select:focus { outline: none; border-color: var(--site-light); }

.jp-toolbar-spacer { flex: 1 1 auto; }

/* Search grows to fill the remaining toolbar space (matches the original's jt-search-wrap:
   flex:1 1 140px), filter stays sized to its own content - not a fixed width on either. */
.jp-search-wrap, .jp-filter-wrap { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #d7dbe1; border-radius: 7px; padding: 6px 12px; }
.jp-search-wrap { flex: 1 1 140px; min-width: 120px; }
.jp-filter-wrap { flex: 0 0 auto; }
.jp-search-wrap i, .jp-filter-wrap i { color: #9aa0aa; font-size: .85em; }
.jp-search-wrap input { border: none; outline: none; font-size: 13px; font-family: inherit; width: 100%; background: transparent; }
.jp-filter-wrap select { border: none; outline: none; font-size: 13px; font-family: inherit; background: transparent; cursor: pointer; }

/* ---- Stats bar ---- */
.jp-stats-bar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px 16px; font-size: 12px; color: #6b7280; background: #fbfbfc; border-bottom: 1px solid #eee; }
.jp-analysis { font-weight: 600; color: var(--site-dark); }
.jp-analysis.jp-analysis-invalid { color: var(--site-danger); }

/* ---- Message banner (validation feedback) ---- */
.jp-message { display: flex; align-items: flex-start; gap: 8px; border-radius: 8px; padding: 10px 14px; font-size: .88em; margin: 14px 16px; line-height: 1.5; }
.jp-message.hide { display: none; }
.jp-message i { margin-top: 2px; flex-shrink: 0; }
.jp-message-error { background: var(--site-danger-bg); color: var(--site-danger); border: 1px solid var(--site-danger-border); }
.jp-message-success { background: var(--site-success-bg); color: var(--site-success); border: 1px solid var(--site-success-border); }

/* ---- Workspace: input | tree view ---- */
/* Edge-to-edge columns (no gap, each side has its own border) - matches the original's
   Bootstrap .row/.col-md-6 layout where .input-area/.output-area sit flush against each other. */
.jp-workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; flex: 1 1 auto; min-height: 0; }
.jp-col { box-sizing: border-box; min-height: 0; }

/* Only the Tree View side has a header, matching the original's .json-output-head (uppercase,
   dashed underline, no icon) - the input side has no header, just the bare textarea. */
.jp-col-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 15px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; border-bottom: 1px dashed #e5e7eb; }

/* Small copy/download buttons reuse the same .jp-btn look (white + left-accent-border + hover
   fill), just smaller - matches the original's "jt-btn jt-btn-sm" (same base button class, a
   size modifier only), instead of being a visually distinct pill-shaped button of their own. */
.jp-btn.jp-btn-sm { padding: 4px 10px; font-size: 12px; }
.jp-btn.jp-copied { --jp-accent: var(--site-success); }

/* Dynamic input height: the input textarea has no explicit height of its own - it stretches to
   match whatever height the Tree View side ends up being (header + fixed-height tree box), the
   same way the original's Bootstrap .row/.col-md-6 layout stretches .input-area to match
   .output-area's explicit height automatically. */
.jp-workspace { align-items: stretch; }
.jp-col { display: flex; flex-direction: column; }

/* Shared by both the Parser view's textarea AND the Validator view's own textarea (#jpValidatorInput)
   - they must look and behave identically, only their JS wiring differs. */
#jpInput, #jpValidatorInput { flex: 1 1 auto; min-height: 0; width: 100%; border: solid 1px #eee; border-radius: 0; padding: 15px; font-family: "Courier New", Courier, monospace; font-size: .88em; line-height: 1.55; resize: none; box-sizing: border-box; outline: none; }

/* Dynamic height: fills whatever room is left inside the now viewport-fitted .jp-card (see
   .jp-card above), scrolling internally, rather than a fixed pixel value. The input textarea
   (#jpInput) has no height of its own; it stretches to match this side via the grid row. */
.jp-tree-container { flex: 1 1 auto; height: auto; min-height: 0; overflow: auto; border: solid 1px #eee; border-top: none; border-radius: 0; padding: 14px 16px; font-family: "Courier New", monospace; font-size: .85em; line-height: 1.6; background: #fff; box-sizing: border-box; }
.jp-tree-placeholder { color: #9ca3af; font-style: italic; font-family: "Nunito", "Segoe UI", Arial, sans-serif; font-size: .95em; }

/* ---- Tree nodes ---- */
.jp-node { position: relative; }
.jp-line { display: flex; align-items: flex-start; gap: 2px; padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.jp-children { margin-left: 15px; padding-left: 10px; border-left: 1px dashed #e5e7eb; }

/* +/- expand/collapse toggle, matching the original tree view's own icon convention (its
   .json-expand-plus feature) instead of a triangle. Minus = expanded (click to collapse),
   Plus = collapsed (click to expand). */
.jp-toggle, .jp-toggle-spacer { width: 14px; height: 14px; flex-shrink: 0; text-align: center; line-height: 14px; }
.jp-toggle { cursor: pointer; color: #6b7280; border: 1px solid #d7dbe1; border-radius: 3px; font-weight: 700; }
.jp-toggle::before { content: "\2212"; font-size: 11px; }
.jp-node.jp-collapsed > .jp-line > .jp-toggle::before { content: "+"; }
.jp-node.jp-collapsed > .jp-children, .jp-node.jp-collapsed > .jp-close { display: none; }
.jp-count { display: none; margin-left: 6px; color: #9ca3af; font-style: italic; }
.jp-node.jp-collapsed > .jp-line > .jp-count { display: inline; }

.jp-key { color: var(--site-dark); font-weight: 600; }
.jp-index { color: #9ca3af; margin-right: 2px; }
.jp-colon { color: #6b7280; }
.jp-bracket { color: #374151; font-weight: 700; }

.jp-val-string { color: var(--site-success); }
.jp-val-number { color: var(--site-accent); }
.jp-val-boolean-true, .jp-val-boolean-false { font-weight: 700; }
.jp-val-boolean-true { color: var(--site-success); }
.jp-val-boolean-false { color: var(--site-danger); }
.jp-val-null { color: #9ca3af; font-style: italic; }

.jp-search-match { background: var(--site-accent); color: #fff; border-radius: 3px; padding: 0 3px; }

/* ---- Generate Class popup (a real modal, not an inline panel - matches the original's
   Bootstrap modal for this feature) ---- */
.jp-modal-backdrop { position: fixed; inset: 0; background: rgba(15,17,23,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 200; }
.jp-modal-backdrop.hide { display: none; }
.jp-modal { background: #fff; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.25); width: 100%; max-width: 720px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.jp-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid #eee; }
.jp-modal-head h3 { margin: 0; font-size: 1.05em; display: flex; align-items: center; gap: 8px; color: #23272f; }
.jp-modal-head h3 i { color: var(--site-orange); }
.jp-modal-close { background: none; border: none; font-size: 1.1em; color: #9aa0aa; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.jp-modal-close:hover { background: #f3f4f6; color: #23272f; }
.jp-modal-body { padding: 20px; overflow-y: auto; }

.jp-classgen-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.jp-classgen-controls label { display: flex; flex-direction: column; gap: 5px; font-size: .8em; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: .03em; }
.jp-classgen-controls input[type="text"] { border: 1px solid #ddd; border-radius: 8px; padding: 7px 12px; font-size: .9em; font-family: inherit; min-width: 160px; }
.jp-classgen-controls input[type="text"]:focus { outline: none; border-color: var(--site-light); }
.jp-classgen-actions { display: flex; gap: 8px; margin-left: auto; }

.jp-classgen-output { background: #1e1e2e; color: #d4d4e0; border-radius: 8px; padding: 16px 18px; font-family: "Courier New", monospace; font-size: .85em; line-height: 1.6; overflow-x: auto; overflow-y: auto; max-height: 420px; white-space: pre; margin: 0; }

/* ---- Validator view (second header tab) - mirrors the original's separate Parser/Validator
   toggle: a plain input on the left, Validate/Format/Copy actions and a result box on the right. */
.jp-view-validator .jp-col:last-child { display: flex; flex-direction: column; min-height: 0; }
.jp-view-validator .jp-validator-result { flex: 1 1 auto; min-height: 0; }
.jp-view-validator .jp-col:last-child { padding: 20px; box-sizing: border-box; }
.jp-validator-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.jp-validator-result { padding: 1em; margin: 0; font-family: "Courier New", monospace; font-size: .88em; line-height: 1.6; overflow: auto; flex: 1 1 auto; }
.jp-validator-result.jp-result-pass { background: var(--site-success-bg); color: var(--site-success); border: 1px solid var(--site-success-border); border-radius: 8px; }
.jp-validator-result.jp-result-fail { background: var(--site-danger-bg); color: var(--site-danger); border: 1px solid var(--site-danger-border); border-radius: 8px; }

@media (max-width: 900px) {
    /* The dynamic viewport-fit height only makes sense on screens roomy enough to show the whole
       tool above the fold - on narrow/short screens, fall back to natural content height (the
       page scrolls normally) with a fixed, reasonable size per stacked panel instead. */
    .jp-card { height: auto; min-height: 0; overflow: visible; }
    .jp-workspace { grid-template-columns: 1fr; flex: none; }
    #jpInput, #jpValidatorInput, .jp-tree-container { flex: none; height: 400px; }
    .jp-tree-container { border-top: solid 1px #eee; }
    .jp-classgen-actions { margin-left: 0; }
}

@media (max-width: 600px) {
    .jp-toolbar-spacer { display: none; }
}
