:root {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef1f6;
  --text-primary: #1a1d26;
  --text-secondary: #5a6275;
  --text-muted: #8b92a5;
  --accent-primary: #0d6efd;
  --accent-secondary: #0b5ed7;
  --border-color: #d8dce6;
  --card-shadow: 0 2px 12px rgba(26, 29, 38, 0.08);
  --card-shadow-hover: 0 6px 24px rgba(26, 29, 38, 0.12);
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

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

/* Header */
.page-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

/* Main container */
.main-container {
  display: flex;
  height: calc(100vh - 72px);
  overflow: hidden;
}

/* Left panel - 3D scatter */
.scatter-panel {
  width: 85%;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.scatter-container {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
}

#scatter-chart {
  width: 100%;
  height: 100%;
}

.scatter-overlay {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-family: "JetBrains Mono", monospace;
}

/* Right panel */
.info-panel {
  width: 15%;
  min-width: 250px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Taxonomy selector */
.taxonomy-selector {
  width: 100%;
}

.form-select {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.875rem;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.form-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

/* Legend */
.legend-container {
  max-height: 180px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
  font-size: 0.8rem;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.legend-item:hover {
  opacity: 0.7;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-label {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Genome info section */
.genome-info {
  flex: 1;
  overflow-y: auto;
}

.no-selection {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.no-selection-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.no-selection-text {
  font-size: 0.85rem;
}

/* Selected genome card */
.genome-card {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 0.875rem;
  margin-bottom: 0.75rem;
}

.genome-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.genome-taxid {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.taxonomy-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.taxonomy-list li {
  display: flex;
  font-size: 0.8rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.taxonomy-list li:last-child {
  border-bottom: none;
}

.taxonomy-rank {
  width: 70px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: capitalize;
}

.taxonomy-value {
  color: var(--text-primary);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
}

/* Radar chart container */
.radar-container {
  height: 220px;
  margin-top: 0.5rem;
}

#radar-chart {
  width: 100%;
  height: 100%;
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
  font-family: "JetBrains Mono", monospace;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-secondary);
}

.stat-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

/* Loading state */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 992px) {
  .main-container {
    flex-direction: column;
    height: auto;
  }

  .scatter-panel {
    width: 100%;
    height: 60vh;
  }

  .info-panel {
    width: 100%;
    min-width: auto;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}
