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

:root {
  --e106-red: #e2231a;
  --e106-red-dark: #b91c14;
  --e106-yellow: #ffcb05;
  --e106-green: #8dc63f;
  --e106-purple: #5b3a8e;
  --e106-text: #2b2b2b;
  --e106-gray: #565f6b;
  --e106-border: #e5e0d8;

  --bg-body-1: #fff9e8;
  --bg-body-2: #fdf5f4;
  --bg-body-3: #f3eefb;
  --bg-card: #ffffff;
  --bg-pill: #fdf8ec;
  --bg-placeholder: #f3eefb;
  --shadow-color: rgba(91, 58, 142, 0.12);
  --error-bg: #fdecea;
  --error-border: #f6c2bd;
  --e106-purple-solid: #5b3a8e;
}

:root[data-theme="dark"] {
  --e106-purple: #b79aec;
  --e106-red: #ff5c50;
  --e106-red-dark: #ff8178;
  --e106-text: #f1eef7;
  --e106-gray: #a8a0b8;
  --e106-border: #3a3350;

  --bg-body-1: #2a2045;
  --bg-body-2: #180f28;
  --bg-body-3: #0b0712;
  --bg-card: #211c2e;
  --bg-pill: #2a2438;
  --bg-placeholder: #2a2438;
  --shadow-color: rgba(0, 0, 0, 0.45);
  --error-bg: rgba(226, 35, 26, 0.15);
  --error-border: rgba(226, 35, 26, 0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(160deg, var(--bg-body-1) 0%, var(--bg-body-2) 45%, var(--bg-body-3) 100%);
  color: var(--e106-text);
  min-height: 100vh;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

/* FONDO DECORATIVO: cassettes, vinilos y notas flotando */
.bg-decor {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.bg-shape {
  position: absolute;
  bottom: -15%;
  opacity: 0;
  animation-name: float-up;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.bg-shape svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes float-up {
  0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  8% { opacity: var(--o, 0.15); }
  50% { transform: translateY(-55vh) translateX(16px) rotate(180deg); opacity: var(--o, 0.15); }
  92% { opacity: var(--o, 0.15); }
  100% { transform: translateY(-115vh) translateX(-12px) rotate(360deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-shape {
    animation: none;
    display: none;
  }
}

.container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  background-color: var(--bg-card);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 20px 45px var(--shadow-color);
  border-top: 6px solid var(--e106-red);
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

@media (min-width: 768px) {
  .container {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

/* LOGO DE LA RADIO */
.station-logo-wrapper {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 1.5rem;
}

/* INFORMACIÓN DE CANCIÓN */
.now-playing-info {
  margin-bottom: 1.5rem;
}

.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--e106-red);
  margin-bottom: 0.85rem;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--e106-red);
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 35, 26, 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(226, 35, 26, 0); }
}

.connection-status {
  color: var(--e106-gray);
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: none;
}

.now-playing-media {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.cover-wrap {
  position: relative;
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 6px 16px var(--theme-accent-glow, rgba(91, 58, 142, 0.18));
  transition: box-shadow 0.6s ease;
}

.cover-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: var(--bg-placeholder);
  border: 2px solid var(--theme-accent, var(--e106-yellow));
  border-radius: 14px;
  transition: border-color 0.6s ease, background-color 0.4s ease;
}

/* Textura estilo VHS/CRT sobre la carátula */
.cover-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.16) 0px,
    rgba(255, 255, 255, 0.16) 1px,
    transparent 2px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  pointer-events: none;
}

.track-details {
  min-width: 0;
}

.text-gray {
  color: var(--e106-gray);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#song-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--e106-purple);
  line-height: 1.25;
  margin-top: 0.35rem;
  animation: neon-pulse 2.4s ease-in-out infinite;
}

@keyframes neon-pulse {
  0%, 100% { text-shadow: 0 0 6px rgba(91, 58, 142, 0.35), 0 0 14px rgba(226, 35, 26, 0.15); }
  50% { text-shadow: 0 0 10px rgba(91, 58, 142, 0.55), 0 0 22px rgba(226, 35, 26, 0.3); }
}

.song-artist {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--e106-red);
  margin-top: 0.25rem;
}

/* CONTROLES PERSONALIZADOS */
.player-controls {
  background-color: var(--bg-pill);
  border: 2px solid var(--theme-accent, var(--e106-yellow));
  border-radius: 999px;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  max-width: 420px;
  width: 100%;
  transition: border-color 0.6s ease, background-color 0.4s ease;
}

#play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--e106-red);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  flex-shrink: 0;
}

#play-btn:hover {
  background-color: var(--e106-red-dark);
}

#play-btn:active {
  transform: scale(0.95);
}

#cassette-icon .reel {
  transform-box: fill-box;
  transform-origin: center;
  animation: reel-spin 1s linear infinite;
}

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

/* Ecualizador animado, visible solo mientras el audio suena de verdad */
.eq-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
  flex-shrink: 0;
}

.eq-bars[hidden] {
  display: none;
}

.eq-bars span {
  width: 4px;
  height: 4px;
  border-radius: 1px;
  transition: height 0.07s linear;
}

.eq-bars span:nth-child(1) { background-color: var(--e106-red); }
.eq-bars span:nth-child(2) { background-color: var(--e106-yellow); }
.eq-bars span:nth-child(3) { background-color: var(--e106-green); }
.eq-bars span:nth-child(4) { background-color: var(--e106-purple); }

/* Respaldo: si el navegador no permite analizar el audio real, animación simulada */
.eq-bars--simulated span {
  animation: eq-bounce 0.9s ease-in-out infinite;
}

.eq-bars--simulated span:nth-child(1) { animation-delay: 0s; }
.eq-bars--simulated span:nth-child(2) { animation-delay: 0.2s; }
.eq-bars--simulated span:nth-child(3) { animation-delay: 0.1s; }
.eq-bars--simulated span:nth-child(4) { animation-delay: 0.3s; }

@keyframes eq-bounce {
  0%, 100% { height: 4px; }
  50% { height: 20px; }
}

.player-error {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--e106-red-dark);
  background-color: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  max-width: 420px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--e106-purple);
  cursor: pointer;
  display: flex;
}

.icon-btn:hover {
  color: var(--e106-red);
}

.volume-slider-container {
  flex: 1;
  display: flex;
  align-items: center;
}

#volume-slider {
  width: 100%;
  height: 6px;
  appearance: none;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--e106-green), var(--e106-yellow));
  outline: none;
  cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--e106-purple);
  cursor: pointer;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 1px var(--e106-purple);
}

#volume-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--e106-purple);
  cursor: pointer;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 1px var(--e106-purple);
}

/* COLUMNA HISTORIAL DE CANCIONES */
.right-column {
  border-top: 1px solid var(--e106-border);
  padding-top: 1.5rem;
}

@media (min-width: 768px) {
  .right-column {
    border-top: none;
    border-left: 1px solid var(--e106-border);
    padding-top: 0;
    padding-left: 2.5rem;
  }
}

.history-header {
  border-bottom: 3px solid var(--e106-yellow);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.history-header h2 {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--e106-purple);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 550px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 3px solid var(--e106-green);
  padding-left: 0.75rem;
}

.history-cover {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: var(--bg-placeholder);
}

.history-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-time {
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: 700;
  color: var(--e106-gray);
}

.history-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--e106-purple);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-artist {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--e106-red);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-empty {
  font-size: 0.85rem;
  color: var(--e106-gray);
  font-style: italic;
}

/* BOTÓN DE TEMA CLARO / OSCURO */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 5;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--e106-yellow);
  background-color: var(--bg-card);
  color: var(--e106-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: background-color 0.4s ease, transform 0.15s ease, color 0.4s ease;
}

.theme-toggle:hover {
  color: var(--e106-red);
}

.theme-toggle:active {
  transform: scale(0.92);
}

/* CONTACTO FLOTANTE: WhatsApp x2 + Correo */
.contact-cluster {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.contact-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 6px 16px var(--shadow-color);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.contact-btn:hover {
  transform: scale(1.08);
}

.contact-btn:active {
  transform: scale(0.95);
}

.contact-whatsapp {
  background-color: #25d366;
}

.contact-email {
  background-color: var(--e106-purple-solid);
}

@media (max-width: 480px) {
  .theme-toggle {
    top: 12px;
    right: 12px;
  }
  .contact-cluster {
    bottom: 12px;
    right: 12px;
  }
}
