:root {
  --bg-color: #1A0A0A;
  --bg-surface: rgba(40, 15, 15, 0.7);
  --bg-surface-hover: rgba(60, 20, 20, 0.8);
  --border-color: rgba(239, 68, 68, 0.2);
  --border-highlight: rgba(239, 68, 68, 0.5);
  
  --primary: #EF4444;       /* Red */
  --primary-hover: #DC2626;
  --secondary: #F87171;
  --accent: #FBBF24;        /* Amber for warnings */
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-inverse: #1A0A0A;
  
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 15px rgba(239, 68, 68, 0.2);
  
  --transition: all 0.2s ease;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, monospace;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(239, 68, 68, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(239, 68, 68, 0.05) 0%, transparent 40%);
}

/* Glassmorphism */
.glass-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}
.glass-panel-sm {
  background: rgba(30, 10, 10, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* Utilities */
.hidden { display: none !important; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-auto { margin-top: auto; }
.pt-4 { padding-top: 1rem; }
.border-t { border-top: 1px solid var(--border-color); }
.w-full { width: 100%; }

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 1rem;
  gap: 1rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; }

.main-content {
  display: flex;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar h2 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text-main); }
.sidebar h3 { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;}

.search-input-wrapper { position: relative; }
.search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
input[type="text"], input[type="number"] {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition);
}
input[type="text"]:focus, input[type="number"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(239,68,68,0.2); }
input[type="number"] { padding-left: 1rem; }

.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 250px;
    overflow-y: auto;
    z-index: 50;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}
.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg-surface-hover); }
.auto-name { font-weight: 600; font-size: 0.9rem;}
.auto-desc { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;}

.control-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.05);
}
.control-group label { font-size: 0.9rem; color: var(--text-muted); }
.control-group input { width: 60px; text-align: center; padding: 0.4rem; }

/* Buttons */
button { font-family: var(--font-sans); cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-primary { background: var(--primary); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: var(--radius-sm); font-weight: 500;}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); padding: 0.6rem 1.2rem; border-radius: var(--radius-sm); font-weight: 500;}
.btn-outline:hover:not(:disabled) { background: rgba(239, 68, 68, 0.1); }
.btn-outline.active { background: var(--primary); color: white; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-text { background: none; border: none; color: var(--text-muted); padding: 0.4rem 0.8rem; font-size: 0.85rem;}
.btn-text:hover { color: var(--text-main); background: rgba(255,255,255,0.05); border-radius: 4px;}

/* Workspace & Views */
.workspace {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}
.view-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding-right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.compare-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
}
.compare-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    min-height: 0;
}
.compare-divider {
    width: 2px;
    background: var(--border-color);
    margin: 0 0.5rem;
}

/* States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 1rem;
}
.empty-state h3 { color: var(--text-main); font-weight: 500; margin-top: 1rem;}
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100px;
    color: var(--text-muted);
    gap: 1rem;
}
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(239, 68, 68, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Package Header */
.pkg-header {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.pkg-title-area { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;}
.pkg-title-area h2 { font-size: 1.5rem; letter-spacing: -0.5px;}
.pkg-desc { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5;}
.pkg-stats { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 0.5rem;}

/* Badges & Stats */
.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}
.badge-version { background: rgba(255,255,255,0.1); color: var(--text-main); }
.badge-license { background: rgba(59, 130, 246, 0.2); color: #60A5FA; border: 1px solid rgba(59,130,246,0.5);}
.badge-vuln { background: rgba(239, 68, 68, 0.2); color: var(--primary); border: 1px solid rgba(239,68,68,0.5); display: flex; align-items: center; gap: 4px;}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(0,0,0,0.3);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.05);
}
.npm-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
}
.npm-link:hover { text-decoration: underline; }

/* Tree Visualization */
.tree-container {
    padding: 1rem 0;
}
.tree-node {
    margin-top: 0.5rem;
}
.node-content {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    transition: var(--transition);
}
.node-content:hover { background: var(--bg-surface-hover); }
.toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    padding: 0;
    display: inline-flex;
    border-radius: 4px;
}
.toggle-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-main); }
.toggle-btn svg { transition: transform 0.2s; }
.toggle-btn.expanded svg { transform: rotate(90deg); }
.toggle-btn.empty svg { visibility: hidden; }

.node-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    overflow: hidden;
}
.node-name { font-weight: 500; color: var(--text-main); font-family: var(--font-mono); font-size: 0.9rem;}
.node-version { color: var(--text-muted); font-size: 0.8rem; font-family: var(--font-mono);}
.node-badges { display: flex; gap: 0.5rem; margin-left: auto; align-items: center;}

.node-children {
    padding-left: 20px;
    border-left: 1px solid rgba(255,255,255,0.1);
    margin-left: 11px; /* Align with toggle button center */
    display: none;
}
.node-children.expanded { display: block; }
.node-loading { font-size: 0.8rem; color: var(--text-muted); padding: 0.5rem 0; font-style: italic;}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(239, 68, 68, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(239, 68, 68, 0.5); }

/* Responsive */
@media (max-width: 900px) {
  .main-content { flex-direction: column; }
  .sidebar { width: 100%; height: auto; max-height: 40vh; }
  .compare-grid { grid-template-columns: 1fr; grid-template-rows: 1fr auto 1fr;}
  .compare-divider { width: 100%; height: 2px; margin: 0.5rem 0;}
}
