/* ATLAS JSON Viewer — styles for the shared component (js/json-viewer.js).
   Mission json-viewer-upgrade-01KXNBJY.

   All tree rules are scoped under .jv-root (guard R-3 — this stylesheet must
   not restyle unrelated .json-* markup). Colours: light values on .jv-root,
   [data-theme="dark"] overrides below (same pattern as cv-viewer.css), with
   structural colours taken from ATLAS custom properties (styles.css). */

.jv-root {
    /* Syntax palette — light theme */
    --jv-key: #1d4ed8;
    --jv-str: #047857;
    --jv-num: #b45309;
    --jv-bool: #7c3aed;
    --jv-null: var(--text-muted);
    --jv-punct: var(--text-secondary);
    --jv-guide: var(--border);
    --jv-hover: rgba(59, 130, 246, 0.07);

    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-primary);
    padding: 0.25rem 0;
}

[data-theme="dark"] .jv-root {
    --jv-key: #93c5fd;
    --jv-str: #6ee7b7;
    --jv-num: #fcd34d;
    --jv-bool: #c4b5fd;
    --jv-punct: var(--text-secondary);
    --jv-hover: rgba(96, 165, 250, 0.12);
}

/* Rows */
.jv-root .jv-row {
    display: flex;
    align-items: baseline;
    padding: 0.08rem 0.5rem 0.08rem 0.25rem;
    border-radius: 4px;
}

.jv-root .jv-row:hover {
    background: var(--jv-hover);
}

/* Indentation guides — one vertical rule per depth level */
.jv-root .jv-indent {
    flex: 0 0 1.15rem;
    align-self: stretch;
    border-left: 1px solid var(--jv-guide);
    margin-left: 0.5rem;
}

/* Expand/collapse chevron */
.jv-root .jv-toggle {
    flex: 0 0 1.15rem;
    text-align: center;
    cursor: pointer;
    user-select: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    transition: transform 0.12s ease, color 0.12s ease;
}

.jv-root .jv-toggle.jv-open {
    transform: rotate(90deg);
}

.jv-root .jv-toggle:hover {
    color: var(--primary-color);
}

.jv-root .jv-toggle:empty {
    cursor: default;
}

/* Type-aware value colouring */
.jv-root .jv-key   { color: var(--jv-key); font-weight: 600; }
.jv-root .jv-idx   { color: var(--text-muted); font-weight: 500; }
.jv-root .jv-str   { color: var(--jv-str); }
.jv-root .jv-num   { color: var(--jv-num); }
.jv-root .jv-bool  { color: var(--jv-bool); font-weight: 600; }
.jv-root .jv-null  { color: var(--jv-null); font-style: italic; }
.jv-root .jv-punct { color: var(--jv-punct); }
.jv-root .jv-colon { margin-right: 0.55ch; }

/* Long strings wrap inside the pane instead of stretching the modal */
.jv-root .jv-str {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    min-width: 0;
}

/* Collapsed-node count badge — {…} 17 keys / […] 42 items */
.jv-root .jv-badge {
    margin-left: 0.5rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--background);
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.jv-root .jv-badge:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Hover copy-value pill */
.jv-root .jv-copy {
    margin-left: 0.6rem;
    padding: 0 0.45rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-family: inherit;
    line-height: 1.5;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.jv-root .jv-row:hover .jv-copy {
    opacity: 1;
}

.jv-root .jv-copy:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ---------------------------------------------------------------------------
   Toolbar polish for the EXISTING viewer controls (ids are unique per page,
   so these cannot leak to other components). Markup owned by the hosts. */

#json-search {
    border-radius: 999px;
    padding: 0.45rem 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#json-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

#expand-all-btn,
#collapse-all-btn,
#copy-json-btn {
    border-radius: 6px;
    font-weight: 500;
}

#copy-json-btn {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

#copy-json-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
}
