/* World State Viewer - Debug JSON tree */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #c8ccd4;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Toolbar ── */
#toolbar {
    background: #16213e;
    border-bottom: 1px solid #2a2a4a;
    padding: 8px 12px;
    flex-shrink: 0;
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.toolbar-row:last-child {
    margin-bottom: 0;
}

.toolbar-row label {
    color: #7a8baa;
    font-size: 13px;
    font-weight: 600;
}

#ws-url {
    flex: 1;
    max-width: 360px;
    background: #0f1629;
    border: 1px solid #2a2a4a;
    color: #c8ccd4;
    padding: 4px 8px;
    border-radius: 3px;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 12px;
}

button {
    background: #1f3460;
    color: #8db4e8;
    border: 1px solid #2a4a7a;
    padding: 4px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s;
}

button:hover:not(:disabled) {
    background: #2a4a7a;
}

button:disabled {
    opacity: 0.4;
    cursor: default;
}

button.active {
    background: #1a5c3a;
    border-color: #2a8a5a;
    color: #6adb8a;
}

#ws-status {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.status-connected {
    color: #6adb8a;
    background: rgba(106, 219, 138, 0.12);
}

.status-disconnected {
    color: #e66;
    background: rgba(230, 102, 102, 0.12);
}

.status-connecting {
    color: #e8c44d;
    background: rgba(232, 196, 77, 0.12);
}

.spacer {
    flex: 1;
}

/* ── Stats bar ── */
#stats-bar {
    background: #121a30;
    border-bottom: 1px solid #2a2a4a;
    padding: 6px 12px;
    font-size: 12px;
    font-family: 'Consolas', 'Fira Code', monospace;
    flex-shrink: 0;
}

#stats-row-1, #stats-row-2 {
    display: flex;
    gap: 6px;
    align-items: center;
}

#stats-row-2 {
    margin-top: 3px;
}

.sep {
    color: #3a3a5a;
}

/* ── Filter bar ── */
#filter-bar {
    background: #16213e;
    border-bottom: 1px solid #2a2a4a;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.search-icon {
    font-size: 14px;
    color: #5a6a8a;
}

#search-input {
    flex: 1;
    background: #0f1629;
    border: 1px solid #2a2a4a;
    color: #c8ccd4;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 13px;
}

#search-input::placeholder {
    color: #4a5a7a;
}

#btn-clear-search {
    background: none;
    border: none;
    color: #5a6a8a;
    font-size: 16px;
    padding: 2px 6px;
    cursor: pointer;
}

#btn-clear-search:hover {
    color: #c8ccd4;
}

.checkbox-label {
    font-size: 12px;
    color: #7a8baa;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
}

/* ── Tree container ── */
#tree-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.6;
}

/* Scrollbar */
#tree-container::-webkit-scrollbar {
    width: 8px;
}

#tree-container::-webkit-scrollbar-track {
    background: #12162a;
}

#tree-container::-webkit-scrollbar-thumb {
    background: #2a3a5a;
    border-radius: 4px;
}

#tree-container::-webkit-scrollbar-thumb:hover {
    background: #3a4a6a;
}

/* ── Tree nodes ── */
.tree-node {
    padding-left: 18px;
    position: relative;
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 4px;
    border-radius: 3px;
}

.tree-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tree-arrow {
    display: inline-block;
    width: 12px;
    text-align: center;
    font-size: 10px;
    color: #5a6a8a;
    transition: transform 0.12s;
}

.tree-arrow.open {
    transform: rotate(90deg);
}

.tree-children {
    display: none;
}

.tree-children.open {
    display: block;
}

/* ── Node labels ── */
.node-key {
    color: #5ec4e8;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 12px;
}

.node-value {
    color: #c8ccd4;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 12px;
}

.node-type-hint {
    color: #5a6a8a;
    font-size: 11px;
    margin-left: 4px;
}

.node-count {
    color: #7a8baa;
    font-size: 11px;
}

/* Value types */
.val-string { color: #8adb8a; }
.val-number { color: #e8c44d; }
.val-bool-true { color: #6adb8a; }
.val-bool-false { color: #e66; }
.val-null { color: #7a6a8a; font-style: italic; }

/* ── Team colors ── */
.team-red .tree-toggle {
    border-left: 3px solid rgb(230, 77, 77);
    padding-left: 6px;
}

.team-blue .tree-toggle {
    border-left: 3px solid rgb(77, 128, 230);
    padding-left: 6px;
}

.team-other .tree-toggle {
    border-left: 3px solid rgb(180, 180, 180);
    padding-left: 6px;
}

/* ── State badges ── */
.state-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.state-takeoff {
    background: rgba(76, 175, 80, 0.2);
    color: #6adb8a;
    border: 1px solid rgba(76, 175, 80, 0.35);
}

.state-airborne, .state-cruising, .state-attacking, .state-intercepting, .state-patrolling, .state-engaging {
    background: rgba(77, 128, 230, 0.15);
    color: #8db4e8;
    border: 1px solid rgba(77, 128, 230, 0.3);
}

.state-landing, .state-returning, .state-rtb {
    background: rgba(232, 196, 77, 0.2);
    color: #e8c44d;
    border: 1px solid rgba(232, 196, 77, 0.35);
}

.state-grounded, .state-landed, .state-idle, .state-disabled {
    background: rgba(150, 150, 150, 0.2);
    color: #999;
    border: 1px solid rgba(150, 150, 150, 0.35);
}

.state-destroyed {
    background: rgba(230, 77, 77, 0.2);
    color: #e66;
    border: 1px solid rgba(230, 77, 77, 0.35);
}

.state-tracking, .state-scanning, .state-active, .state-searching {
    background: rgba(0, 200, 200, 0.15);
    color: #5ec4e8;
    border: 1px solid rgba(0, 200, 200, 0.3);
}

.state-firing, .state-launching {
    background: rgba(255, 140, 0, 0.2);
    color: #f0a040;
    border: 1px solid rgba(255, 140, 0, 0.35);
}

/* ── Entity type icons ── */
.entity-type-icon {
    font-size: 12px;
    margin-right: 2px;
}

/* ── Field rows ── */
.field-row {
    display: flex;
    gap: 8px;
    padding: 0 0 0 18px;
    align-items: baseline;
}

.field-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.015);
}

.field-name {
    color: #5ec4e8;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 12px;
    min-width: 180px;
    text-align: right;
    flex-shrink: 0;
}

.field-value {
    color: #c8ccd4;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 12px;
}

/* ── Group header ── */
.group-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
}

.group-count {
    background: rgba(255, 255, 255, 0.08);
    padding: 0 6px;
    border-radius: 8px;
    font-size: 11px;
    color: #7a8baa;
    font-weight: normal;
}

/* ── Entity header ── */
.entity-header {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.entity-id {
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 12px;
    color: #c8ccd4;
}

.entity-name {
    color: #8db4e8;
    font-size: 12px;
}

/* ── Removed IDs ── */
.removed-id {
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 12px;
    color: #e66;
    padding: 0 0 0 18px;
}

/* ── Footer ── */
#footer {
    background: #12162a;
    border-top: 1px solid #2a2a4a;
    padding: 4px 12px;
    font-size: 11px;
    display: flex;
    gap: 8px;
    color: #5a6a8a;
    flex-shrink: 0;
}

/* ── Empty state ── */
.empty-state {
    color: #5a6a8a;
    text-align: center;
    padding: 60px 20px;
    font-size: 14px;
}

.empty-state .hint {
    margin-top: 8px;
    font-size: 12px;
    color: #3a4a6a;
}

/* ── Search highlight ── */
.search-match {
    background: rgba(232, 196, 77, 0.25);
    border-radius: 2px;
    padding: 0 1px;
}

/* ── Simulation info section ── */
.sim-info-section {
    margin-bottom: 4px;
}
