/* ── OrbitWhisper Global Styles ── */
/* LeoLabs-inspired dark space theme */

:root {
  --bg-primary: #0a0e17;
  --bg-sidebar: rgba(8, 14, 28, 0.92);
  --bg-panel: rgba(10, 18, 32, 0.88);
  --bg-input: #0d1520;
  --border-subtle: rgba(70, 130, 220, 0.25);
  --border-accent: rgba(88, 160, 255, 0.5);
  --text-primary: #e0eaff;
  --text-secondary: #8fa8cc;
  --text-dim: #556b8a;
  --accent: #58a6ff;
  --accent-glow: rgba(88, 166, 255, 0.15);
  --danger: #ff4466;
  --success: #00ff88;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Category colors */
  --cat-stations: #ff6600;
  --cat-weather: #00ccff;
  --cat-comm: #ffcc00;
  --cat-nav: #00ff88;
  --cat-science: #cc44ff;
  --cat-misc: #888888;
  --cat-constellation: #4488ff;
}

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg-primary);
  font-family: var(--font);
  color: var(--text-primary);
}

#cesiumContainer {
  position: absolute; inset: 0;
  z-index: 0;
  transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.shift-left { padding-left: 280px; }
.shift-right { padding-right: 300px; }

/* ── Left Sidebar ── */
#sidebar {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 280px; z-index: 10;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  overflow-y: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.collapsed {
  transform: translateX(-100%);
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h1 {
  font-size: 20px; font-weight: 700;
  background: linear-gradient(135deg, #58a6ff, #7dd3fc);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
}

.sidebar-subtitle {
  display: block; font-size: 11px;
  color: var(--text-dim); margin-top: 2px;
  letter-spacing: 0.3px;
}

.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.section-title.clickable {
  cursor: pointer; display: flex;
  justify-content: space-between; align-items: center;
  user-select: none;
}

.section-title.clickable:hover { color: var(--text-primary); }

.toggle-icon {
  font-size: 9px; transition: transform 0.2s;
}

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

.collapsed-content { display: none; }

/* Search */
#searchInput {
  width: 100%; padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px; font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

#searchInput:focus { border-color: var(--accent); }
#searchInput::placeholder { color: var(--text-dim); }

#searchResults {
  list-style: none; margin-top: 6px;
  max-height: 200px; overflow-y: auto;
}

#searchResults li {
  padding: 6px 8px; font-size: 12px;
  cursor: pointer; border-radius: 4px;
  transition: background 0.15s;
  display: flex; justify-content: space-between;
}

#searchResults li:hover { background: var(--accent-glow); }
#searchResults li .sat-cat {
  font-size: 10px; color: var(--text-dim);
  white-space: nowrap;
}

/* Category Filters */
.category-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
  cursor: pointer; user-select: none;
  font-size: 13px;
  transition: opacity 0.15s;
}

.category-item:hover { opacity: 0.85; }

.category-checkbox {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 2px solid var(--text-dim);
  border-radius: 3px;
  cursor: pointer; flex-shrink: 0;
  position: relative;
  transition: all 0.15s;
}

.category-checkbox:checked {
  border-color: transparent;
}

.category-checkbox:checked::after {
  content: '✓'; position: absolute;
  top: -2px; left: 1px;
  font-size: 12px; font-weight: 700;
  color: #fff;
}

.category-dot {
  width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}

.category-label { flex: 1; }

.category-count {
  font-size: 11px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.filter-actions {
  display: flex; gap: 8px; margin-top: 8px;
}

.action-btn {
  flex: 1; padding: 5px 0;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px; font-family: var(--font);
  cursor: pointer; transition: all 0.15s;
}

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

/* Stats */
.stat-row {
  display: flex; justify-content: space-between;
  padding: 2px 0; font-size: 11px;
}

.stat-row span:first-child { color: var(--text-secondary); }
.stat-row span:last-child { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.warn-text { color: var(--danger) !important; font-weight: 600; }

/* Upload */
.upload-btn {
  width: 100%; padding: 8px;
  background: var(--bg-input);
  border: 1px dashed var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px; font-family: var(--font);
  cursor: pointer; transition: all 0.15s;
  margin-top: 8px;
}

.upload-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.status-text {
  margin-top: 6px; font-size: 11px;
  color: var(--accent); min-height: 16px;
}

.sidebar-footer {
  padding: 12px 16px; margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  font-size: 10px;
}

.sidebar-footer a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.sidebar-footer a:hover { color: var(--accent); }

/* ── Bottom Status Bar ── */
#bottomBar {
  position: absolute; bottom: 0; left: 280px; right: 0;
  z-index: 10; height: 28px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  font-size: 11px; color: var(--text-dim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#bottomBar.expanded { left: 0; }

#bottomCount {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* ── Detail Panel ── */
#detailPanel {
  position: absolute; top: 16px; right: 16px;
  z-index: 15;
  width: 260px;
  background: var(--bg-panel);
  border: 1px solid var(--border-accent);
  border-radius: 12px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex; flex-direction: column;
  transition: opacity 0.3s;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  max-height: calc(100vh - 100px);
}

#detailPanel.hidden { display: none; }

.detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; font-weight: 700;
}

.close-btn {
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  font-size: 16px; padding: 2px 6px;
  border-radius: 4px; transition: all 0.15s;
}

.close-btn:hover { background: var(--accent-glow); color: var(--text-primary); }

#detailBody {
  padding: 8px 12px;
}

.detail-row {
  display: flex; justify-content: space-between;
  padding: 3px 0; font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-secondary); }
.detail-row .value { color: var(--text-primary); font-variant-numeric: tabular-nums; text-align: right; }

.sidebar-section-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--accent);
  margin-top: 10px; margin-bottom: 6px;
  opacity: 0.8;
}

.separator {
  height: 1px; background: var(--border-subtle);
  margin: 8px 0; opacity: 0.5;
}

#survivalChart {
  width: 100%;
  height: 220px;
  margin-top: 10px;
}

/* ── Conjunction Panel ── */
#chartPanel.hidden { display: none; }

.chart-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px; font-weight: 600;
}

#survivalChart {
  flex: 1; min-height: 0; padding: 10px;
}

/* ── Naming Modal ── */
#namingModal {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}

.modal-content {
  width: 380px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-accent);
  border-radius: 10px; padding: 20px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  color: var(--text-primary);
}

#modalMessage { margin-bottom: 16px; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }

#namingInput {
  width: 100%; padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px; margin-bottom: 20px;
  outline: none; transition: border-color 0.2s;
}

#namingInput:focus { border-color: var(--accent); }

.modal-actions {
  display: flex; gap: 12px;
}

.modal-actions .action-btn {
  flex: 1; padding: 10px 0; font-size: 13px; font-weight: 500;
}

.modal-actions .action-btn:first-child {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.modal-actions .action-btn:first-child:hover {
  background: #3b8ce0;
}

/* ── Cesium overrides ── */
.cesium-viewer-bottom { display: none !important; }
.cesium-widget-credits { display: none !important; }
.cesium-viewer .cesium-widget { border: none !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
  #legend { display: none; }
}

/* ── Panel Toggles ── */
.panel-toggle {
  position: absolute;
  z-index: 100;
  background: var(--bg-panel);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.panel-toggle:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px var(--accent);
  border-color: #fff;
}

.side-toggle {
  top: 50%; left: 280px; transform: translate(0, -50%);
  width: 24px; height: 64px;
  border-radius: 0 12px 12px 0;
  border-left: none;
}

.side-toggle.collapsed {
  left: 0; transform: translate(0, -50%);
}

.side-toggle-right {
  top: 50%; right: 330px; transform: translate(0, -50%);
  width: 24px; height: 60px;
  border-radius: 12px 0 0 12px;
  border-right: none;
}

.side-toggle-right.collapsed {
  right: 0; transform: translate(0, -50%);
}

.mini-toggle {
  top: 4px; right: 4px;
  width: 24px; height: 24px;
  font-size: 11px; border-radius: 6px;
}

.panel-toggle.hidden { display: none; }

/* ── Conjunction Panel ── */
#conjunctionPanel {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 600px; max-height: 80vh;
  z-index: 40;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-accent);
  border-radius: 12px;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  backdrop-filter: blur(20px);
}

#conjunctionPanel.hidden { display: none; }

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; color: var(--danger);
  font-size: 15px;
}

.scroll-list {
  padding: 10px; overflow-y: auto;
  flex: 1;
}

.conj-item {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr 1fr 1fr;
  gap: 10px; padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 12px; cursor: pointer;
  transition: background 0.2s;
}

.conj-item:hover { background: rgba(255, 68, 102, 0.1); }
.conj-item div { display: flex; align-items: center; }
.conj-val { font-family: monospace; color: #fff; }
.conj-label { color: var(--text-dim); font-size: 10px; margin-right: 4px; }
.conj-btn { color: var(--accent); font-weight: 600; text-align: right; }
