/* ============================================================
   DATA INSPECTOR
   Left panel: JSON source list (world_state, anna_state,
   map_json, save_file). Right panel: live JSON viewer.
   Matches the dark #011e29 / #00d4ff panel theme.
   ============================================================ */

/* ------------------------------------------------------------
   1. Trigger button in the top icon row
   (a <button>, unlike the sibling <i> icons, so reset chrome)
   ------------------------------------------------------------ */
button.data-inspector-trigger {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

button.data-inspector-trigger:focus-visible {
    outline: 2px solid rgba(0, 212, 255, 0.8);
    outline-offset: 2px;
    border-radius: 4px;
}

button.data-inspector-trigger.is-active,
button.data-inspector-trigger.is-active:hover {
    color: #00d4ff !important;
    text-shadow:
        0 0 10px rgba(0, 212, 255, 0.8),
        0 0 20px rgba(0, 212, 255, 0.6);
}

/* ------------------------------------------------------------
   2. Left panel — source list view
   ------------------------------------------------------------ */
/* Same rendered surface as .chat-view / .storefront-items-view /
   .signal-stability-view after chat_app_enhancements.css +
   chat_app_ui_fixes.css apply (cyan border, 6px radius, gradient +
   glow, radial texture). Texture is painted as background layers
   instead of a ::before so the view can scroll safely. */
.data-inspector-view {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 6px;
    background:
        radial-gradient(circle at 10% 20%, rgba(0, 212, 255, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(0, 212, 255, 0.03) 0%, transparent 50%),
        linear-gradient(135deg, rgba(1, 30, 41, 0.95) 0%, rgba(0, 20, 30, 0.98) 100%);
    box-shadow:
        0 0 30px rgba(0, 212, 255, 0.2),
        inset 0 0 40px rgba(0, 212, 255, 0.05);
    padding: 20px;
    position: relative;
}

/* Same scrollbar treatment as the sibling left-panel views */
.data-inspector-view::-webkit-scrollbar {
    width: 8px;
}

.data-inspector-view::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.data-inspector-view::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg,
        rgba(0, 212, 255, 0.6) 0%,
        rgba(0, 212, 255, 0.4) 100%);
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.data-inspector-view::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg,
        rgba(0, 212, 255, 0.8) 0%,
        rgba(0, 212, 255, 0.6) 100%);
}

.data-inspector-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.data-inspector-eyebrow {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: rgba(0, 212, 255, 0.75);
}

/* Same title treatment as .storefront-title (Tomorrow, uppercase, glow) */
.data-inspector-heading h2 {
    font-family: 'Tomorrow', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #ffffff;
    text-shadow:
        0 0 20px rgba(0, 212, 255, 0.6),
        0 2px 10px rgba(0, 0, 0, 0.5);
    margin: 5px 0 0 0;
}

.data-inspector-live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #7fe4ff;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.4);
    border-radius: 999px;
    padding: 4px 12px;
}

.data-inspector-live span[aria-hidden] {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2eff8b;
    box-shadow: 0 0 8px rgba(46, 255, 139, 0.9);
    animation: dataInspectorPulse 1.6s ease-in-out infinite;
}

@keyframes dataInspectorPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.8); }
}

.data-inspector-intro {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.6);
}

/* Source buttons */
.data-source-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.data-source-button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    padding: 12px 14px;
    color: #ffffff;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.data-source-button:hover {
    border-color: rgba(0, 212, 255, 0.6);
    background: rgba(0, 212, 255, 0.1);
    transform: translateX(2px);
}

.data-source-button:focus-visible {
    outline: 2px solid rgba(0, 212, 255, 0.8);
    outline-offset: 2px;
}

.data-source-button.is-active {
    border-color: rgba(0, 212, 255, 0.85);
    background: rgba(0, 212, 255, 0.13);
    box-shadow:
        0 0 12px rgba(0, 212, 255, 0.25),
        inset 3px 0 0 #00d4ff;
}

.data-source-index {
    flex-shrink: 0;
    font-family: 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    color: rgba(0, 212, 255, 0.55);
}

.data-source-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 212, 255, 0.4);
    border-radius: 4px;
    background: rgba(0, 212, 255, 0.08);
    color: #00d4ff;
    font-size: 0.95rem;
}

.data-source-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.data-source-name {
    font-family: 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.88rem;
    letter-spacing: 0.03em;
    color: #ffffff;
}

.data-source-button.is-active .data-source-name {
    color: #7fe4ff;
}

.data-source-description {
    font-size: 0.72rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.55);
}

.data-source-arrow {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    transition: color 0.25s ease, transform 0.25s ease;
}

.data-source-button:hover .data-source-arrow,
.data-source-button.is-active .data-source-arrow {
    color: #00d4ff;
    transform: translateX(3px);
}

.data-inspector-note {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.45);
}

.data-inspector-note i {
    color: rgba(0, 212, 255, 0.55);
    font-size: 0.72rem;
}

/* ------------------------------------------------------------
   3. Right panel — JSON viewer
   ------------------------------------------------------------ */
.data-json-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
    border: 2px solid #ffffff;
    background: #011e29;
    border-radius: 4px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.data-json-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.data-json-kicker {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.62rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.data-json-kicker span {
    color: rgba(0, 212, 255, 0.8);
}

.data-json-kicker i {
    font-size: 0.5rem;
}

.data-json-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.data-json-source-mark {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 212, 255, 0.5);
    border-radius: 4px;
    background: rgba(0, 212, 255, 0.09);
    color: #00d4ff;
    font-size: 1.1rem;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.18);
}

.data-json-title-row h2 {
    font-family: 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    color: #ffffff;
    margin: 0;
}

.data-json-meta {
    margin-top: 3px;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
}

.data-json-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.data-json-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.45);
    border-radius: 4px;
    color: #9fe8ff;
    font-family: 'Tomorrow', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 7px 14px;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.data-json-action:hover:not(:disabled) {
    background: rgba(0, 212, 255, 0.18);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.35);
}

.data-json-action:focus-visible {
    outline: 2px solid rgba(0, 212, 255, 0.8);
    outline-offset: 2px;
}

.data-json-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.data-json-action.is-loading i {
    animation: dataJsonSpin 0.8s linear infinite;
}

.data-json-action.is-success {
    border-color: rgba(46, 255, 139, 0.6);
    color: #7dffb2;
}

@keyframes dataJsonSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Code stage */
.data-json-stage {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border: 1px solid rgba(0, 212, 255, 0.35);
    border-radius: 4px;
    background: #021016;
    overflow: hidden;
}

.data-json-stage-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(0, 212, 255, 0.25);
    background: rgba(0, 212, 255, 0.06);
}

.data-json-file-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.85);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-json-status-dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2eff8b;
    box-shadow: 0 0 6px rgba(46, 255, 139, 0.9);
}

.data-json-stage-meta {
    flex-shrink: 0;
    font-size: 0.64rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

/* Code area + syntax highlighting */
.data-json-code {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 14px 18px;
    margin: 0;
}

.data-json-code:focus-visible {
    outline: 2px solid rgba(0, 212, 255, 0.6);
    outline-offset: -2px;
}

.data-json-code code {
    display: block;
    font-family: 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre;
    tab-size: 2;
    color: rgba(255, 255, 255, 0.82);
}

.data-json-code::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

.data-json-code::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}

.data-json-code::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.35);
    border-radius: 4px;
}

.data-json-code::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.55);
}

.json-key { color: #4fd6ff; }
.json-string { color: #9ef0a8; }
.json-number { color: #ffbe73; }
.json-boolean { color: #ff8fd6; }
.json-null { color: #9aa7b0; font-style: italic; }

/* Empty / loading / error states */
.data-json-empty,
.data-json-loading,
.data-json-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 30px 20px;
}

.data-json-empty-icon,
.data-json-error-icon {
    width: 52px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 212, 255, 0.35);
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.07);
    color: rgba(0, 212, 255, 0.8);
    font-size: 1.25rem;
}

.data-json-empty h3,
.data-json-error h3 {
    font-family: 'Tomorrow', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.05em;
    color: #ffffff;
    margin: 0;
}

.data-json-empty p,
.data-json-error p {
    font-size: 0.78rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.55);
    margin: 0;
    max-width: 380px;
}

.data-json-empty p strong {
    color: #7fe4ff;
    font-family: 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
    font-weight: 400;
    font-size: 0.72rem;
}

.data-json-loading {
    flex-direction: row;
    gap: 12px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.65);
}

.data-json-loader {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(0, 212, 255, 0.25);
    border-top-color: #00d4ff;
    animation: dataJsonSpin 0.8s linear infinite;
}

.data-json-error-icon {
    border-color: rgba(255, 120, 120, 0.45);
    background: rgba(255, 80, 80, 0.08);
    color: #ff8f8f;
}

/* ------------------------------------------------------------
   4. Responsive (mirror the other left-panel views on mobile)
   ------------------------------------------------------------ */
@media (max-width: 768px) {
    .data-inspector-view {
        overflow-y: visible !important;
        overflow-x: hidden !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        flex: 0 0 auto !important;
        padding: 15px !important;
    }

    .data-json-view {
        padding: 12px;
    }

    .data-json-header {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .data-json-actions {
        justify-content: flex-end;
    }
}
