@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;700&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
  --bg-color: #020208;
  --panel-bg: rgba(8, 8, 20, 0.65);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f2f5;
  --text-secondary: #9ea7b4;
  --accent-cyan: #00f0ff;
  --accent-blue: #3b82f6;
  --accent-gold: #fbbf24;
  --accent-purple: #a855f7;
  --glow-cyan: 0 0 15px rgba(0, 240, 255, 0.3);
  --shadow-panel: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --font-title: 'Space Grotesk', sans-serif;
  --font-body: 'Outfit', sans-serif;
}

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

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

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Loading overlay */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease-out;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(0, 240, 255, 0.1);
  border-left-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
  box-shadow: var(--glow-cyan);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#loading-text {
  font-family: var(--font-title);
  font-size: 1.2rem;
  letter-spacing: 2px;
  color: var(--accent-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

/* UI overlay */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: grid;
  grid-template-columns: 350px 1fr 380px;
  grid-template-rows: auto 1fr;
  padding: 20px;
  gap: 20px;
}

/* Active interactive elements must re-enable pointer-events */
.interactive {
  pointer-events: auto;
}

/* Glassmorphism Panel styles */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow-panel);
  padding: 20px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel::-webkit-scrollbar {
  width: 6px;
}
.glass-panel::-webkit-scrollbar-track {
  background: transparent;
}
.glass-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.glass-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Left panel: Controls & Constellations */
#left-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.app-header {
  margin-bottom: 20px;
}

.app-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.8rem;
  background: linear-gradient(135deg, #fff 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 4px;
}

.search-box {
  position: relative;
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 40px 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

/* Control section styles */
.section-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.15);
  padding-bottom: 6px;
}

.control-group {
  margin-bottom: 20px;
}

/* Toggle tabs */
.view-mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  margin-bottom: 15px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 8px 4px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.tab-btn.active {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Switch toggles */
.switch-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.switch-label {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 34px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider-round {
  background-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

input:checked + .slider-round:before {
  transform: translateX(22px);
  background-color: #000;
}

/* Sliders */
.slider-control {
  margin-bottom: 14px;
}

.slider-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  transition: background 0.3s;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: var(--glow-cyan);
  transition: transform 0.1s;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Constellation list */
.constellation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.const-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.const-item:hover {
  background: rgba(0, 240, 255, 0.06);
  border-color: rgba(0, 240, 255, 0.2);
  transform: translateX(4px);
}

.const-item.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

.const-item-code {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-title);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Floating middle buttons (auto tour, reset) */
#top-controls {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  justify-content: center;
  gap: 12px;
  align-self: start;
}

.glass-btn {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-panel);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s;
}

.glass-btn:hover {
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
  transform: translateY(-2px);
  color: var(--accent-cyan);
}

.glass-btn:active {
  transform: translateY(0);
}

.glass-btn.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

/* Right panel: Star details / Constellation Info */
#right-panel {
  grid-column: 3;
  grid-row: 1 / span 2;
  transform: translateX(410px); /* Hidden by default */
  opacity: 0;
}

#right-panel.open {
  transform: translateX(0);
  opacity: 1;
}

.close-panel-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  transition: color 0.3s;
}

.close-panel-btn:hover {
  color: #ef4444;
}

.detail-header {
  margin-top: 10px;
  margin-bottom: 20px;
}

.detail-title {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
}

.detail-subtitle {
  color: var(--accent-cyan);
  font-size: 0.85rem;
  letter-spacing: 1px;
  margin-top: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.detail-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 12px;
  border-radius: 10px;
}

.card-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.card-value {
  font-size: 1rem;
  font-weight: 600;
}

/* Star color ball */
.spectral-ball {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 8px;
  box-shadow: 0 0 10px currentColor;
}

.star-list-inline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.star-list-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.01);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.star-list-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-cyan);
}

/* Compass HUD at the bottom */
#hud-overlay {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  justify-self: center;
  margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  gap: 20px;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-val {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Highlight constellation overlay */
#constellation-title-overlay {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.4), 0 4px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.5s ease;
  text-align: center;
}

#constellation-title-overlay.show {
  opacity: 1;
}

.const-sub-overlay {
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--accent-cyan);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Mobile responsive fixes */
@media (max-width: 900px) {
  .ui-layer {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    padding: 10px;
    overflow-y: auto;
    height: 100vh;
  }
  
  #left-panel {
    grid-column: 1;
    grid-row: 1;
    max-height: 400px;
  }
  
  #right-panel {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    transform: none;
    max-height: 400px;
    opacity: 1;
    display: none;
  }
  
  #right-panel.open {
    display: flex;
  }
  
  #top-controls {
    grid-column: 1;
    grid-row: 3;
    justify-content: center;
  }
  
  #hud-overlay {
    display: none;
  }
}

/* Planet and Exoplanet Labels */
.planet-label {
  position: absolute;
  color: var(--accent-gold);
  font-family: var(--font-title);
  font-size: 0.75rem;
  font-weight: 700;
  pointer-events: none;
  transform: translate(12px, -50%);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(251, 191, 36, 0.4);
  white-space: nowrap;
  z-index: 4;
}

.exoplanet-label {
  position: absolute;
  color: #10b981; /* Emerald Green */
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  pointer-events: none;
  transform: translate(12px, -50%);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(16, 185, 129, 0.4);
  white-space: nowrap;
  z-index: 4;
}

/* Planet list under star details */
.planet-tag {
  display: inline-block;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
}

/* Wavelength View Mode Tabs Selector styling */
.wavelength-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  margin-top: 8px;
  margin-bottom: 15px;
}

.wavelength-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 8px 2px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

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

.wavelength-btn.active {
  background: var(--accent-cyan);
  color: #010103;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(1, 1, 3, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Modal Content (Glassmorphism) */
.modal-content {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(0, 240, 255, 0.2);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 240, 255, 0.1);
  border-radius: 16px;
  width: 520px;
  max-width: 90%;
  padding: 24px;
  color: var(--text-primary);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.open .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.modal-title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
  padding: 0 4px;
}

.close-btn:hover {
  color: #ef4444;
}

/* Stats Cards in Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.subsection-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  color: var(--accent-cyan);
  margin-top: 15px;
  margin-bottom: 10px;
  border-bottom: 1px dashed rgba(0, 240, 255, 0.15);
  padding-bottom: 4px;
}

/* Horizontal Progress Bars for charts */
.chart-bar-container {
  margin-bottom: 10px;
}

.chart-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.chart-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease-out;
}
