/* ========================================
   LoDiveRadio - Reproductor Web
   Estilos principales - Versión optimizada
   ======================================== */

/* ========================================
   VARIABLES CSS (Fácil personalización)
   ======================================== */
:root {
  --bg: #0f1720;                    /* Fondo de página */
  --card: #0b1220;                  /* Fondo de la tarjeta */
  --accent: #ff7043;                /* Color principal (botón play, acentos) */
  --accent-hover: #ff8a65;          /* Hover del color principal */
  --muted: #9aa6b2;                 /* Texto secundario */
  --glass: rgba(255, 255, 255, 0.03); /* Fondos sutiles de botones */
  --success: #4caf50;               /* Estado: online */
  --warning: #ffc107;               /* Estado: conectando */
  --danger: #f44336;                /* Estado: offline/error */
  --shadow: rgba(2, 6, 23, 0.7);    /* Sombra base */
  --shadow-glow: rgba(255, 112, 67, 0.15); /* Resplandor al reproducir */
}

/* ========================================
   RESET Y BASE
   ======================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body, #app {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, 
               system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #071021 0%, #071421 100%);
  color: #e6eef6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  line-height: 1.5;
}

/* ========================================
   CARD PRINCIPAL
   ======================================== */
.card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 30px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  user-select: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Estado visual cuando está reproduciendo */
.card.playing {
  border-color: rgba(255, 112, 67, 0.4);
  box-shadow: 0 0 20px var(--shadow-glow), 0 8px 30px var(--shadow);
}

/* ========================================
   BANNER SUPERIOR
   ======================================== */
.header-banner {
  width: 100%;
  margin-bottom: 10px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.header-banner img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}

.header-banner img:hover {
  opacity: 0.95;
}

/* ========================================
   META INFORMACIÓN
   ======================================== */
.meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 4px;
}

.title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.status {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  transition: color 0.2s ease;
}

/* Estados de conexión con colores */
.status.online {
  color: var(--success);
  position: relative;
  padding-left: 18px;
}

.status.online::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status.connecting {
  color: var(--warning);
}

.status.offline {
  color: var(--danger);
}

/* Animación de pulso para "En vivo" */
@keyframes pulse {
  0%, 100% { 
    opacity: 1; 
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
  }
  50% { 
    opacity: 0.8; 
    box-shadow: 0 0 0 6px rgba(76, 175, 80, 0);
  }
}

.metaSmall {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

/* ========================================
   CONTROLES PRINCIPALES
   ======================================== */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  flex-wrap: wrap;
}

.btn {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--muted);
  height: 52px;
  width: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: translateY(1px);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Botón Play destacado */
.btn.play {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #081019;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(255, 112, 67, 0.3);
}

.btn.play:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 16px rgba(255, 112, 67, 0.4);
}

.btn.play:active {
  transform: translateY(2px);
  box-shadow: 0 2px 8px rgba(255, 112, 67, 0.3);
}

/* Botón Stop */
.btn.stop {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
}

.btn.stop:hover {
  background: rgba(244, 67, 54, 0.15);
  color: var(--danger);
  border-color: var(--danger);
}

/* Botón Mute */
.btn.mute {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.btn.mute:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Accesibilidad: foco visible con teclado */
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ========================================
   CONTROL DE VOLUMEN
   ======================================== */
.volWrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

input[type="range"] {
  width: 120px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.1s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--accent-hover);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ========================================
   FILA DE INFORMACIÓN
   ======================================== */
.infoRow {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 2px;
  font-size: 12px;
  color: var(--muted);
  align-items: center;
  font-weight: 500;
}

.infoRow span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ========================================
   VISUALIZADOR DE AUDIO (CANVAS)
   ======================================== */
.meterWrap {
  padding: 6px 4px;
}

canvas {
  width: 100%;
  height: 40px;  /* ✅ Coincide con el atributo height="40" del HTML */
  border-radius: 8px;
  background: transparent;
  display: block;  /* ✅ Evita espacio extra por inline */
  image-rendering: pixelated;  /* ✅ Mejor rendimiento en animación */
}

/* ========================================
   MENSAJES DE ESTADO (Opcional, para JS)
   ======================================== */
.message {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

.message.error {
  background: rgba(244, 67, 54, 0.15);
  color: var(--danger);
  border: 1px solid rgba(244, 67, 54, 0.3);
}

.message.success {
  background: rgba(76, 175, 80, 0.15);
  color: var(--success);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   RESPONSIVE - MÓVILES (< 480px)
   ======================================== */
@media (max-width: 480px) {
  body {
    padding: 12px;
  }
  
  .card {
    padding: 14px;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow);
  }
  
  .card.playing {
    box-shadow: 0 0 12px var(--shadow-glow), 0 4px 20px var(--shadow);
  }
  
  .header-banner img {
    height: 100px;
  }
  
  .title {
    font-size: 17px;
  }
  
  .btn {
    height: 48px;
    width: 48px;
    font-size: 18px;
    transition: transform 0.08s ease, background 0.08s ease;
    touch-action: manipulation;  /* ✅ Elimina delay de 300ms en touch */
  }
  
  .btn.play {
    font-size: 17px;
  }
  
  .btn.mute {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }
  
  input[type="range"] {
    width: 90px;
    height: 3px;
  }
  
  input[type="range"]::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
  }
  
  canvas {
    height: 36px;  /* Reducir ligeramente en móviles muy pequeños */
  }
  
  .metaSmall {
    font-size: 11px;
  }
}

/* ========================================
   TABLETS (481px - 768px)
   ======================================== */
@media (min-width: 481px) and (max-width: 768px) {
  .card {
    max-width: 480px;
    padding: 18px;
  }
  
  .header-banner img {
    height: 130px;
  }
  
  input[type="range"] {
    width: 140px;
  }
}

/* ========================================
   ACCESIBILIDAD: prefers-reduced-motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .card {
    transition: none;
  }
  
  .btn:active {
    transform: none;
  }
  
  .status.online::before {
    animation: none;
    box-shadow: none;
  }
  
  input[type="range"]::-webkit-slider-thumb {
    transition: none;
  }
  
  .message {
    animation: none;
  }
}

/* ========================================
   ALTO CONTRASTE (accesibilidad)
   ======================================== */
@media (prefers-contrast: high) {
  :root {
    --glass: rgba(255, 255, 255, 0.1);
    --shadow: rgba(0, 0, 0, 0.9);
  }
  
  .card {
    border-color: rgba(255, 255, 255, 0.3);
  }
  
  .btn {
    border-color: rgba(255, 255, 255, 0.3);
  }
  
  .status.online::before {
    box-shadow: 0 0 0 2px var(--success);
  }
}

/* ========================================
   MODO OSCURO DEL SISTEMA (refuerzo)
   ======================================== */
@media (prefers-color-scheme: dark) {
  /* Ya estamos en modo oscuro por defecto, 
     pero esto asegura consistencia si el usuario cambia */
  body {
    background: linear-gradient(180deg, #071021 0%, #071421 100%);
  }
}

/* ========================================
   UTILIDADES (para JS o expansión futura)
   ======================================== */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Animación suave para cambios de estado */
.fade {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade.out {
  opacity: 0;
  transform: scale(0.98);
}