/* ── JSON Tools ─────────────────────────────────────────────────────────────
   Dark code-editor panels + tree view + stats grid
   Uses --color-* variables from site.css for light/dark transitions,
   but editor panels stay dark regardless of page theme.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Action Bar ────────────────────────────────────────────────────────── */
.jt-tool {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.jt-action-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.jt-action-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 7px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    text-decoration: none;
    font-family: var(--font-body);
    line-height: 1;
}

.jt-action-btn:hover {
    background: var(--color-bg-secondary);
    border-color: var(--color-border-focus);
    color: var(--color-text);
}

.jt-action-btn.active {
    background: var(--gradient-accent);
    border-color: transparent;
    color: #ffffff;
}

.jt-action-btn.jt-fix-btn {
    color: var(--color-warning);
    border-color: rgba(245, 158, 11, 0.3);
}

.jt-action-btn.jt-fix-btn:hover {
    background: var(--color-warning-light);
    border-color: var(--color-warning);
}

.jt-action-sep {
    width: 1px;
    height: 22px;
    background: var(--color-border);
    flex-shrink: 0;
}

.jt-action-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ── Editor Area ────────────────────────────────────────────────────────── */
.jt-editor-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* ── Shared Pane Shell ──────────────────────────────────────────────────── */
.jt-editor-pane,
.jt-output-pane {
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #0F172A;
    border: 1px solid #1E293B;
    height: 480px; /* fixed height — content scrolls inside, not page */
    min-height: 0; /* let it shrink if needed */
}

.jt-pane-header,
.jt-tab-bar,
.jt-output-toolbar {
    display: flex;
    align-items: center;
    padding: 7px 12px;
    background: #1E293B;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
    gap: var(--space-2);
}

.jt-pane-header { justify-content: space-between; }
.jt-output-toolbar { border-bottom: none; border-top: 1px solid #334155; }

.jt-pane-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.jt-pane-meta {
    display: flex;
    gap: var(--space-3);
    font-size: var(--text-xs);
    color: #4B5563;
}

/* ── Input Editor ───────────────────────────────────────────────────────── */
.jt-input-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.jt-line-nums {
    padding: 12px 8px 12px 12px;
    color: #334155;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    text-align: right;
    user-select: none;
    pointer-events: none;
    overflow: hidden;
    min-width: 38px;
    white-space: pre;
    flex-shrink: 0;
    background: #0F172A;
}

.jt-input {
    flex: 1;
    padding: 12px 14px;
    background: transparent;
    border: none;
    outline: none;
    color: #E2E8F0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    resize: none;
    overflow: auto;
    white-space: pre;
    tab-size: 4;
    caret-color: #93C5FD;
}

.jt-input::placeholder { color: #334155; }

/* ── Tab Bar ────────────────────────────────────────────────────────────── */
.jt-tab-bar { padding: 0 12px; }

.jt-tab-btn {
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: #64748B;
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--font-body);
}

.jt-tab-btn:hover { color: #94A3B8; }
.jt-tab-btn.active { color: #93C5FD; border-bottom-color: #93C5FD; }

.jt-tab-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ── Output / Tree / Stats Panels ───────────────────────────────────────── */
.jt-panel {
    display: block;
    flex: 1;
    overflow: auto;
    padding: 12px 14px;
    position: relative;
    background: #0F172A;
}

.jt-output-code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre;
    color: #E2E8F0;
    display: block;
    background: transparent;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
}

/* ── Syntax Highlight Colors ────────────────────────────────────────────── */
.jt-key    { color: #93C5FD; }
.jt-string { color: #86EFAC; }
.jt-number { color: #FDE68A; }
.jt-bool   { color: #FB923C; }
.jt-null   { color: #F87171; }

/* ── Search Highlight ───────────────────────────────────────────────────── */
.jt-search-mark {
    background: #FDE68A;
    color: #0F172A;
    border-radius: 2px;
    padding: 0 1px;
}

/* ── Badge ──────────────────────────────────────────────────────────────── */
.jt-badge {
    display: none;
    align-items: center;
    gap: 5px;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.jt-badge-valid {
    background: rgba(34, 197, 94, 0.15);
    color: #4ADE80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.jt-badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: #F87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Error Message ──────────────────────────────────────────────────────── */
.jt-error-msg {
    display: none;
    margin-bottom: 8px;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: #FCA5A5;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    word-break: break-word;
}

/* ── Output Toolbar ─────────────────────────────────────────────────────── */
.jt-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #94A3B8;
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-family: var(--font-body);
}

.jt-toolbar-btn:hover { background: #334155; color: #E2E8F0; }
.jt-toolbar-btn.jt-success { color: #4ADE80; border-color: rgba(74, 222, 128, 0.4); }

.jt-search-box {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 7px;
    color: #4B5563;
    font-size: var(--text-xs);
}

.jt-search-input {
    padding: 4px 8px;
    background: #0F172A;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    color: #E2E8F0;
    font-size: var(--text-xs);
    width: 150px;
    outline: none;
    font-family: var(--font-body);
}

.jt-search-input:focus { border-color: #93C5FD; }
.jt-search-input::placeholder { color: #334155; }

/* ── Indent Selector ────────────────────────────────────────────────────── */
.jt-indent-sel {
    padding: 4px 6px;
    background: #0F172A;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    color: #94A3B8;
    font-size: var(--text-xs);
    cursor: pointer;
    outline: none;
    font-family: var(--font-body);
}

.jt-toolbar-sep {
    width: 1px;
    height: 16px;
    background: #334155;
    flex-shrink: 0;
}

/* ── Tree View ──────────────────────────────────────────────────────────── */
.jt-tree-view {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.7;
    color: #E2E8F0;
}

.jt-tree-node {
    position: relative;
    padding-left: 16px;
}

.jt-root-node { padding-left: 0; }

.jt-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    cursor: pointer;
    color: #475569;
    margin-right: 3px;
    vertical-align: middle;
}

.jt-tree-toggle:hover { color: #93C5FD; }

.jt-chevron {
    font-size: 0.5625rem;
    transition: transform 0.15s ease;
}

.jt-tree-key  { color: #93C5FD; }
.jt-bracket   { color: #94A3B8; }
.jt-close-bracket { display: block; padding-left: 0; }

.jt-count {
    display: none; /* shown only when node is collapsed via JS toggle */
    color: #475569;
    font-size: 0.75rem;
    font-style: italic;
}

.jt-tree-children {
    border-left: 1px solid #1E293B;
    margin-left: 6px;
    padding-left: 12px;
}

.jt-tree-leaf {
    padding-left: 17px;
    line-height: 1.7;
}

.jt-tree-error { color: #64748B; padding: 4px; font-size: var(--text-sm); }

/* ── Stats Grid ─────────────────────────────────────────────────────────── */
.jt-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.jt-stat-card {
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: var(--radius-md);
    padding: 16px 12px;
    text-align: center;
}

.jt-stat-val {
    font-size: var(--text-xl);
    font-weight: 700;
    color: #93C5FD;
    font-family: var(--font-mono);
    line-height: 1.2;
}

.jt-stat-lbl {
    font-size: var(--text-xs);
    color: #64748B;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .jt-editor-area {
        grid-template-columns: 1fr;
    }
    .jt-editor-pane,
    .jt-output-pane {
        height: 360px;
    }
}

@media (max-width: 640px) {
    .jt-action-bar { gap: var(--space-2); padding: var(--space-3); }
    .jt-action-btn { padding: 6px 10px; font-size: 0.8125rem; }
    .jt-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .jt-search-box { display: none; }
    .jt-action-right { margin-left: 0; }
}
