:root {
  --bg-color: #0d1117;
  --surface: rgba(22, 27, 34, 0.7);
  --surface-solid: #161b22;
  --surface-hover: rgba(33, 38, 45, 0.8);
  --border: rgba(48, 54, 61, 0.6);
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --primary: #58a6ff;
  --primary-hover: #3182ce;
  --danger: #f85149;
  --danger-bg: rgba(248, 81, 73, 0.1);
  --success: #2ea043;
  --success-bg: rgba(46, 160, 67, 0.1);
  --border-radius: 12px;
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --sidebar-width: 320px;
}

[data-theme="light"] {
  --bg-color: #f6f8fa;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-solid: #ffffff;
  --surface-hover: rgba(243, 244, 246, 0.9);
  --border: rgba(208, 215, 222, 0.6);
  --text: #24292f;
  --text-muted: #57606a;
  --primary: #0969da;
  --danger: #cf222e;
  --danger-bg: rgba(207, 34, 46, 0.1);
  --success: #1a7f37;
  --success-bg: rgba(26, 127, 55, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(140, 148, 159, 0.15);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  display: flex;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Glassmorphism utility */
.glass {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 1px 0 10px rgba(0,0,0,0.1);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  color: var(--primary);
  width: 28px;
  height: 28px;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

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

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

/* Actions & Buttons */
.action-card {
  padding: 1.25rem;
  border-radius: var(--border-radius);
  text-align: center;
}

.primary-action {
  border: 1px dashed var(--border);
  background: var(--surface-hover);
  transition: all 0.2s;
}

.primary-action:hover {
  border-color: var(--primary);
  background: rgba(88, 166, 255, 0.05);
}

.upload-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.4;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.search-box input {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.25rem;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
}

.search-box input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Togglers */
.toggle-group {
  display: flex;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--surface-hover);
  color: var(--primary);
}

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

/* Status Panels */
.status-panel {
  padding: 1rem;
  border-radius: var(--border-radius);
  max-height: 250px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.status-panel h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin: 0;
  color: inherit;
  text-transform: none;
}

.status-panel h3 i {
  width: 18px;
  height: 18px;
}

.error-panel {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.success-panel {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(46, 160, 67, 0.3);
}

.scrollable-list {
  list-style: none;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.scrollable-list li {
  background: var(--surface-solid);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  word-break: break-all;
}

.error-panel .scrollable-list li {
  border-color: rgba(248, 81, 73, 0.3);
}

/* Exporter Actions */
.exporter-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

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

/* Main Content Area */
.main-content {
  flex: 1;
  position: relative;
  background-color: var(--bg-color);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
}

#empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 1rem;
  z-index: 5;
}

.empty-icon {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

#graph-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  outline: none;
}

/* vis-network overrides */
.vis-network {
  outline: none;
}

/* Theme Toggle */
.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 20;
}

#themeToggleBtn {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

#themeToggleBtn:hover {
  background: var(--surface-hover);
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: 350px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
