/**
 * Stylesheet: Buscador 3D de Cielos Oscuros y Planetario en Directo
 * Fijate Tools - Estilo espacial, glassmorphism, AdSense y botón Fullscreen.
 */

:root {
  --bg-app: #080c14;
  --bg-panel: rgba(13, 19, 33, 0.85);
  --bg-panel-solid: #0d1321;
  --bg-card: rgba(22, 31, 51, 0.7);
  --border-panel: rgba(255, 255, 255, 0.12);
  --border-focus: #ff8507;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-accent: #ff8507;

  --accent-color: #ff8507;
  --accent-hover: #e07400;
  --accent-glow: rgba(255, 133, 7, 0.35);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-panel: 0 10px 30px -5px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-panel: rgba(255, 255, 255, 0.88);
  --bg-panel-solid: #ffffff;
  --bg-card: rgba(241, 245, 249, 0.85);
  --border-panel: rgba(0, 0, 0, 0.1);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow-panel: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Contenedor central estándar Fijate */
.main-wrapper {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 16px 40px 16px;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.tool-main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* Escenario Split (Mapa + Cúpula 3D) */
.stage-split-wrapper {
  position: relative;
  width: 100%;
  height: 580px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #03050a;
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

.stage-split-wrapper.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
  border: none !important;
}

/* Columna Izquierda: Mapa VIIRS */
.map-view-column {
  position: relative;
  height: 100%;
  border-right: 1px solid var(--border-panel);
}

#sky-map-container {
  width: 100%;
  height: 100%;
  background: #050811;
}

/* Columna Derecha: Cúpula 3D Three.js */
.planetarium-view-column {
  position: relative;
  height: 100%;
  background: #03050a;
}

#planetarium-container {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#planetarium-container:active {
  cursor: grabbing;
}

/* Paneles Flotantes HUD */
.floating-hud {
  position: absolute;
  z-index: 500;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: 12px;
}

/* Panel de Calidad de Cielo (Arriba Izquierda) */
.hud-sky-quality {
  top: 12px;
  left: 12px;
  width: 290px;
  max-width: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quality-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bortle-title-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.bortle-number {
  font-size: 18px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
}

.bortle-indicator-pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.bortle-1, .bortle-2 { background: rgba(34, 197, 94, 0.2); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.4); }
.bortle-3, .bortle-4 { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.bortle-5, .bortle-6 { background: rgba(234, 179, 8, 0.2); color: #eab308; border: 1px solid rgba(234, 179, 8, 0.4); }
.bortle-7, .bortle-8, .bortle-9 { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.4); }

.quality-desc {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
  margin: 0;
}

/* Métricas astronómicas */
.astro-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.astro-stat-card {
  background: var(--bg-card);
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-panel);
}

.astro-stat-label {
  font-size: 9.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.astro-stat-value {
  font-size: 12px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
  margin-top: 1px;
}

/* Buscador y Selectores */
.search-controls-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.select-sky-control {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.select-sky-control:focus {
  border-color: var(--accent-color);
}

/* Controles de Tiempo del Planetario (Arriba Derecha) */
.hud-time-controls {
  top: 12px;
  right: 12px;
  width: 290px;
  max-width: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.time-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.time-clock-display {
  font-size: 20px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-color);
}

.btn-time-now {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-time-now:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.time-slider-range {
  width: 100%;
  accent-color: var(--accent-color);
  cursor: pointer;
}

/* Toggles de Capas Celestes */
.celestial-toggles-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--bg-card);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-panel);
  transition: all 0.15s ease;
}

.toggle-chip input { accent-color: var(--accent-color); }
.toggle-chip:hover { color: var(--text-main); }

/* Marcadores Personalizados Leaflet */
.custom-observer-pin {
  width: 24px;
  height: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.observer-pin-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.4);
  animation: pulse-pin 1.8s infinite;
}

.observer-pin-core {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px #38bdf8;
}

.starlight-badge-pin {
  width: 26px;
  height: 26px;
  background: #0f172a;
  border: 1.5px solid #ff8507;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(255, 133, 7, 0.5);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.starlight-badge-pin:hover { transform: scale(1.2); }

@keyframes pulse-pin {
  0% { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* Popups Leaflet */
.leaflet-popup-content-wrapper {
  background: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 10px !important;
}

.leaflet-popup-tip { background: #0f172a !important; }
.starlight-popup-title { margin: 2px 0 4px 0; font-size: 12px; font-weight: 700; color: #f8fafc; }
.starlight-popup-desc { font-size: 10.5px; color: #94a3b8; line-height: 1.4; margin: 0 0 6px 0; }
.btn-goto-reserve { width: 100%; padding: 4px; background: #ff8507; border: none; border-radius: 4px; color: #0b0f17; font-size: 10.5px; font-weight: 700; cursor: pointer; }

/* Sidebar de AdSense y Didáctico */
.sidebar-darksky-card {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 14px;
}

.sidebar-darksky-title {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-color);
}

.sidebar-darksky-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Sección Didáctica y FAQ Inferior */
.tool-info-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-md);
  padding: 16px;
}

.info-card-title {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-accent);
}

.info-card-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Modales Nativos */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.app-modal-backdrop.active { display: flex; }

.app-modal-card {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.app-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-modal-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-main); }
.app-modal-body { padding: 20px; font-size: 13px; line-height: 1.6; color: var(--text-muted); }
.app-modal-footer { padding: 12px 20px; border-top: 1px solid var(--border-panel); display: flex; justify-content: flex-end; }

/* Responsividad */
@media (max-width: 1240px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr;
  }
  .tool-ad-sidebar {
    display: none !important;
  }
}

@media (max-width: 920px) {
  .stage-split-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    height: 640px;
  }
  .map-view-column {
    border-right: none;
    border-bottom: 1px solid var(--border-panel);
  }
  .hud-sky-quality, .hud-time-controls {
    width: auto;
    left: 8px;
    right: 8px;
    top: 8px;
  }
}
