/* ===== Custom Scrollbar ===== */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ===== Input Tabs ===== */
.input-tab {
    color: #64748b;
    background: transparent;
}
.input-tab:hover {
    color: #94a3b8;
    background: rgba(51, 65, 85, 0.5);
}
.input-tab.active {
    color: #e2e8f0;
    background: #334155;
}

/* ===== Tree Node Styles ===== */
.tree-node {
    position: relative;
    user-select: none;
}

.node-content {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    min-height: 28px;
    white-space: nowrap;
}
.node-content:hover {
    background-color: rgba(51, 65, 85, 0.6);
}
.node-content.selected {
    background-color: rgba(59, 130, 246, 0.2);
    outline: 1px solid rgba(59, 130, 246, 0.4);
    outline-offset: -1px;
}
.node-content.filtered-out {
    opacity: 0.2;
    pointer-events: none;
}
.node-content.filter-highlight {
    background-color: rgba(250, 204, 21, 0.15);
    outline: 1px solid rgba(250, 204, 21, 0.3);
    outline-offset: -1px;
}

/* Toggle button */
.node-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
    font-size: 10px;
}
.node-toggle:hover {
    background-color: rgba(100, 116, 139, 0.3);
    color: #e2e8f0;
}
.node-toggle.collapsed {
    transform: rotate(-90deg);
}
.node-toggle.leaf {
    opacity: 0;
    pointer-events: none;
}

/* Node key */
.node-key {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
}
.node-key.xml-tag {
    color: #fb923c;
}

/* Node type badge */
.node-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    flex-shrink: 0;
}
.badge-object { background: rgba(96, 165, 250, 0.2); color: #93c5fd; }
.badge-array { background: rgba(52, 211, 153, 0.2); color: #6ee7b7; }
.badge-string { background: rgba(251, 191, 36, 0.2); color: #fcd34d; }
.badge-number { background: rgba(34, 211, 238, 0.2); color: #67e8f9; }
.badge-boolean { background: rgba(167, 139, 250, 0.2); color: #c4b5fd; }
.badge-null { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.badge-xml-element { background: rgba(251, 146, 60, 0.2); color: #fdba74; }
.badge-text { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.badge-comment { background: rgba(148, 163, 184, 0.1); color: #64748b; }

/* Node value */
.node-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    margin-left: 2px;
}
.val-string { color: #fbbf24; }
.val-number { color: #22d3ee; }
.val-boolean { color: #a78bfa; }
.val-null { color: #64748b; font-style: italic; }

/* Node info */
.node-info {
    font-size: 11px;
    color: #64748b;
    margin-left: 4px;
    flex-shrink: 0;
}

/* Tree children container */
.tree-children {
    position: relative;
    margin-left: 20px;
    padding-left: 12px;
    border-left: 1px solid #1e3a5f;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}
.tree-children.collapsed {
    max-height: 0 !important;
    opacity: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-left-color: transparent;
}

/* Tree connector lines */
.tree-node > .node-content::before {
    content: '';
    position: absolute;
    left: -13px;
    top: 50%;
    width: 10px;
    height: 1px;
    background: #1e3a5f;
}
.tree-node:last-child > .node-content::after {
    content: '';
    position: absolute;
    left: -13px;
    top: 50%;
    bottom: -10px;
    width: 1px;
    background: #0f172a;
}
.tree-node:last-child > .tree-children {
    border-left-color: transparent;
}

/* Root node doesn't need connector */
#treeContainer > .tree-node > .node-content::before,
#treeContainer > .tree-node > .node-content::after {
    display: none;
}
#treeContainer > .tree-node > .tree-children {
    border-left: 1px solid #1e3a5f;
    margin-left: 8px;
}

/* ===== Detail Panel Styles ===== */
.detail-section {
    margin-bottom: 16px;
}
.detail-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    margin-bottom: 6px;
    font-weight: 600;
}
.detail-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #e2e8f0;
    background: #1e293b;
    padding: 8px 12px;
    border-radius: 8px;
    word-break: break-all;
    line-height: 1.6;
}
.detail-attr-table {
    width: 100%;
    border-collapse: collapse;
}
.detail-attr-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid #334155;
}
.detail-attr-table td {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 6px 10px;
    border-bottom: 1px solid #1e293b;
}
.detail-attr-table td:first-child {
    color: #c084fc;
}
.detail-attr-table td:last-child {
    color: #fbbf24;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
#detailPanel.slide-in {
    animation: slideInRight 0.3s ease forwards;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    #detailPanel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 340px;
        max-width: 85vw;
        z-index: 40;
        transform: translateX(100%);
        box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
    }
    #detailPanel.open {
        transform: translateX(0);
    }
    #mobileOverlay.show {
        display: block;
    }
}

@media (max-width: 640px) {
    #detailPanel {
        width: 100%;
        max-width: 100%;
    }
    .node-content {
        padding: 4px 6px 4px 2px;
    }
    .node-key {
        font-size: 12px;
    }
    .node-value {
        font-size: 11px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #inputSection {
        padding: 8px;
    }
    #pasteInput {
        height: 120px;
        font-size: 12px;
    }
    #treeContainer {
        padding: 8px;
    }
    .tree-children {
        margin-left: 14px;
        padding-left: 8px;
    }
}