/* ==========================================================================
   SISTEMA DE DISEÑO - EL SONIDO DE LA FELICIDAD (DARK MODE PREMIUM)
   ========================================================================== */

:root {
  --bg-color: #0b0f19; /* Azul oscuro profundo de fondo */
  --bg-panel: rgba(18, 26, 47, 0.65); /* Panel translúcido */
  --border-color: rgba(226, 232, 240, 0.08);
  
  --text-main: #f8fafc; /* Blanco pizarra */
  --text-muted: #94a3b8; /* Gris pizarra */
  
  /* Colores de Marca y Acentos */
  --color-spotify: #1db954; /* Verde Oficial */
  --color-spotify-glow: rgba(29, 185, 84, 0.15);
  
  --color-cyan: #06b6d4; /* Cian oficial de adrianjaen.org */
  --color-cyan-glow: rgba(6, 182, 212, 0.15);
  
  --color-orange: #ff6b35; /* Coral / Naranja */
  --color-orange-glow: rgba(255, 107, 53, 0.15);
  
  --font-family: 'Outfit', sans-serif;
  --font-title: 'Montserrat', sans-serif;
  
  --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 24px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 20px 60px rgba(6, 182, 212, 0.06);
}

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

body {
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(29, 185, 84, 0.04) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(255, 107, 53, 0.02) 0px, transparent 50%);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   CABECERA PREMIUM
   ========================================================================== */

header {
  padding: 1.5rem 4%;
  background: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.back-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-title);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--color-spotify);
  text-transform: uppercase;
  margin-bottom: 6px;
  transition: var(--transition);
  cursor: pointer;
}

.back-link:hover {
  opacity: 0.8;
  transform: translateX(-2px);
}

.brand-sub {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.8px;
  color: var(--color-spotify);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.brand-sub .separator {
  font-weight: 300;
  color: var(--text-muted);
  margin: 0 4px;
}

.brand-title {
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 1.6rem;
  letter-spacing: -0.5px;
  color: var(--text-main);
  margin-bottom: 2px;
}

.brand-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

.text-green { color: var(--color-spotify); }
.text-cyan { color: var(--color-cyan); }
.text-orange { color: var(--color-orange); }

.badge-platform {
  background: rgba(29, 185, 84, 0.08);
  border: 1px solid rgba(29, 185, 84, 0.15);
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--color-spotify);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-platform::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--color-spotify);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-spotify-glow);
  animation: pulse-rhythmic 3s infinite ease-in-out;
}

/* ==========================================================================
   ESTRUCTURA DEL DASHBOARD
   ========================================================================== */

.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 4%;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
}

@media (max-width: 1200px) {
  .dashboard-container {
    grid-template-columns: 1fr;
    max-width: 800px;
  }
}

/* Paneles Colectivos (Estilo Glassmorphism Oscuro) */
.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
  margin-bottom: 2rem;
}

.panel:hover {
  border-color: rgba(6, 182, 212, 0.15);
  box-shadow: var(--shadow-hover);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 0.75rem;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-title);
  color: var(--text-main);
  border-left: 4px solid var(--color-spotify);
  padding-left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-title.text-orange {
  border-color: var(--color-orange);
}

.panel-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

/* ==========================================================================
   ELEMENTOS DE CONTROL Y FILTROS
   ========================================================================== */

.map-controls {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.filter-btn {
  background: transparent;
  border: none;
  outline: none;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn.active {
  background: var(--color-spotify);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(29, 185, 84, 0.2);
}

/* ==========================================================================
   MAPA Y ENTORNO GEOGRÁFICO
   ========================================================================== */

.map-wrapper {
  position: relative;
  width: 100%;
}

#map {
  height: 460px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: #090c13 !important; /* Fondo del mapa */
  z-index: 1;
}

/* Estilos de Leaflet para integrarse al Modo Oscuro */
.leaflet-tile {
  /* CartoDB Dark Matter es nativamente oscuro y hermoso, no requiere inversión */
  filter: none !important;
}

.leaflet-container {
  background: #090c13 !important;
}

/* Marcadores Rítmicos en el Mapa */
.rhythmic-pulse-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  transition: var(--transition);
  cursor: pointer;
  transform-origin: center;
}

.rhythmic-pulse-marker.active-rhythmic-marker {
  width: 16px;
  height: 16px;
  border-color: var(--color-spotify);
  box-shadow: 0 0 16px var(--color-spotify);
  animation: pulse-rhythmic 2s infinite ease-in-out;
}


.leaflet-popup-content-wrapper {
  background: rgba(11, 15, 25, 0.95) !important;
  backdrop-filter: blur(10px);
  color: var(--text-main) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 16px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-popup-tip {
  background: rgba(11, 15, 25, 0.95) !important;
}

.custom-popup h3 {
  font-size: 0.9rem;
  font-weight: 800;
  font-family: var(--font-title);
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
  color: var(--text-main);
}

.custom-popup p {
  font-size: 0.75rem;
  margin: 3px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* ==========================================================================
   VISUALIZACIÓN DE GRÁFICOS
   ========================================================================== */

.chart-container {
  position: relative;
  width: 100%;
  height: 290px;
}

/* ==========================================================================
   TARJETA DETALLE DE PAÍS (HIGHLIGHT PANEL)
   ========================================================================== */

.highlight-panel {
  border-left: 4px solid var(--color-spotify);
}

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

.country-flag-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.large-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.country-title {
  font-size: 1.4rem;
  font-weight: 900;
  font-family: var(--font-title);
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1.2;
}

.country-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.valence-score-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(29, 185, 84, 0.06);
  border: 1px solid rgba(29, 185, 84, 0.12);
  padding: 6px 14px;
  border-radius: 16px;
}

.badge-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-value {
  font-size: 1.3rem;
  font-weight: 850;
  font-family: var(--font-title);
}

/* Comparación de Bloques */
.metrics-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-mini-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.block-onu { border-left: 3px solid var(--color-cyan); }
.block-spotify { border-left: 3px solid var(--color-spotify); }

.mini-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mini-value-container {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 4px 0;
}

.mini-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-title);
  line-height: 1;
}

.mini-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.mini-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Barras de Atributos de Audio */
.audio-features-box {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
}

.box-subtitle {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.feature-bar-group {
  margin-bottom: 12px;
}

.feature-bar-group:last-child {
  margin-bottom: 0;
}

.feature-bar-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.fill-green { background-color: var(--color-spotify); }
.fill-cyan { background-color: var(--color-cyan); }
.fill-orange { background-color: var(--color-orange); }

/* ==========================================================================
   LISTA DE CANCIONES (ECO DE ECO)
   ========================================================================== */

.track-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.track-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.track-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(29, 185, 84, 0.2);
}

.track-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.track-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 16px;
  text-align: center;
}

.track-details {
  display: flex;
  flex-direction: column;
}

.track-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.track-artist {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Ecualizador CSS Rítmico y Suave (Acentos ritmicos, no parpadeos) */
.equalizer-wave {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 14px;
  height: 12px;
}

.eq-bar {
  width: 2px;
  background-color: var(--color-spotify);
  border-radius: 1px;
  animation: eq-bounce 1.5s ease-in-out infinite alternate;
}

.eq-bar:nth-child(1) { height: 10%; animation-delay: 0.1s; }
.eq-bar:nth-child(2) { height: 30%; animation-delay: 0.4s; }
.eq-bar:nth-child(3) { height: 20%; animation-delay: 0.2s; }
.eq-bar:nth-child(4) { height: 40%; animation-delay: 0.6s; }

@keyframes eq-bounce {
  0% { height: 10%; }
  100% { height: 100%; }
}

.track-valence {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.track-valence-val {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-spotify);
}

.track-valence-lbl {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ==========================================================================
   PANEL DEL VEREDICTO ACTUARIAL
   ========================================================================== */

.verdict-panel {
  border-left: 4px solid var(--color-orange);
}

.verdict-summary {
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 12px;
  text-align: justify;
}

.verdict-alert {
  background: rgba(255, 107, 53, 0.05);
  border: 1px solid rgba(255, 107, 53, 0.15);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: #ff8c5a;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.verdict-alert i {
  margin-top: 2px;
  font-size: 0.85rem;
}

/* ==========================================================================
   PANEL DE CONEXIÓN CON SPOTIFY API
   ========================================================================== */

.connection-panel {
  border-left: 4px solid var(--color-spotify);
}

.spotify-pulse-icon {
  font-size: 1.5rem;
  color: var(--color-spotify);
  animation: slow-pulse 3s infinite ease-in-out;
}

@keyframes slow-pulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(29,185,84,0)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 8px var(--color-spotify-glow)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(29,185,84,0)); }
}

.sync-input-group {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.sync-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 0.78rem;
  outline: none;
  transition: var(--transition);
}

.sync-input:focus {
  border-color: var(--color-spotify);
}

.sync-btn {
  background: var(--color-spotify);
  border: none;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sync-btn:hover {
  background: #1ed760;
  box-shadow: 0 4px 15px rgba(29, 185, 84, 0.3);
}

/* ==========================================================================
   NOTA METODOLÓGICA Y FUENTES (SECCIÓN INFERIOR)
   ========================================================================== */

.methodology-container {
  max-width: 1200px;
  margin: 0 auto 3rem auto;
  padding: 0 4%;
}

.methodology-title {
  font-family: var(--font-title);
  font-weight: 850;
  font-size: 1.2rem;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  border-left: 4px solid var(--color-orange);
  padding-left: 12px;
}

.methodology-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.methodology-sub {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.methodology-text {
  margin-bottom: 10px;
  text-align: justify;
}

.methodology-text:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   PIE DE PÁGINA
   ========================================================================== */

footer {
  text-align: center;
  padding: 3rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  margin-top: 4rem;
}

footer a {
  color: var(--color-cyan);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

footer a:hover {
  color: var(--color-spotify);
}

/* ==========================================================================
   PULSAR ANIMATIONS (RITMICOS, NO PARPADEOS)
   ========================================================================== */

@keyframes pulse-rhythmic {
  0% { box-shadow: 0 0 0 0 rgba(29, 185, 84, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(29, 185, 84, 0); }
  100% { box-shadow: 0 0 0 0 rgba(29, 185, 84, 0); }
}

/* ==========================================================================
   MEDIA QUERIES - MÓVIL Y ADAPTABILIDAD ESTRICTA
   ========================================================================== */

@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 1rem 4%;
    width: 100% !important;
    left: 0;
    right: 0;
  }
  
  .badge-platform {
    align-self: flex-start;
    font-size: 0.65rem;
    padding: 4px 10px;
  }
  
  .brand-title {
    font-size: 1.15rem !important;
    line-height: 1.3 !important;
  }
  
  .brand-desc {
    font-size: 0.75rem !important;
    line-height: 1.4 !important;
  }
  
  .mobile-experience-banner {
    display: flex;
    background: rgba(6, 182, 212, 0.05);
    border-bottom: 1px solid rgba(6, 182, 212, 0.15);
    padding: 10px 4%;
    font-size: 0.72rem;
    color: var(--color-cyan);
    font-weight: 600;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
  }
  
  .dashboard-container {
    padding: 1rem 4%;
    gap: 1.5rem;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden;
  }
  
  .panel {
    padding: 1.25rem;
    max-width: 100% !important;
    overflow-x: hidden;
    margin-bottom: 1rem;
  }
  
  .panel-title {
    font-size: 0.95rem !important;
    margin-bottom: 0.8rem;
  }
  
  #map {
    height: 320px; /* Reducir altura del mapa en móvil */
  }
  
  .metrics-comparison-grid {
    grid-template-columns: 1fr; /* Una columna en mini-tarjetas */
    gap: 0.75rem;
  }
  
  .methodology-grid {
    grid-template-columns: 1fr; /* Colapsar a una columna en móvil */
    gap: 1.5rem;
  }
  
  .map-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .filter-btn {
    padding: 6px 8px;
    font-size: 0.7rem;
    flex: 1;
    text-align: center;
  }
}
