/* ===== Design Tokens ===== */
:root {
  --bg-primary: #0A0F1A;
  --bg-secondary: #101828;
  --bg-card: #151d2e;
  --bg-card-hover: #1a2540;
  --bg-input: #0d1322;
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --primary: #3498DB;
  --primary-light: #5dade2;
  --secondary: #2980B9;
  --accent: #1ABC9C;
  --accent-light: #48d1b0;
  --border: rgba(52, 152, 219, 0.12);
  --border-strong: rgba(52, 152, 219, 0.25);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.2s ease;
  --glass: rgba(21, 29, 46, 0.8);
  --glass-border: rgba(52, 152, 219, 0.1);

  /* Node colors by type */
  --node-js: #f7df1e;
  --node-ts: #3178c6;
  --node-css: #264de4;
  --node-html: #e34c26;
  --node-json: #59a14f;
  --node-other: #94a3b8;
  --node-circular: #ef4444;
  --node-orphan: rgba(148, 163, 184, 0.5);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  height: 56px;
}

.header-inner {
  max-width: 100%;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { font-size: 1.4rem; }

.logo h1 {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-icon { width: 15px; height: 15px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card); border-color: var(--border-strong); color: var(--text-primary); }
.btn-ghost:disabled { opacity: 0.4; cursor: default; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-card); color: var(--primary); }
.icon-btn svg { width: 16px; height: 16px; }

/* ===== Layout ===== */
.app-layout {
  display: flex;
  height: calc(100vh - 56px);
  margin-top: 56px;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 16px;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  transition: all var(--transition);
}
.search-wrap input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(52,152,219,0.15); }

/* Filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}
.chip:hover { border-color: var(--primary); color: var(--text-primary); }
.chip.active { background: rgba(52,152,219,0.15); border-color: var(--primary); color: var(--primary); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.js { background: var(--node-js); }
.dot.ts { background: var(--node-ts); }
.dot.css { background: var(--node-css); }
.dot.html { background: var(--node-html); }
.dot.json { background: var(--node-json); }
.dot.other { background: var(--node-other); }

/* Toggle options */
.toggle-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-option input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
}

/* Stats grid */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-stat {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.mini-val {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
}

.mini-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Detail panel */
.detail-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.detail-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.detail-path {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-bottom: 8px;
}

.detail-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(52,152,219,0.15);
  color: var(--primary);
  margin-bottom: 10px;
}

.detail-group {
  margin-top: 10px;
}

.detail-group h4 {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-list {
  list-style: none;
  max-height: 120px;
  overflow-y: auto;
}

.detail-list li {
  font-size: 0.78rem;
  padding: 3px 0;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition);
}
.detail-list li:hover { color: var(--accent); }

/* ===== Graph Container ===== */
.graph-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#graph-canvas:active { cursor: grabbing; }

.graph-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.ctrl-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--glass);
  backdrop-filter: blur(8px);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.ctrl-btn:hover { color: var(--primary); border-color: var(--primary); }
.ctrl-btn svg { width: 16px; height: 16px; }

/* ===== Empty State ===== */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
  text-align: center;
  padding: 20px;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.empty-state h2 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  max-width: 400px;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.empty-actions {
  display: flex;
  gap: 10px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-sm { max-width: 360px; }

@keyframes slideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 10px;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }

.modal-body { padding: 8px 22px 22px; }

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.modal-desc code {
  background: rgba(52,152,219,0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--accent);
}

.modal-body textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  resize: vertical;
  min-height: 180px;
  transition: border var(--transition);
}
.modal-body textarea:focus { outline: none; border-color: var(--primary); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.export-options {
  display: flex;
  gap: 12px;
}

.export-opt {
  flex: 1;
  padding: 18px;
  font-size: 0.9rem;
  justify-content: center;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .header-actions { gap: 4px; }
  .header-actions .btn { padding: 6px 10px; font-size: 0.78rem; }
}
