/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --purple: #a78bfa;
  --pink: #f472b6;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header --- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  font-size: 1.5rem;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-user img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.header-user a {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* --- Navigation tabs --- */
.nav-tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  padding: 0.75rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--surface-hover);
  text-decoration: none;
}

.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Main content --- */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* --- Ancestry --- */
.pca-container {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.pca-container img {
  width: 100%;
  height: auto;
  display: block;
}

.haplogroup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .haplogroup-grid { grid-template-columns: 1fr; }
}

.haplogroup-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

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

.haplogroup-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  margin-bottom: 0.5rem;
}

.haplogroup-value.y-dna { color: var(--accent); }
.haplogroup-value.mt-dna { color: var(--pink); }
.haplogroup-value.pending { color: var(--text-muted); font-style: italic; font-size: 1rem; }

.haplogroup-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.haplogroup-full {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 0.25rem;
}

/* --- Traits --- */
.trait-category {
  margin-bottom: 2rem;
}

.category-header {
  font-size: 1rem;
  font-weight: 600;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-count {
  background: var(--surface-hover);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 400;
}

.trait-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s;
}

.trait-item:hover {
  border-color: var(--surface-hover);
}

.trait-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.trait-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.trait-gene {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: monospace;
}

.trait-genotype {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
}

.trait-label {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.trait-interpretation {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.trait-recommendation {
  font-size: 0.8rem;
  color: var(--success);
  padding: 0.5rem 0.75rem;
  background: rgba(52, 211, 153, 0.08);
  border-radius: 6px;
  border-left: 3px solid var(--success);
}

.trait-confidence {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.confidence-well-established {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.confidence-preliminary {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

/* --- Chromosome art --- */
.ideogram-container {
  background: #0d1117;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.ideogram-container img {
  width: 100%;
  height: auto;
  display: block;
}

/* --- Timeline --- */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-event {
  position: relative;
  margin-bottom: 1.5rem;
  padding-left: 1rem;
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: -1.75rem;
  top: 0.5rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-event.type-import::before { background: var(--purple); }
.timeline-event.type-analysis::before { background: var(--success); }

.timeline-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-bottom: 0.25rem;
}

.timeline-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.timeline-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.timeline-badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-right: 0.5rem;
}

.badge-import { background: rgba(167, 139, 250, 0.15); color: var(--purple); }
.badge-analysis { background: rgba(52, 211, 153, 0.15); color: var(--success); }

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

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.placeholder-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.placeholder-text {
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto;
}

/* --- Stats bar --- */
.stats-bar {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
}

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

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .main { padding: 1rem; }
  .card { padding: 1rem; }
  .header { padding: 0.5rem 1rem; }
  .header-title { font-size: 0.95rem; }
  .header-subtitle { display: none; }
  .stats-bar { gap: 1rem; }
  .stat-value { font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .nav-tab { padding: 0.6rem 0.75rem; font-size: 0.8rem; }
  .trait-header { flex-direction: column; gap: 0.25rem; }
}
