:root {
  --accent: #10b981;
  --accent-dim: rgba(16, 185, 129, 0.15);
  --text-primary: #363636;
  --text-secondary: #686868;
  --text-muted: #64748b;
  --glow: rgba(16, 185, 129, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background atmosphere */
.bg-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-atmosphere::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
      ellipse 800px 600px at 20% 30%,
      rgba(16, 185, 129, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse 600px 400px at 80% 70%,
      rgba(6, 182, 212, 0.06) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse 1000px 800px at 50% 50%,
      rgba(16, 185, 129, 0.03) 0%,
      transparent 60%
    );
  animation: float 30s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  33% {
    transform: translate(2%, 1%) rotate(1deg);
  }
  66% {
    transform: translate(-1%, 2%) rotate(-1deg);
  }
}

/* Grid pattern overlay */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: linear-gradient(
      rgba(16, 185, 129, 0.03) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(16, 185, 129, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(
    ellipse 80% 80% at 50% 50%,
    black 40%,
    transparent 100%
  );
}

.main-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
.page-header {
  text-align: center;
  margin-bottom: 3rem;
  opacity: 0;
  transform: translateY(-20px);
  animation: fadeInDown 0.8s ease forwards;
}

@keyframes fadeInDown {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-title {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  background: linear-gradient(
    135deg,
    var(--text-primary) 0%,
    var(--accent) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
}

/* Search box */
.search-container {
  margin-bottom: 2rem;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease 0.2s forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-box {
  position: relative;
  max-width: 500px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.875rem 1.25rem 0.875rem 3rem;
  color: var(--text-primary);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

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

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Stats bar */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.3s forwards;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

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

/* Tree container */
.tree-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.4s forwards;
}

.tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.tree-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.tree-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-tree-action {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-tree-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* Tree nodes */
.tree-root {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tree-node {
  margin: 0;
  padding: 0;
}

.tree-node-content {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.tree-node-content:hover {
  background: var(--bg-hover);
}

.tree-node-content.active {
  background: var(--accent-dim);
}

.tree-node-content.loading {
  pointer-events: none;
}

/* Toggle icon */
.toggle-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  transition: transform 0.3s ease;
}

.toggle-icon svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.tree-node-content:hover .toggle-icon svg {
  color: var(--accent);
}

.toggle-icon.expanded {
  transform: rotate(90deg);
}

.toggle-icon.leaf {
  visibility: hidden;
}

/* Node icon */
.node-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: 6px;
  flex-shrink: 0;
}

.node-icon.class-icon {
  background: linear-gradient(
    135deg,
    var(--accent-dim),
    rgba(6, 182, 212, 0.15)
  );
}

.node-icon.subclass-icon {
  background: var(--bg-secondary);
}

.node-icon.enzyme-icon {
  background: linear-gradient(
    135deg,
    rgba(251, 191, 36, 0.15),
    rgba(245, 158, 11, 0.1)
  );
}

.node-icon svg {
  width: 14px;
  height: 14px;
}

.node-icon.class-icon svg {
  color: var(--accent);
}

.node-icon.subclass-icon svg {
  color: var(--text-secondary);
}

.node-icon.enzyme-icon svg {
  color: #f59e0b;
}

/* Node label */
.node-label {
  flex: 1;
  min-width: 0;
}

.node-title {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.node-ec {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 0.125rem;
}

.node-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.node-description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  line-height: 1.5;
}

/* Children container */
.tree-children {
  list-style: none;
  padding: 0;
  margin: 0;
  padding-left: 1.5rem;
  border-left: 1px dashed var(--border-color);
  margin-left: 10px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
}

.tree-children.expanded {
  max-height: 10000px;
  opacity: 1;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

/* Loading spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Detail panel */
.detail-panel {
  position: fixed;
  top: 0;
  right: -450px;
  width: 450px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  z-index: 1000;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.detail-panel.open {
  right: 0;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.detail-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.detail-header {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  z-index: 1;
}

.detail-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.detail-body {
  padding: 1.5rem;
}

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.detail-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.detail-ec {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.detail-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Error state */
.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

/* Responsive */
@media (max-width: 768px) {
  .main-container {
    padding: 1rem;
  }

  .tree-container {
    padding: 1rem;
  }

  .stats-bar {
    gap: 1rem;
  }

  .detail-panel {
    width: 100%;
    right: -100%;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
