/* ═══════════════════════════════════════════════════════════════════════════
   ORBITAL DATA EXPLORER — Dark theme dashboard
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

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

:root {
  --bg-deep: hsl(220, 30%, 6%);
  --bg-panel: rgba(20, 24, 30, 0.96);
  --bg-panel-hover: rgba(30, 35, 45, 0.96);
  --border: rgba(255, 255, 255, 0.07);
  --text: rgba(255, 255, 255, 0.85);
  --text-muted: rgba(255, 255, 255, 0.5);
  --accent: #2e64be;
  --green: rgba(143, 188, 143, 0.85);
  --amber: #f0b040;
}

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

/* ── Header ─────────────────────────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  background: linear-gradient(135deg, hsla(215, 35%, 14%, 0.98), hsla(220, 30%, 8%, 0.98));
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

header h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-controls label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Planet button bar */
.planet-bar {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.planet-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: none;
  border-right: 1px solid var(--border);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.planet-btn:last-child {
  border-right: none;
}

.planet-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.planet-btn.active {
  background: var(--pc, #888);
  color: #fff;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.planet-btn::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pc, #888);
  margin-right: 4px;
  vertical-align: middle;
}

.planet-btn.active::before {
  background: #fff;
}

/* Range toggle buttons */
.range-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.range-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: none;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.range-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.range-btn.active {
  background: var(--accent);
  color: #fff;
}

.range-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
}

.header-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}

.header-link:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ── Main content ───────────────────────────────────────────────────────── */

main {
  padding: 16px 24px 40px;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Chart panels ───────────────────────────────────────────────────────── */

.chart-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px 8px;
  backdrop-filter: blur(14px);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chart-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chart-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* CSV export button */
.csv-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  letter-spacing: 0.03em;
}

.csv-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

/* Expand button */
.expand-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1;
}

.expand-btn:hover {
  color: var(--text);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.05);
}

/* Expanded chart panel */
.chart-panel.expanded {
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  border-radius: 0;
  margin: 0;
  overflow: hidden;
}

.chart-panel.expanded .chart-container {
  height: calc(100vh - 100px);
}

.chart-container {
  width: 100%;
  height: 400px;
  transition: height 0.3s ease;
}

.earth-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 500;
  color: #2e64be;
  background: rgba(46, 100, 190, 0.15);
  border: 1px solid rgba(46, 100, 190, 0.3);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Info panel ─────────────────────────────────────────────────────────── */

.info-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  backdrop-filter: blur(14px);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 24px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.info-label {
  font-size: 11px;
  color: var(--text-muted);
}

.info-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text);
}

.info-j2000 .info-value {
  color: #4fc3f7;
}

.info-j2000 .info-label {
  color: rgba(79, 195, 247, 0.6);
}

/* ── Loading overlay ────────────────────────────────────────────────────── */

.loading {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 14, 20, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

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

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

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .planet-btn::before {
    margin-right: 2px;
  }
  .planet-btn {
    padding: 5px 6px;
    font-size: 10px;
  }
  .range-btn {
    padding: 5px 8px;
    font-size: 10px;
  }
}

@media (max-width: 800px) {
  header {
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
  }

  .header-left {
    flex-direction: column;
    gap: 2px;
    align-items: center;
  }

  .header-controls {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .planet-bar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .planet-btn {
    padding: 4px 8px;
    font-size: 10px;
  }

  .range-toggle {
    flex-wrap: wrap;
    justify-content: center;
  }

  main {
    padding: 8px 8px 24px;
  }

  .chart-container {
    height: 220px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .header-link {
    display: none;
  }

  .jump-nav {
    display: none;
  }

  .chart-panel.expanded .chart-container {
    height: calc(100vh - 80px);
  }
}

/* ── Jump navigation ────────────────────────────────────────────────────── */

.jump-nav {
  position: fixed;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(20, 24, 30, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.jump-link {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  border-radius: 4px;
  text-align: center;
  transition: all 0.15s;
}

.jump-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.jump-link.active {
  color: #fff;
  background: var(--accent);
}

/* ── Theme toggle ───────────────────────────────────────────────────────── */

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

/* ── Light mode ─────────────────────────────────────────────────────────── */

body.light-mode {
  --bg-deep: #f0f2f5;
  --bg-panel: rgba(255, 255, 255, 0.96);
  --bg-panel-hover: rgba(245, 245, 250, 0.96);
  --border: rgba(0, 0, 0, 0.1);
  --text: rgba(0, 0, 0, 0.85);
  --text-muted: rgba(0, 0, 0, 0.5);
  --accent: #2e64be;
}

body.light-mode header {
  background: linear-gradient(135deg, rgba(240, 242, 248, 0.98), rgba(230, 234, 242, 0.98));
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

body.light-mode .planet-bar {
  border-color: rgba(0, 0, 0, 0.12);
}

body.light-mode .planet-btn {
  background: rgba(0, 0, 0, 0.02);
  color: rgba(0, 0, 0, 0.6);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .planet-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.85);
}

body.light-mode .planet-btn.active {
  background: rgba(0, 0, 0, 0.07);
  color: rgba(0, 0, 0, 0.85);
  font-weight: 600;
  text-shadow: none;
  box-shadow: inset 0 -2px 0 var(--pc, #888);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .planet-btn.active::before {
  background: var(--pc, #888);
}

body.light-mode .range-toggle {
  border-color: rgba(0, 0, 0, 0.12);
}

body.light-mode .range-btn {
  background: rgba(0, 0, 0, 0.02);
  color: rgba(0, 0, 0, 0.6);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .range-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.85);
}

body.light-mode .range-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

body.light-mode .info-panel {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .info-label {
  color: rgba(0, 0, 0, 0.5);
}

body.light-mode .info-value {
  color: rgba(0, 0, 0, 0.85);
}

body.light-mode .info-j2000 .info-value {
  color: #0277bd;
}

body.light-mode .info-j2000 .info-label {
  color: rgba(2, 119, 189, 0.6);
}

body.light-mode .theme-toggle {
  border-color: rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.5);
}

body.light-mode .theme-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.25);
  color: rgba(0, 0, 0, 0.8);
}

body.light-mode .chart-panel {
  backdrop-filter: none;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  background: #fff;
}

body.light-mode .chart-title {
  color: rgba(0, 0, 0, 0.6);
}

body.light-mode .csv-btn {
  color: rgba(0, 0, 0, 0.5);
  border-color: rgba(0, 0, 0, 0.15);
}

body.light-mode .csv-btn:hover {
  color: rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.04);
}

body.light-mode .expand-btn {
  color: rgba(0, 0, 0, 0.4);
}

body.light-mode .expand-btn:hover {
  color: rgba(0, 0, 0, 0.7);
  background: rgba(0, 0, 0, 0.04);
}

body.light-mode .modebar-container {
  background: rgba(255, 255, 255, 0.9) !important;
}

body.light-mode .modebar-group {
  background: rgba(240, 242, 248, 0.95) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 4px !important;
}

body.light-mode .modebar-btn {
  opacity: 0.7 !important;
}

body.light-mode .modebar-btn:hover {
  opacity: 1 !important;
}

body.light-mode .modebar-btn path {
  fill: rgba(0, 0, 0, 0.6) !important;
}

body.light-mode .modebar-btn:hover path {
  fill: rgba(0, 0, 0, 0.9) !important;
}

body.light-mode .jump-nav {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

body.light-mode .jump-link {
  color: rgba(0, 0, 0, 0.55);
  font-weight: 600;
}

body.light-mode .jump-link:hover {
  color: rgba(0, 0, 0, 0.85);
  background: rgba(0, 0, 0, 0.06);
}

body.light-mode .jump-link.active {
  background: var(--accent);
  color: #fff;
}

body.light-mode .earth-badge {
  background: rgba(46, 100, 190, 0.1);
  border-color: rgba(46, 100, 190, 0.25);
}

body.light-mode .loading {
  background: rgba(240, 242, 245, 0.7);
}

body.light-mode .info-item {
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

/* ── Plotly overrides ───────────────────────────────────────────────────── */

.js-plotly-plot .plotly .modebar {
  top: 2px !important;
  right: 2px !important;
}

.js-plotly-plot .plotly .modebar-btn {
  opacity: 0.4;
}

.js-plotly-plot .plotly .modebar-btn:hover {
  opacity: 0.8;
}

/* ── Dashboard tab navigation ────────────────────────────────────────── */

.dashboard-tabs {
  display: flex;
  gap: 2px;
  align-items: center;
}

.tab-link {
  padding: 6px 14px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary, rgba(255,255,255,0.45));
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.tab-link:hover {
  color: var(--text, rgba(255,255,255,0.85));
}

.tab-link.active {
  border-bottom-color: #4a9eff;
  color: var(--text, rgba(255,255,255,0.85));
}

.light-mode .tab-link {
  color: rgba(0,0,0,0.4);
}

.light-mode .tab-link:hover {
  color: rgba(0,0,0,0.8);
}

.light-mode .tab-link.active {
  color: rgba(0,0,0,0.85);
  border-bottom-color: #2e64be;
}

/* ── Positions dashboard extras ──────────────────────────────────────── */

.center-year-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary, rgba(255,255,255,0.6));
}

.center-year-input {
  width: 65px;
  padding: 4px 6px;
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: 'IBM Plex Mono', monospace;
  text-align: center;
}

.center-year-input:focus {
  outline: 1px solid var(--accent, #4a9eff);
}
