:root {
  /* Dynamic themes using CSS variables */
  --primary: #6366F1;
  --secondary: #8B5CF6;
  --accent: #22D3EE;
  
  /* Shared Base */
  --border-radius: 12px;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-color: rgba(0, 0, 0, 0.1);
  
  /* Dark Mode Default */
  --bg-color: #0F172A;
  --surface-color: rgba(30, 41, 59, 0.7);
  --surface-border: rgba(255, 255, 255, 0.1);
  --text-primary: #F8FAFC;
  --text-muted: #94A3B8;
  --input-bg: rgba(15, 23, 42, 0.6);
  --hover-bg: rgba(255, 255, 255, 0.05);
  
  /* Link line colors */
  --link-color: rgba(148, 163, 184, 0.4);
  --link-color-highlight: var(--primary);
  
  /* Node Types - Base Palette */
  --node-app: #ef4444;
  --node-pkg: #3b82f6;
  --node-tool: #10b981;
  --node-lib: #f59e0b;
  --node-other: #6b7280;
}

.light-mode {
  --bg-color: #F8FAFC;
  --surface-color: rgba(255, 255, 255, 0.8);
  --surface-border: rgba(0, 0, 0, 0.1);
  --text-primary: #0F172A;
  --text-muted: #64748B;
  --input-bg: rgba(255, 255, 255, 1);
  --hover-bg: rgba(0, 0, 0, 0.05);
  --link-color: rgba(100, 116, 139, 0.3);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: background-color var(--transition), color var(--transition);
}

/* Utilities */
.hidden { display: none !important; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }
.text-warning { color: #f59e0b; }
.w-full { width: 100%; }
.mt-3 { margin-top: 0.75rem; }
.mt-auto { margin-top: auto; }
.break-all { word-break: break-all; }

/* Glassmorphism */
.glass-panel {
  background: var(--surface-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  box-shadow: 0 8px 32px var(--shadow-color);
}

.glass-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-family);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.glass-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

textarea.glass-input {
  resize: vertical;
  min-height: 80px;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 320px;
  min-width: 320px;
  height: 100%;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 10;
  overflow-y: auto;
  border-right: 1px solid var(--surface-border);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--primary);
}

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

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group > label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Multi-tab system */
.tabs {
  display: flex;
  background: var(--input-bg);
  border-radius: 8px;
  padding: 0.25rem;
  border: 1px solid var(--surface-border);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.375rem 0;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.tab-content {
  animation: fadeIn 0.3s ease;
}

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

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--surface-border);
  border-radius: var(--border-radius);
  padding: 1.5rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  background: var(--input-bg);
  transition: var(--transition);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.upload-zone svg {
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.upload-zone p {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  font-family: var(--font-family);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
  background: #4f46e5;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border-color: var(--surface-border);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

/* Search Box */
.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  padding-left: 2.25rem;
}

/* Filters */
.filters {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.filter-item input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.filter-item input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.filter-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.type-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

/* Warnings */
.warnings-container {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  padding: 0.75rem;
}

.warning-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #f59e0b;
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.warning-list {
  padding-left: 1.5rem;
  color: var(--text-muted);
  margin-block: 0;
}

.warning-list li {
  margin-bottom: 0.25rem;
}

/* Export actions */
.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* Main View */
.main-view {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-image: radial-gradient(var(--surface-border) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Toolbar */
.graph-toolbar {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  z-index: 10;
}

.view-controls {
  display: flex;
  gap: 0.25rem;
}

.legend {
  display: flex;
  gap: 1rem;
  padding-left: 1.5rem;
  border-left: 1px solid var(--surface-border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Graph Container */
.graph-container {
  width: 100%;
  height: 100%;
  cursor: grab;
}

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

.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  color: var(--text-muted);
  max-width: 400px;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--hover-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--primary);
  margin-bottom: 1rem;
}

/* Node/Link styling in D3 */
.node-circle {
  transition: r 0.3s ease, fill-opacity 0.3s ease;
}
.node-circle.fade {
  fill-opacity: 0.2;
}
.node-circle.highlight {
  stroke: var(--text-primary);
  stroke-width: 2px;
}
.node-text {
  font-family: var(--font-family);
  font-size: 11px;
  fill: var(--text-primary);
  pointer-events: none;
  font-weight: 500;
  text-shadow: 0 1px 3px var(--bg-color), 0 -1px 3px var(--bg-color), 1px 0 3px var(--bg-color), -1px 0 3px var(--bg-color);
  transition: opacity 0.3s ease;
}
.node-text.fade {
  opacity: 0.1;
}

.link {
  stroke: var(--link-color);
  transition: stroke 0.3s ease, stroke-opacity 0.3s ease, stroke-width 0.3s ease;
}
.link.fade {
  stroke-opacity: 0.1;
}
.link.highlight {
  stroke: var(--link-color-highlight);
  stroke-opacity: 1;
  stroke-width: 2px;
}

/* Details Panel */
.details-panel {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 320px;
  max-height: calc(100vh - 3rem);
  border-radius: var(--border-radius);
  overflow-y: auto;
  z-index: 20;
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}

.details-panel.hidden {
  transform: translateX(120%);
  opacity: 0;
  pointer-events: none;
  display: block !important;
}

.details-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--surface-border);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.details-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  padding-right: 2rem;
  word-break: break-all;
}

.details-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.badge {
  display: inline-flex;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary);
  color: white;
  align-self: flex-start;
}

.details-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.detail-value {
  font-size: 0.875rem;
  font-weight: 500;
}

.detail-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dep-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dep-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  padding: 0.5rem;
  background: var(--input-bg);
  border-radius: 6px;
  border: 1px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}

.dep-list li:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.dep-list li.dev-dep {
  border-left: 2px solid var(--secondary);
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(15, 23, 42, 0.9);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* Toast Notification */
.toast {
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--secondary);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
  z-index: 100;
  transition: transform 0.3s, opacity 0.3s;
}

.toast.hidden {
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  pointer-events: none;
  display: block !important;
}
