/* JSON Viewer Styles */
.json-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ─── Toolbar ────────────────────────────────────────────── */

.json-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.json-toolbar .format-btn,
.json-toolbar .toolbar-btn {
    margin-top: 0;
}

.json-stats {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* ─── Panels ─────────────────────────────────────────────── */

.json-panels {
    display: flex;
    gap: 16px;
    height: calc(97vh - 260px);
    min-height: 400px;
}

.json-input-panel,
.json-output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 0 4px var(--shadow-color);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.json-input-panel:focus-within {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px var(--accent-primary);
}

.json-panel-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding: 8px 14px 6px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.json-path-hint {
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-secondary);
    opacity: 0.6;
    margin-left: auto;
    font-family: 'Courier New', monospace;
    transition: color 0.2s, opacity 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.json-path-hint.flashed {
    color: var(--accent-primary);
    opacity: 1;
}

#jsonInput {
    flex: 1;
    width: 100%;
    background: transparent;
    color: var(--text-primary);
    border: none;
    resize: none;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    outline: none;
    line-height: 1.6;
    padding: 12px 14px;
    box-sizing: border-box;
}

.json-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 10px 6px 10px 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* ─── Empty State ────────────────────────────────────────── */

.json-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    opacity: 0.5;
    gap: 12px;
}

.json-empty-state i {
    font-size: 48px;
    color: var(--border-color);
}

.json-empty-state p {
    font-size: 14px;
    font-family: "Raleway", sans-serif;
    margin: 0;
}

/* ─── Error Bar ──────────────────────────────────────────── */

.json-error {
    display: none;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--error-color) 12%, transparent);
    border: 1px solid var(--error-color);
    border-radius: 5px;
    color: var(--error-color);
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

/* ─── Search Bar ─────────────────────────────────────────── */

.json-search-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.json-search-icon {
    color: var(--text-secondary);
    font-size: 12px;
    opacity: 0.6;
    flex-shrink: 0;
}

.json-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'Courier New', monospace;
    padding: 2px 4px;
    min-width: 0;
}

.json-search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.json-search-count {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
    white-space: nowrap;
    padding: 0 4px;
    min-width: 56px;
    text-align: right;
}

.json-search-nav,
.json-search-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 11px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.json-search-nav:hover:not(:disabled),
.json-search-clear:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.json-search-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ─── Search Highlights ──────────────────────────────────── */

.search-match {
    background: color-mix(in srgb, var(--warning-color) 30%, transparent);
    border-radius: 2px;
    outline: 1px solid color-mix(in srgb, var(--warning-color) 50%, transparent);
}

.search-match-active {
    background: color-mix(in srgb, var(--accent-primary) 35%, transparent) !important;
    outline: 1px solid var(--accent-primary) !important;
    border-radius: 2px;
}

/* ─── Tree Nodes ─────────────────────────────────────────── */

.json-root {
    user-select: none;
}

.json-node {
    padding-left: 0;
}

.json-children {
    padding-left: 20px;
    border-left: 1px solid var(--border-color);
    margin-left: 7px;
}

.json-row {
    display: flex;
    align-items: baseline;
    flex-wrap: nowrap;
    padding: 1px 4px;
    border-radius: 4px;
    gap: 0;
    min-height: 1.6em;
    white-space: nowrap;
}

.json-row-expandable {
    cursor: pointer;
}

.json-row-expandable:hover {
    background: var(--bg-hover);
}

.json-closing {
    padding: 1px 4px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ─── Toggle Arrow ───────────────────────────────────────── */

.json-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    color: var(--text-secondary);
    font-size: 10px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.json-row-expandable:hover .json-toggle {
    color: var(--accent-primary);
}

/* ─── Key ────────────────────────────────────────────────── */

.json-key {
    color: var(--accent-primary);
    cursor: pointer;
    border-radius: 3px;
    padding: 0 2px;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.json-key:hover {
    background: color-mix(in srgb, var(--accent-primary) 20%, transparent);
    color: var(--accent-primary);
}

.json-key:hover::after {
    content: ' ⎘';
    font-size: 10px;
    opacity: 0.7;
}

.json-colon {
    color: var(--text-secondary);
    margin-right: 4px;
}

/* ─── Value Types ────────────────────────────────────────── */

.json-value {
    flex-shrink: 0;
}

.json-string {
    color: var(--syntax-string);
    word-break: break-all;
    white-space: normal;
}

.json-number {
    color: var(--syntax-number);
}

.json-boolean {
    color: var(--syntax-keyword);
    font-weight: 600;
}

.json-null {
    color: var(--text-secondary);
    opacity: 0.6;
    font-style: italic;
}

/* ─── Bracket + Count Badge ──────────────────────────────── */

.json-bracket {
    color: var(--text-secondary);
    font-weight: 700;
}

.json-count-badge {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.55;
    margin-left: 6px;
    font-family: "Raleway", sans-serif;
    font-weight: 400;
}

/* ─── Collapsed State ────────────────────────────────────── */

.json-expandable.collapsed .json-children,
.json-expandable.collapsed .json-closing {
    display: none;
}

.json-expandable.collapsed .json-count-badge {
    opacity: 0.8;
}

/* ─── SynthWave: indent guide contrast fix ───────────────── */
/* --border-color (#3b2d5e) is nearly identical to --bg-primary
   (#262335), making the nesting guide lines invisible           */

[data-theme="synthwave"] .json-children {
    border-left-color: #6c5a9e;
}

/* ─── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .json-panels {
        flex-direction: column;
        height: auto;
    }

    .json-input-panel {
        min-height: 220px;
    }

    .json-output-panel {
        min-height: 300px;
    }

    .json-stats {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 540px) {
    .json-path-hint {
        display: none;
    }
}

/* ─── Copy Notification ──────────────────────────────────── */

.copy-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    padding: 12px 25px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.copy-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
