/**
 * Estilos Principales - Rastreador 3D de la ISS y Satélites
 * fijate.com/tools/rastreador-iss/ - Layout Estándar de Fijate Tools
 */

:root {
  color-scheme: dark;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

  --bg-main: #0b0f17;
  --bg-surface: #111827;
  --bg-card: #182234;
  --bg-card-hover: #1f2d42;
  --bg-card-dark: #0f172a;
  --bg-input: #0f172a;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #ff8507;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #38bdf8;
  --accent-blue: #0284c7;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #ff8507;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-card-dark: #ffffff;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #ff8507;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* ============================================================
   CABECERA PRINCIPAL (.app-header)
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  height: 64px;
}

[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.85);
}

.header-container {
  max-width: 1720px !important;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-back-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.2s ease;
}

.btn-back-tools:hover {
  color: var(--text-primary);
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-logo-box {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(2, 132, 199, 0.3));
  border: 1px solid rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

/* Layout General de la Aplicación con Sidebar - Anchura Ampliada en Desktop */
.iss-app-layout,
.fijate-footer-container {
  max-width: 1720px !important;
  width: 100%;
}

.iss-app-layout {
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

@media (min-width: 1500px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr 320px;
    gap: 2.5rem;
  }
}

@media (max-width: 1239px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr;
  }
}

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

/* ==========================================================================
   TARJETA PRINCIPAL DEL VISOR 3D Y CONTROLES
   ========================================================================== */
.iss-main-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

.iss-card-header-bar {
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.iss-selector-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.select-satellite {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
}

.select-satellite:focus, .select-satellite:hover {
  border-color: var(--accent-cyan);
}

.btn-header-action {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-header-action:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--accent-cyan);
}

/* Contenedor del Lienzo WebGL 3D */
.iss-viewport-wrapper {
  position: relative;
  width: 100%;
  height: 520px;
  background: var(--bg-space);
  overflow: hidden;
}

@media (min-width: 992px) {
  .iss-viewport-wrapper {
    height: 600px;
  }
}

@media (min-width: 1400px) {
  .iss-viewport-wrapper {
    height: 680px;
  }
}

#globe-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

/* Controles Flotantes sobre el Lienzo 3D */
.iss-floating-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-width: 95%;
  flex-wrap: wrap;
  justify-content: center;
}

.control-pill-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px;
  border-radius: var(--radius-full);
}

.btn-pill {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  font-family: inherit;
}

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

.btn-pill.active {
  background: var(--accent-cyan);
  color: #030712;
  font-weight: 700;
}

.btn-speed {
  padding: 4px 8px;
  font-size: 0.78rem;
}

/* ==========================================================================
   PANEL DE TELEMETRÍA Y OBSERVADOR INFERIOR
   ========================================================================== */
.iss-telemetry-strip {
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .iss-telemetry-strip {
    grid-template-columns: 1fr;
  }
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

@media (max-width: 640px) {
  .telemetry-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.tel-cell {
  background: var(--bg-card);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.tel-lbl {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.tel-val {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.sun-status-box {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.dot-day {
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.dot-night {
  background: #3b82f6;
  box-shadow: 0 0 8px #3b82f6;
}

/* Tarjeta del observador / Avistamientos */
.observer-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
}

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

.obs-city {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.obs-actions {
  display: flex;
  gap: 6px;
}

.btn-small-link {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 4px;
}

.btn-small-link:hover {
  text-decoration: underline;
}

.next-pass-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  gap: 6px;
}

.pass-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.badge-excelente {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.badge-buena {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
}

.badge-normal, .badge-baja {
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
}

/* Barra de botones de acción complementaria */
.iss-action-bar {
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-iss-action {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-iss-action:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.btn-iss-action.btn-iss-primary {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(2, 132, 199, 0.3));
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* ==========================================================================
   WIDGET LATERAL DE TELEMETRÍA (SIDEBAR)
   ========================================================================== */
.sidebar-iss-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-iss-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-iss-facts {
  list-style: none;
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-iss-facts li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ==========================================================================
   SECCIONES EDUCATIVAS Y FAQ INFERIOR
   ========================================================================== */
.iss-guide-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .iss-guide-section {
    grid-template-columns: 1fr;
  }
}

.iss-guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.iss-guide-card h2,
.iss-guide-card h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.iss-guide-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.iss-guide-card ul {
  padding-left: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ==========================================================================
   MODALES (ESTRUCTURA ESTÁNDAR FIJATE)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

.modal-dialog {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  width: 640px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-primary);
}

.modal-dialog.modal-dialog-large {
  width: 820px;
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.btn-primary-action {
  background: var(--accent-cyan);
  color: #030712;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* Radar celeste 2D */
.radar-passes-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
}

@media (max-width: 680px) {
  .radar-passes-container {
    grid-template-columns: 1fr;
  }
}

.sky-radar-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sky-radar-canvas {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: #0a101d;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.2);
}

.passes-cards-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.pass-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pass-card.pass-card-highlight {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

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

.pass-day-label {
  font-size: 0.9rem;
  font-weight: 700;
}

.pass-time-badge {
  font-size: 0.9rem;
  font-family: monospace;
  color: var(--accent-cyan);
}

.pass-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px;
  border-radius: 6px;
  font-size: 0.78rem;
}

.btn-cal-export {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 4px;
}

.btn-cal-export:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

/* Toast */
.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 3000;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s ease;
}

.app-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.live-stream-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #000;
}

.live-stream-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
