:root {
    /* VSCode Dark+ (Default) */
    --bg-primary: #1e1e1e;
    --bg-sidebar: #252526;
    --bg-header: #3c3c3c;
    --bg-active: #04395e;
    --text-primary: #cccccc;
    --text-header: #ffffff;
    --text-secondary: #858585;
    --border-color: #333333;
    --accent-blue: #007acc;
    --accent-green: #89d185;
    --accent-red: #f44747;
    --accent-yellow: #cca700;
    --accent-purple: #b180d7;
    --tree-hover: #2a2d2e;
    --glass-bg: rgba(255, 255, 255, 0.02);
    --glass-blur: blur(8px);

    /* JSON Highlighting - Dark */
    --json-key: #9cdcfe;
    --json-string: #ce9178;
    --json-number: #b5cea8;
    --json-boolean: #569cd6;
    --json-null: #569cd6;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-sidebar: #f3f3f3;
    --bg-header: #2c2c2c;
    --bg-active: #e4e6f1;
    --text-primary: #333333;
    --text-header: #ffffff;
    --text-secondary: #616161;
    --border-color: #e5e5e5;
    --accent-blue: #007acc;
    --accent-green: #388a34;
    --accent-red: #cd3131;
    --accent-yellow: #947600;
    --accent-purple: #8630a4;
    --tree-hover: #e8e8e8;
    --glass-bg: rgba(0, 0, 0, 0.05);

    /* JSON Highlighting - Light */
    --json-key: #0451a5;
    --json-string: #a31515;
    --json-number: #098658;
    --json-boolean: #0000ff;
    --json-null: #0000ff;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

header {
    height: auto;
    min-height: 48px;
    background: var(--bg-header);
    color: var(--text-header);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    z-index: 3000;
    font-size: 0.8125rem;
}

.logo {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.app-container {
    flex: 1;
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    overflow: hidden;
}

aside {
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    outline: none;
}

#explorerPanel {
    border-right: 1px solid var(--border-color);
}

.aside-header {
    padding: 10px 16px;
    text-transform: uppercase;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.tree-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.filter-bar {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    align-items: center;
}

.table-container {
    flex: 1;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

th {
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.75rem;
    user-select: none;
    transition: color 0.1s;
}

th:hover {
    color: var(--text-primary);
}

th.sort-asc::after {
    content: " ▲";
    font-size: 0.7em;
    opacity: 0.8;
}

th.sort-desc::after {
    content: " ▼";
    font-size: 0.7em;
    opacity: 0.8;
}

td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

tr:hover {
    background: var(--tree-hover);
}

tr.selected {
    background: var(--bg-active);
}

.details-panel {
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--border-color);
}

.details-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    background: var(--bg-sidebar);
    z-index: 10;
}

.details-content {
    flex: 1;
    padding: 16px;
    overflow: hidden;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-primary);
    line-height: 1.4;
    white-space: pre;
}

.json-key {
    color: var(--json-key);
}

.json-string {
    color: var(--json-string);
}

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

.json-boolean {
    color: var(--json-boolean);
}

.json-null {
    color: var(--json-null);
}

/* Badges */
.badge {
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 500;
    display: inline-block;
    border: 1px solid transparent;
}

.badge-ADDED {
    background: rgba(137, 209, 133, 0.15);
    color: var(--accent-green);
    border-color: rgba(137, 209, 133, 0.3);
}

.badge-REMOVED {
    background: rgba(244, 71, 71, 0.15);
    color: var(--accent-red);
    border-color: rgba(244, 71, 71, 0.3);
}

.badge-PARENT_REMOVED {
    background: rgba(193, 44, 44, 0.15);
    color: #c12c2c;
    border-color: rgba(193, 44, 44, 0.3);
}

.badge-MODIFIED {
    background: rgba(204, 167, 0, 0.15);
    color: var(--accent-yellow);
    border-color: rgba(204, 167, 0, 0.3);
}

.badge-PATH_CHANGED {
    background: rgba(0, 122, 204, 0.15);
    color: var(--accent-blue);
    border-color: rgba(0, 122, 204, 0.3);
}

.badge-HAS_ADS, .badge-ADS {
    background: rgba(78, 201, 176, 0.15);
    color: #4ec9b0; /* Teal/Cyan */
    border-color: rgba(78, 201, 176, 0.3);
}

.badge-HAS_HARDLINKS {
    background: rgba(197, 134, 192, 0.15);
    color: #c586c0; /* Pink/Violet */
    border-color: rgba(197, 134, 192, 0.3);
}

.badge-PATH_LOOKUP_REQ {
    background: rgba(128, 128, 128, 0.15);
    color: #a0a0a0; /* Gray */
    border-color: rgba(128, 128, 128, 0.3);
}

.badge-WORM_COMMITTED {
    background: rgba(215, 186, 125, 0.15);
    color: #d7ba7d; /* Sand/Gold (Locked) */
    border-color: rgba(215, 186, 125, 0.3);
}

/* Tree Styles */
.tree-node {
    cursor: pointer;
    padding: 4px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.tree-node:hover {
    background: var(--tree-hover);
}

.tree-node.active {
    background: var(--bg-active);
}

.tree-node svg {
    color: #dcb67a;
}

/* UI Elements */
.input-base {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 2px;
    outline: none;
}

.input-base:focus {
    border-color: var(--accent-blue);
}

.btn {
    background: #444444;
    color: white;
    border: none;
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: #555555;
}

.btn-primary {
    background: var(--accent-blue);
}

.btn-primary:hover {
    background: #006bb3;
}

/* Custom Select Dropdown for Columns */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--bg-sidebar);
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 5000;
    border: 1px solid var(--border-color);
    padding: 8px 0;
}

.dropdown-item {
    padding: 6px 16px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-primary);
}

.dropdown-item:hover {
    background: var(--tree-hover);
}

.show {
    display: block;
}

/* Path Delta Styling */
.path-delta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.path-old {
    color: var(--text-secondary);
    text-decoration: line-through;
    font-size: 0.7rem;
}

.path-new {
    font-weight: 500;
}

/* Modal Styling from before but themed */
#modalOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 4px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

/* Analytics Dashboard */
.dashboard-overlay {
    position: absolute;
    top: 48px; /* Below header */
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 4000;
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    overflow-y: auto;
    overflow-x: hidden;
}

.dashboard-overlay.hidden {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.dashboard-header {
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 10;
}

.dashboard-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.dashboard-content {
    padding: 32px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.chart-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin: 0;
}

/* DOM-based Bar Chart */
.bar-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bar-label-area {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.bar-label {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.bar-value {
    color: var(--text-secondary);
}

.bar-track {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--accent-blue);
}

/* Responsive Styles */
/* Responsive Styles */
@media (max-width: 1024px) {
    .app-container {
        display: flex;
        position: relative;
    }

    aside {
        position: absolute;
        top: 0;
        bottom: 0;
        z-index: 2000;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
    }

    main {
        flex: 1;
        min-width: 0;
        width: 100%;
    }

    .filter-bar {
        padding: 8px 32px;
    }

    .table-container {
        padding: 0 28px;
    }

    #explorerPanel {
        left: 0;
        width: 280px;
        max-width: 90vw;
        border-right: 1px solid var(--border-color);
        transform: translateX(calc(-100% + 24px));
    }

    #explorerPanel::after {
        content: "📁";
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 24px;
        height: 48px;
        background: var(--bg-header);
        border: 1px solid var(--border-color);
        border-left: none;
        border-radius: 0 4px 4px 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        color: var(--text-primary);
        cursor: pointer;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
        transition: opacity 0.2s, right 0.3s;
        z-index: 10;
    }

    #explorerPanel:focus-within,
    #explorerPanel:focus {
        transform: translateX(0);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.3);
    }

    #explorerPanel:focus-within::after,
    #explorerPanel:focus::after {
        opacity: 0;
        pointer-events: none;
    }

    #detailsPanel {
        right: 0;
        width: 320px;
        max-width: 90vw;
        border-left: 1px solid var(--border-color);
        transform: translateX(calc(100% - 24px));
    }

    #detailsPanel::before {
        content: "ℹ️";
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 24px;
        height: 48px;
        background: var(--bg-header);
        border: 1px solid var(--border-color);
        border-right: none;
        border-radius: 4px 0 0 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        color: var(--text-primary);
        cursor: pointer;
        box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
        transition: opacity 0.2s, left 0.3s;
        z-index: 10;
    }

    #detailsPanel:focus-within,
    #detailsPanel:focus {
        transform: translateX(0);
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.3);
    }

    #detailsPanel:focus-within::before,
    #detailsPanel:focus::before {
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 1024px) and (hover: hover) {
    #explorerPanel:hover {
        transform: translateX(0);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.3);
    }

    #explorerPanel:hover::after {
        opacity: 0;
        pointer-events: none;
    }

    #detailsPanel:hover {
        transform: translateX(0);
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.3);
    }

    #detailsPanel:hover::before {
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 768px) {
    header {
        justify-content: center;
    }

    .logo-text {
        display: none;
        /* Hide logo text on smaller screens */
    }

    .controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        padding-bottom: 4px;
    }

    .controls .btn span {
        display: none;
        /* Icon only buttons */
    }

    .filter-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .filter-bar select,
    .filter-bar input {
        flex: 1 1 120px;
    }
}