/**
 * Estilos Principales - Simulador de Impacto de Asteroides
 * fijate.com/tools/simulador-asteroides/ - Layout Estándar 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, 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-orange: #ff8507;
  --accent-red: #ef4444;
  --accent-gold: #f59e0b;
  --accent-yellow: #eab308;
  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;

  --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) - Estándar Fijate
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  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-orange);
  background: rgba(255, 133, 7, 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(255, 133, 7, 0.25), rgba(239, 68, 68, 0.3));
  border: 1px solid rgba(255, 133, 7, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-orange);
}

.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: var(--radius-full);
  background: rgba(255, 133, 7, 0.15);
  color: #ff8507;
  border: 1px solid rgba(255, 133, 7, 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-orange);
  background: rgba(255, 133, 7, 0.08);
}

/* ============================================================
   LAYOUT PRINCIPAL Y SIDEBAR (1720px Max-Width)
   ============================================================ */
.asteroid-app-layout,
.fijate-footer-container {
  max-width: 1720px !important;
  width: 100%;
}

.asteroid-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;
}

/* ============================================================
   PRESETS HISTÓRICOS Y FAMOSOS
   ============================================================ */
.presets-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.presets-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.presets-chips-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 4px;
}

.btn-preset-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-preset-chip:hover {
  color: var(--text-primary);
  border-color: var(--accent-orange);
  background: rgba(255, 133, 7, 0.08);
}

.btn-preset-chip.active {
  background: var(--accent-orange);
  color: #0b0f17 !important;
  font-weight: 700;
  border-color: var(--accent-orange);
}

/* ============================================================
   PANEL INTERACTIVO: CONTROLES Y MAPA
   ============================================================ */
.asteroid-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;
}

.asteroid-card-header {
  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;
}

.target-location-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.target-loc-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

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

/* Grid de controles del asteroide */
.asteroid-controls-grid {
  padding: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--border-color);
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field-val-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-orange);
}

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

.select-control {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

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

/* Botón de impacto */
.launch-action-bar {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-color);
}

.btn-launch-impact {
  background: linear-gradient(135deg, #ff8507 0%, #ef4444 100%);
  color: #0b0f17 !important;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 16px rgba(255, 133, 7, 0.35);
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-launch-impact:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 133, 7, 0.5);
}

/* Contenedor del Mapa */
.asteroid-map-wrapper {
  position: relative;
  width: 100%;
  height: 520px;
  background: #090d16;
}

@media (min-width: 992px) {
  .asteroid-map-wrapper {
    height: 580px;
  }
}

@media (min-width: 1400px) {
  .asteroid-map-wrapper {
    height: 640px;
  }
}

/* ============================================================
   ESTILOS ADICIONALES PARA RELIEVE 3D (MAPLIBRE GL JS)
   ============================================================ */
.impact-custom-marker-3d {
  width: 32px;
  height: 32px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.impact-marker-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.45);
  animation: impact-pulse-ring 1.5s infinite;
}

.impact-marker-reticle {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 8px #ef4444);
}

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

/* ============================================================
   ESTILOS DE ANIMACIÓN DE IMPACTO, FLASH Y ONDA DE CHOQUE 3D
   ============================================================ */
.asteroid-map-wrapper.earthquake-shake {
  animation: seismic-shake 0.85s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes seismic-shake {
  10%, 90% { transform: translate3d(-3px, 1px, 0); }
  20%, 80% { transform: translate3d(4px, -3px, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 4px, 0); }
  40%, 60% { transform: translate3d(6px, -4px, 0); }
}

.thermal-flash-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.95) 0%, rgba(255, 133, 7, 0.8) 40%, rgba(239, 68, 68, 0.4) 70%, transparent 100%);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
}

.thermal-flash-overlay.active {
  animation: flash-fadeout 1.4s forwards;
}

@keyframes flash-fadeout {
  0% { opacity: 0.95; }
  20% { opacity: 0.8; }
  100% { opacity: 0; }
}

.impact-explosion-marker {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.fireball-core-flash {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #fbbf24 40%, #ff8507 70%, transparent 100%);
  box-shadow: 0 0 40px #fbbf24, 0 0 80px #ef4444;
  animation: fireball-grow 1.8s ease-out forwards;
}

.supersonic-blast-ring {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 25px rgba(255, 133, 7, 0.85), inset 0 0 15px rgba(255, 255, 255, 0.6);
  animation: shockwave-expand 2.2s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

.supersonic-blast-ring.second {
  animation-delay: 0.3s;
  border-color: rgba(239, 68, 68, 0.85);
}

@keyframes fireball-grow {
  0% { transform: scale(0.2); opacity: 1; }
  35% { transform: scale(3.2); opacity: 0.95; }
  100% { transform: scale(5.5); opacity: 0; }
}

@keyframes shockwave-expand {
  0% { transform: scale(0.1); opacity: 1; }
  50% { transform: scale(8.5); opacity: 0.8; }
  100% { transform: scale(16); opacity: 0; }
}

/* Tooltip emergente de zonas de daño */
.impact-map-tooltip {
  background: rgba(15, 23, 42, 0.92) !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: var(--radius-md) !important;
  padding: 8px 12px !important;
  font-size: 11.5px !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6) !important;
}


.map-style-pill {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.map-style-pill:focus {
  border-color: var(--accent-orange);
}

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


/* Animaciones y crosshair de impacto */
.target-crosshair-icon {
  pointer-events: none;
}

.crosshair-wrapper {
  width: 36px;
  height: 36px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crosshair-ring {
  width: 28px;
  height: 28px;
  border: 2px solid #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
  animation: targetPulse 2s infinite ease-in-out;
}

.crosshair-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 50%;
}

@keyframes targetPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
}

.shockwave-anim-layer {
  pointer-events: none;
}

.shockwave-pulse {
  width: 100px;
  height: 100px;
  border: 4px solid #f59e0b;
  border-radius: 50%;
  animation: shockwaveExpand 1.5s ease-out forwards;
  opacity: 0.9;
}

@keyframes shockwaveExpand {
  0% { transform: scale(0.1); opacity: 1; }
  100% { transform: scale(8); opacity: 0; }
}

/* ============================================================
   INFORME CIENTÍFICO DE DAÑOS Y TELEMETRÍA
   ============================================================ */
.report-metrics-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-color);
}

@media (max-width: 900px) {
  .report-metrics-section {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 500px) {
  .report-metrics-section {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.metric-val.highlight-energy {
  color: #f59e0b;
}

.metric-val.highlight-crater {
  color: #38bdf8;
}

.metric-val.highlight-blast {
  color: #ef4444;
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Sección de cálculo a tu distancia */
.distance-calculator-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.distance-calculator-box h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.dist-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.dist-input-field {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  width: 120px;
}

.dist-effect-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.dist-metric-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.dist-metric-row span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.dist-metric-row strong {
  color: var(--text-primary);
}

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

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

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

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

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

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

/* ============================================================
   SIDEBAR CORPORATIVO (300x600 AdSense + Tarjeta Didáctica)
   ============================================================ */
.sidebar-asteroid-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-asteroid-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

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

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

/* ============================================================
   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-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-location-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-location-item:hover {
  border-color: var(--accent-orange);
  background: rgba(255, 133, 7, 0.08);
}
