/* ==========================================================================
   Globo terráqueo de vientos y corrientes oceánicas en 3D
   Fijate Tools - Estilos oficiales e inmersivos WebGL
   ========================================================================== */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta base de la herramienta (Midnight Sky & Ocean Cyan) */
  --primary-color: #0284c7;
  --primary-light: #38bdf8;
  --primary-dark: #0369a1;
  --accent-glow: rgba(56, 189, 248, 0.35);

  --bg-app: #070b14;
  --bg-card: #0b1325;
  --bg-card-subtle: #0f1c35;
  --bg-input: #132240;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-accent: #38bdf8;
  --border-color: rgba(56, 189, 248, 0.18);
  --border-focus: #38bdf8;

  --shadow-hud: 0 16px 36px -8px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.15);
}

[data-theme="light"],
body.light-theme {
  --primary-color: #0284c7;
  --primary-light: #0ea5e9;
  --primary-dark: #0369a1;
  --accent-glow: rgba(2, 132, 199, 0.25);

  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-accent: #0284c7;
  --border-color: rgba(2, 132, 199, 0.22);
  --border-focus: #0284c7;

  --shadow-hud: 0 12px 30px -6px rgba(0, 0, 0, 0.2), 0 0 15px rgba(2, 132, 199, 0.12);
}

/* Base de página y tipografía */
body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.strip-section-title,
.hud-location-title,
.modal-title {
  font-family: var(--font-heading);
  letter-spacing: -0.015em;
  font-weight: 700;
}

.mono {
  font-family: var(--font-mono);
}

/* Card principal */
.earth-globe-app-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Barra superior de pestañas de capas */
.layers-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background-color: var(--bg-card-subtle);
  padding: 0.5rem;
  border-radius: 14px;
  border: 1px solid var(--border-color);
}

.btn-layer-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.95rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
  white-space: nowrap;
}

.btn-layer-tab:hover {
  color: var(--text-main);
  background-color: var(--bg-input);
  border-color: var(--border-color);
}

.btn-layer-tab.active {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-light);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.tab-icon {
  font-size: 1rem;
}

/* Contenedor del Visor 3D / 2D */
.globe-viewer-card {
  position: relative;
  width: 100%;
  height: 640px;
  border-radius: 16px;
  overflow: hidden;
  background-color: #070b14;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
}

.globe-viewer-card:fullscreen,
.globe-viewer-card:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0;
  border: none;
}

.globe-viewport-3d,
.flat-map-viewport {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
}

.globe-viewport-3d:active,
.flat-map-viewport:active {
  cursor: grabbing;
}

#flat-map-canvas {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

/* Barra de herramientas superior flotante */
.viewer-top-toolbar {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.view-mode-toggle,
.viewer-action-buttons {
  display: inline-flex;
  gap: 0.4rem;
  background: rgba(11, 19, 37, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  pointer-events: auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.btn-toggle-view,
.btn-viewer-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 38px;
}

.btn-toggle-view:hover,
.btn-viewer-action:hover {
  color: var(--text-main);
  background: var(--bg-card-subtle);
}

.btn-toggle-view.active,
.btn-viewer-action.active {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-light);
}

.btn-action-info {
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--primary-light);
}

/* Panel HUD de Telemetría Flotante */
.hud-telemetry-panel {
  position: absolute;
  bottom: 3.8rem;
  left: 1rem;
  width: 320px;
  max-width: calc(100% - 2rem);
  background: rgba(11, 19, 37, 0.84);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  z-index: 10;
  box-shadow: var(--shadow-hud);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.25s ease;
}

.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.5rem;
}

.hud-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-light);
  font-weight: 700;
}

.hud-location-title {
  font-size: 0.98rem;
  margin: 0.15rem 0 0.1rem;
  color: var(--text-main);
  line-height: 1.25;
}

.hud-coords {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.telemetry-badge {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-analytic {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-live {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.badge-loading {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

/* Métricas en cuadrícula */
.hud-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.hud-metric-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.metric-val-main {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.metric-number {
  font-size: 1.6rem;
  font-weight: 800;
  color: #38bdf8;
  line-height: 1;
}

.metric-unit {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.metric-conversions {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  white-space: nowrap;
}

/* Widget de Rosa Náutica */
.compass-widget {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.2rem;
}

.compass-dial {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(56, 189, 248, 0.4);
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.compass-needle {
  position: absolute;
  width: 4px;
  height: 34px;
  background: linear-gradient(to bottom, #ef4444 50%, #38bdf8 50%);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
  transform-origin: center center;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.compass-mark {
  position: absolute;
  font-size: 0.52rem;
  font-weight: 800;
  color: var(--text-muted);
}

.mark-n { top: 1px; color: #ef4444; }
.mark-e { right: 2px; }
.mark-s { bottom: 1px; }
.mark-o { left: 2px; }

.compass-info {
  display: flex;
  flex-direction: column;
}

.compass-heading {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.compass-degree {
  font-size: 0.72rem;
  color: #38bdf8;
}

/* Submétricas */
.hud-submetrics-row {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.submetric-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: #facc15;
  margin: 0.1rem 0;
}

.submetric-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.25;
}

.hud-data-tags-row {
  display: flex;
  gap: 0.5rem;
}

.data-tag {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tag-lbl {
  color: var(--text-muted);
  font-size: 0.64rem;
}

.tag-val {
  color: var(--text-main);
  font-weight: 700;
}

/* Botón de sincronización satélite en directo */
.hud-actions-footer {
  margin-top: 0.2rem;
}

.btn-sync-telemetry {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--primary-light);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.btn-sync-telemetry:hover:not(:disabled) {
  background: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-light);
}

.btn-sync-telemetry:disabled {
  opacity: 0.6;
  cursor: wait;
}

.sync-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Leyenda cromática sobrepuesta */
.viewer-bottom-overlay {
  position: absolute;
  bottom: 0.8rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  z-index: 9;
}

.legend-bar-wrapper {
  background: rgba(11, 19, 37, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  pointer-events: auto;
  width: 280px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.legend-title {
  color: var(--text-main);
  font-weight: 600;
}

.legend-color-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #38bdf8, #22c55e, #a3e635, #facc15, #fb923c, #f43f5e, #c084fc, #ffffff);
}

/* Descripción de la capa */
.layer-description-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.layer-desc-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.layer-desc-text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.45;
}

/* Enclaves geográficos en carrusel */
.locations-strip-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.strip-section-title {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0;
  font-weight: 600;
}

.locations-chip-carousel {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
}

.location-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.55rem 0.9rem;
  border-radius: 24px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  min-height: 40px;
}

.location-chip:hover {
  color: var(--text-main);
  background: var(--bg-input);
  border-color: var(--primary-light);
}

.location-chip.active {
  background: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-light);
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* Controles de partículas en cuadrícula */
.simulation-controls-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.control-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.app-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 42px;
  min-height: 40px;
  padding: 0 2.2rem 0 0.85rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.85rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.app-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.app-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

/* Sección científica divulgativa */
.educational-science-section {
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
}

.educational-science-section .section-title {
  font-size: 1.25rem;
  margin: 0 0 1rem;
  color: var(--text-main);
}

.science-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.science-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.1rem;
}

.science-card-title {
  font-size: 0.95rem;
  color: var(--primary-light);
  margin: 0 0 0.5rem;
}

.science-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Modal Canónico Accesible (sin alert) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  color: var(--text-main);
}

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

.modal-title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-main);
}

.btn-modal-close {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  min-height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-modal-close:hover {
  color: var(--text-main);
  background: var(--bg-input);
}

.modal-body h4 {
  font-size: 1rem;
  color: var(--primary-light);
  margin: 1.1rem 0 0.5rem;
}

.modal-body ul {
  padding-left: 1.25rem;
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.modal-body li {
  margin-bottom: 0.4rem;
}

.modal-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.modal-table th,
.modal-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.modal-table th {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  font-weight: 700;
}

.modal-table td {
  color: var(--text-muted);
}

.modal-footer {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--primary-color);
  color: #ffffff;
  border: 1px solid var(--primary-light);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

/* ==========================================================================
   Adaptación Responsiva Móvil y Tablet
   ========================================================================== */
@media (max-width: 1024px) {
  .science-cards-grid {
    grid-template-columns: 1fr;
  }

  .simulation-controls-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .globe-viewer-card {
    height: 520px;
  }

  .hud-telemetry-panel {
    bottom: 3.5rem;
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    max-width: none;
    padding: 0.8rem;
  }

  .viewer-bottom-overlay {
    bottom: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    justify-content: center;
  }

  .legend-bar-wrapper {
    width: 100%;
  }

  .btn-layer-tab {
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .globe-viewer-card {
    height: 460px;
  }

  .hud-metrics-grid {
    grid-template-columns: 1fr;
  }

  .btn-layer-tab {
    flex: 1 1 100%;
  }
}
