:root {
    /* Color Palette */
    --bg-base: #0D0A1A;
    --bg-panel: rgba(26, 20, 50, 0.6);
    --bg-glass-border: rgba(162, 155, 254, 0.15);

    --primary: #A29BFE;
    --primary-hover: #b4aeff;
    --secondary: #DFE6E9;
    --accent: #00CEC9;

    --text-primary: #FFFFFF;
    --text-secondary: #B8B2D1;
    --text-muted: #736b9e;

    --success: #00b894;
    --error: #ff7675;
    --warning: #fdcb6e;

    /* Dep Types */
    --color-prod: #00CEC9;
    /* Accent */
    --color-dev: #A29BFE;
    /* Primary */
    --color-peer: #fdcb6e;
    /* Warning */

    /* Node Types */
    --node-local: #A29BFE;
    --node-external: #636e72;

    /* Theme Specs */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

    --font-ui: 'Inter', -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    /* Subtle background glow */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(162, 155, 254, 0.1), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 206, 201, 0.05), transparent 40%);
}

.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

.app-container {
    display: flex;
    height: 100vh;
    padding: 1rem;
    gap: 1rem;
    max-width: 1800px;
    margin: 0 auto;
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glass);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary-btn {
    background-color: var(--primary);
    color: var(--bg-base);
    font-weight: 600;
}

.primary-btn:not(:disabled):hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(162, 155, 254, 0.3);
}

.secondary-btn {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-btn:not(:disabled):hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

/* ---> Sidebar <--- */
.sidebar {
    width: 340px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--bg-glass-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Upload Section */
.drop-zone {
    border: 2px dashed rgba(162, 155, 254, 0.3);
    border-radius: var(--radius-md);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 1rem;
}

.drop-zone:hover,
.drop-zone.dragover {
    background: rgba(162, 155, 254, 0.05);
    border-color: var(--primary);
}

.drop-zone i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.drop-zone p {
    font-size: 0.9rem;
    color: var(--secondary);
}

.drop-zone .drop-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.drop-zone code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.file-item-name {
    color: var(--secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.file-item-del {
    color: var(--error);
    cursor: pointer;
    opacity: 0.7;
}

.file-item-del:hover {
    opacity: 1;
}

/* Filter Section */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--secondary);
    user-select: none;
}

.checkbox-label input {
    display: none;
}

.custom-checkbox {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid;
    position: relative;
    transition: all 0.2s;
}

.custom-checkbox::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 4px;
    width: 3px;
    height: 6px;
    border: solid var(--bg-base);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
}

.checkbox-label input:checked~.custom-checkbox::after {
    opacity: 1;
}

.prod-color {
    border-color: var(--color-prod);
}

.checkbox-label input:checked~.prod-color {
    background-color: var(--color-prod);
}

.dev-color {
    border-color: var(--color-dev);
}

.checkbox-label input:checked~.dev-color {
    background-color: var(--color-dev);
}

.peer-color {
    border-color: var(--color-peer);
}

.checkbox-label input:checked~.peer-color {
    background-color: var(--color-peer);
}

/* Analysis Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.5rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.stat-val {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-lbl {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.alerts-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.alert i {
    margin-top: 0.1rem;
}

.alert.error {
    background: rgba(255, 118, 117, 0.1);
    border: 1px solid rgba(255, 118, 117, 0.3);
    color: var(--error);
}

.alert.warning {
    background: rgba(253, 203, 110, 0.1);
    border: 1px solid rgba(253, 203, 110, 0.3);
    color: var(--warning);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--bg-glass-border);
}

.sidebar-footer .btn {
    width: 100%;
}


/* ---> Main Workspace <--- */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
    position: relative;
}

.workspace-header {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 10;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls {
    display: flex;
    gap: 0.5rem;
}

.legend {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot.local {
    background: var(--node-local);
}

.dot.external {
    background: var(--node-external);
}

.graph-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.graph-container:active {
    cursor: grabbing;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.empty-icon {
    font-size: 4rem;
    color: rgba(162, 155, 254, 0.2);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
}

/* Tooltip */
.tooltip {
    position: absolute;
    pointer-events: none;
    padding: 1rem;
    min-width: 200px;
    z-index: 20;
    /* positioned via JS */
}

.tooltip h4 {
    color: var(--primary);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
    word-break: break-all;
}

.tt-stats {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--secondary);
}


/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: var(--bg-base);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: var(--shadow-glass);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

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