/* ============================================
   LEO Satellite Constellation Visualizer
   Dark Space Theme
   ============================================ */

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

:root {
  --bg-dark: #080c14;
  --bg-panel: #0d1421;
  --bg-panel-hover: #121a2e;
  --border-color: #1e3a5f;
  --border-glow: #2a5298;
  --text-primary: #e8f0fe;
  --text-secondary: #7aa0c4;
  --text-muted: #4a6b8a;
  --accent-blue: #4a9eff;
  --accent-green: #00ff88;
  --accent-red: #ff4444;
  --accent-yellow: #ffcc00;
  --link-blue: #2255cc;
  --link-green: #00aa55;
  --link-red: #cc2222;
  --scrollbar-bg: #0d1421;
  --scrollbar-thumb: #1e3a5f;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ============ LAYOUT ============ */

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#globe-container {
  flex: 1;
  position: relative;
  min-width: 0;
  background: radial-gradient(ellipse at center, #0a1628 0%, #050810 70%);
}

#globe-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#dashboard {
  width: 420px;
  min-width: 380px;
  max-width: 500px;
  height: 100vh;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

/* ============ SCROLLBARS ============ */

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-glow);
}

/* ============ DASHBOARD HEADER ============ */

#dashboard-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, #0f1d35 0%, var(--bg-panel) 100%);
  flex-shrink: 0;
}

#dashboard-header h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-blue);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

#dashboard-header .subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============ STATS BAR ============ */

#stats-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: #0a1220;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 60px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-blue);
  font-variant-numeric: tabular-nums;
}

.stat-value.green { color: var(--accent-green); }
.stat-value.yellow { color: var(--accent-yellow); }
.stat-value.red { color: var(--accent-red); }

/* ============ DASHBOARD SECTIONS ============ */

#dashboard-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.section {
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  transition: background 0.15s;
}

.section-header:hover {
  background: var(--bg-panel-hover);
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
}

.btn-clear-all {
  background: transparent;
  border: none;
  color: #cc4444;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
  margin-left: auto;
  margin-right: 4px;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}
.btn-clear-all:hover {
  opacity: 1;
  background: rgba(204, 34, 34, 0.15);
}

.section-toggle {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.section-toggle.open {
  transform: rotate(180deg);
}

.section-content {
  padding: 8px 12px;
  display: none;
}

.section-content.open {
  display: block;
}

/* ============ FORM ELEMENTS ============ */

.form-group {
  margin-bottom: 6px;
}

.form-group label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  background: #0a1628;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a6b8a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-row {
  display: flex;
  gap: 8px;
}

.form-row .form-group {
  flex: 1;
}

/* ============ BUTTONS ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: var(--accent-blue);
  color: #000;
  border-color: var(--accent-blue);
}

.btn-primary:hover {
  background: #6bb3ff;
  box-shadow: 0 0 12px rgba(74, 158, 255, 0.4);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-panel-hover);
  border-color: var(--border-glow);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border-color: rgba(255, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 68, 68, 0.1);
}

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

.btn-full {
  width: 100%;
}

/* ============ FLOW LIST ============ */

#flow-list-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 200px;
}

#flow-list-section .section-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}

#flow-list-section .section-content.open {
  display: flex;
}

#flow-table-wrapper {
  flex: 1;
  overflow-y: auto;
}

.flow-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.flow-table th {
  padding: 7px 10px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: #0a1220;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.flow-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(30, 58, 95, 0.4);
  vertical-align: middle;
  color: var(--text-primary);
}

.flow-row {
  cursor: pointer;
  transition: background 0.1s;
}

.flow-row:hover {
  background: var(--bg-panel-hover);
}

.flow-row.active {
  background: rgba(74, 158, 255, 0.1);
  border-left: 2px solid var(--accent-blue);
}

.flow-id {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  color: var(--accent-blue);
  white-space: nowrap;
}

.flow-status {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 4px var(--accent-green);
}

.flow-status.rerouted {
  background: var(--accent-yellow);
  box-shadow: 0 0 4px var(--accent-yellow);
}

.flow-status.blocked {
  background: var(--accent-red);
  box-shadow: 0 0 4px var(--accent-red);
}

/* ============ TOOLTIP ============ */

#link-tooltip {
  position: fixed;
  background: rgba(8, 16, 30, 0.95);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  display: none;
  max-width: 260px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 20px rgba(42, 82, 152, 0.2);
}

#link-tooltip.visible {
  display: block;
  pointer-events: auto;
}

#link-tooltip .tooltip-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  line-height: 1;
}

#link-tooltip .tooltip-close:hover {
  color: var(--text-primary);
}

#link-tooltip .tooltip-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

#link-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 12px;
}

#link-tooltip .tooltip-key {
  color: var(--text-muted);
  font-size: 11px;
}

#link-tooltip .tooltip-val {
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
}

#link-tooltip .tooltip-flows {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
  font-size: 10px;
  color: var(--text-muted);
}

#link-tooltip .tooltip-flows span {
  display: inline-block;
  background: rgba(74, 158, 255, 0.15);
  color: var(--accent-blue);
  border-radius: 3px;
  padding: 1px 5px;
  margin: 1px 2px;
  font-family: 'Courier New', monospace;
}

/* ============ MODAL DIALOG ============ */

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

#modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8), 0 0 40px rgba(42, 82, 152, 0.15);
}

.modal h2 {
  font-size: 16px;
  color: var(--accent-blue);
  margin-bottom: 8px;
}

.modal p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

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

/* ============ NOTIFICATIONS ============ */

#notification-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.notification {
  background: rgba(8, 16, 30, 0.95);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: slideDown 0.3s ease, fadeOut 0.3s ease 2.7s;
  pointer-events: all;
  max-width: 360px;
  text-align: center;
}

.notification.success { border-color: var(--accent-green); }
.notification.error { border-color: var(--accent-red); }
.notification.info { border-color: var(--accent-blue); }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ============ LEGEND ============ */

#legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(8, 16, 30, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 11px;
  z-index: 5;
  overflow: hidden;
}

#legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

#legend-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.legend-chevron {
  font-size: 8px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

#legend.collapsed .legend-chevron {
  transform: rotate(-90deg);
}

#legend-body {
  padding: 0 12px 10px;
}

#legend.collapsed #legend-body {
  display: none;
}

.legend-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.legend-line {
  width: 24px;
  height: 2px;
  border-radius: 1px;
}

.legend-line.blue { background: #4488ff; }
.legend-line.green { background: #00cc66; }
.legend-line.red { background: #ff4444; }


/* ============ PAUSE BUTTON ============ */

/* Globe control buttons container (left-center of globe) */
.globe-controls {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.globe-controls button {
  background: rgba(8, 16, 30, 0.7);
  border: 1px solid rgba(30, 58, 95, 0.6);
  border-radius: 6px;
  color: #e8f0fe;
  font-size: 14px;
  width: 36px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
}

.globe-controls button:hover {
  background: rgba(20, 35, 60, 0.85);
  border-color: var(--border-glow);
}

#pause-btn {
  letter-spacing: -2px;
}

#light-btn {
  font-size: 16px;
  letter-spacing: 0;
}

/* ============ CAMERA CONTROLS HINT ============ */

#controls-hint {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(8, 16, 30, 0.7);
  border: 1px solid rgba(30, 58, 95, 0.5);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 10px;
  color: var(--text-muted);
  z-index: 5;
  line-height: 1.7;
  pointer-events: none;
}

/* ============ LOADING ============ */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

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

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

.loading-text {
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: 1px;
}

.loading-sub {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 6px;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 900px) {
  #app {
    flex-direction: column;
  }

  #globe-container {
    flex: none;
    height: 55vh;
  }

  #dashboard {
    width: 100%;
    max-width: 100%;
    height: 45vh;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}

/* ============ MISC ============ */

.text-muted { color: var(--text-muted); }
.text-success { color: var(--accent-green); }
.text-warning { color: var(--accent-yellow); }
.text-danger { color: var(--accent-red); }
.text-info { color: var(--accent-blue); }

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(74, 158, 255, 0.15);
  color: var(--accent-blue);
}

.divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 0;
}

.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 12px;
}

.empty-state .empty-icon {
  font-size: 24px;
  margin-bottom: 8px;
  opacity: 0.4;
}

.btn-group {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

/* Destination cities display */
.dest-cities {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Capacity input unit toggle */
.input-with-unit {
  display: flex;
  gap: 0;
}

.input-with-unit .form-control {
  border-radius: 4px 0 0 4px;
  flex: 1;
}

.unit-toggle {
  display: flex;
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 4px 4px 0;
  overflow: hidden;
}

.unit-btn {
  padding: 0 10px;
  background: #0a1628;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: all 0.15s;
  border-left: 1px solid var(--border-color);
}

.unit-btn:first-child {
  border-left: none;
}

.unit-btn.active {
  background: var(--accent-blue);
  color: #000;
  font-weight: 600;
}

/* ============ INPUT PAIR (city OR region) ============ */

.input-pair {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.input-pair .form-control {
  flex: 1;
  min-width: 0;
}

.input-pair-or {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cities-preview {
  min-height: 18px;
  padding: 2px 0 0;
}

.cities-preview .badge {
  margin: 2px;
}

.form-group-pair {
  margin-bottom: 8px;
}

.form-group-pair label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  font-weight: 500;
}

/* Constellation info param display */
.info-param {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.info-param .text-muted {
  color: var(--text-muted);
}

.info-param .highlight {
  color: var(--accent-blue);
  font-weight: 600;
}

/* Constellation parameter bar */
#constellation-params {
  background: #1A0A2E;
  border-top: 1px solid #3a1a6a;
  border-bottom: 1px solid #3a1a6a;
  padding: 8px 12px;
  font-size: 11px;
}
#constellation-params .param-input {
  background: #251540;
  border-color: #3a1a6a;
}

#orbit-slider-container {
  background: #0e1525;
  border-bottom: 1px solid var(--border-color);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

/* Constellation parameter inputs */
.param-input {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 11px;
  font-family: inherit;
}
.param-input:focus {
  border-color: var(--accent-blue);
  outline: none;
}

/* Orbit slider */
#orbit-slider {
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-color);
  border-radius: 2px;
}
#orbit-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
}
#orbit-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
