/* ====================================================================== */
/* ==================  ESTILOS ESPECÍFICOS DE INDEX.HTML  =============== */
/* ====================================================================== */

/* Variables CSS y configuración base */
:root {
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  --sal: env(safe-area-inset-left);
  --sar: env(safe-area-inset-right);
}

html {
  height: -webkit-fill-available;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  margin: 0;
  overflow: hidden;
  height: 100vh;
  height: -webkit-fill-available;
}

.container {
  display: flex;
  height: 100%;
  max-height: 100vh;
  max-height: -webkit-fill-available;
  padding-top: env(safe-area-inset-top);
}

.miniatura {
  width: 100px;
  height: 100px;
  background-size: cover;
  background-position: center;
  border: none;
  border-radius: 0px;
  margin: 0px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.miniatura:hover {
  transform: scale(1);
}

#miniaturasContainer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0px;
  gap: 0px;
  overflow-y: auto;
}

/* Estilos para el slider (input range) */
#seekBar {
  appearance: none;
  -webkit-appearance: none;
  width: 80%; /* Ancho reducido al 80% */
  height: 6px;
  background: #ccc;
  outline: none;
  border-radius: 3px;
  margin: 10px auto; /* Centrado horizontal */
  display: block; /* Asegura que el margin auto funcione */
  pointer-events: none;
}

/* Thumb del slider (para Webkit: Chrome, Safari, Edge) */
#seekBar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;  /* Mantenemos el tamaño original */
  height: 24px;
  background: #4a9eff;
  border: 2px solid white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 10px transparent;  /* Área transparente alrededor */
  margin-top: 0px;  /* Ajuste perfecto para el centro */
  transition: transform 0.1s ease;
  position: relative;
  z-index: 1;
}

/* Aumentamos el área de interacción con pseudo-elementos */
#seekBar::-webkit-slider-thumb::before {
  content: '';
  position: absolute;
  width: 44px;  /* 24px + 20px extra */
  height: 44px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border-radius: 50%;
  pointer-events: all;
}

/* Thumb para Firefox */
#seekBar::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: #4a9eff;
  border: 2px solid white;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
}

/* Thumb para IE/Edge */
#seekBar::-ms-thumb {
  width: 24px;
  height: 24px;
  background: #4a9eff;
  border: 2px solid white;
  border-radius: 50%;
  cursor: pointer;
}

/* Mantenemos todos los eventos de interacción originales */
#seekBar::-webkit-slider-thumb {
  pointer-events: all;
}

/* Efecto al interactuar con el thumb */
#seekBar::-webkit-slider-thumb:hover,
#seekBar::-moz-range-thumb:hover,
#seekBar::-ms-thumb:hover {
  transform: scale(1.1);
}

.sidebar {
  padding-top: 0px; /* Valor fijo en lugar de env(safe-area-inset-top) */
}

/* ====================================================================== */
/* =======================  ESTILOS GENERALES  ========================== */
/* ====================================================================== */
html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;      /* Evita scroll de fondo */
  height: 100%;
  background-color: #363739; /* Fondo gris oscuro solicitado */
  font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Helvetica Neue', sans-serif;
}

/* Contenedor principal dividido en barra lateral y área de reproducción */
.container {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
 /* padding-top: env(safe-area-inset-top); /* Ajuste para notch/status-bar */
}

/* ====================================================================== */
/* ===============  BARRA LATERAL CON MINIATURAS (SIDEBAR) ============== */
/* ====================================================================== */
.sidebar {
  width: 100px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  gap: 0;
  
  /* padding-top: var(--sat, 0px); */ /* Ya no es crucial si env() es 0px */
  /* padding-bottom: var(--sab, 0px); */ /* Ya no es crucial si env() es 0px */
  /* Si necesitas un padding superior específico por diseño, añádelo aquí */
  /* padding-top: 10px; */ /* Ejemplo */

  box-sizing: border-box;
  height: 100%;
}

/* Botones de miniaturas */
.sidebar .miniatura {
  /* *IMPORTANTE*: sin padding extra para que NO aparezcan márgenes en desktop */
  margin: 0;
  padding: 0;
  line-height: 0;
  vertical-align: top;
  box-sizing: border-box;
  position: relative;
  width: 100px;
  aspect-ratio: 1/1;                /* Mantiene 1:1 */
  font-size: 0;                     /* Oculta texto */
  background: #555;
  background-size: cover;
  background-position: center;
  border: none;
  color: white;
  cursor: pointer;
}

/* Número sobre cada miniatura */
.sidebar .miniatura::after {
  content: attr(data-label);
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 14px;
  background-color: black;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  z-index: 2;
}

/* Efecto hover sólo visible en computadora */
@media (hover: hover) {
  .sidebar .miniatura:hover {
    filter: brightness(1.3);
  }
}

/* Arreglo específico para el scroll en móviles - mantiene la visualización actual */
@media (max-width: 768px), (hover: none), (pointer: coarse) {
  /* El contenedor padre debe permitir scroll pero sin manejarlo directamente */
  .sidebar {
    overflow-y: visible !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    position: relative !important;
    height: 100vh !important;
  }
  
  /* El contenedor de miniaturas debe manejar su propio scroll para que funcione posicionarMiniatura() */
  #miniaturasContainer {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 100vh !important;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
    /* Mantener las propiedades flex para el posicionamiento */
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
  
  /* Asegurar que las miniaturas mantengan su aspecto y no se compriman */
  .sidebar .miniatura {
    width: 100px !important;
    height: 100px !important;
    min-width: 100px !important;
    min-height: 100px !important;
    aspect-ratio: 1/1 !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
  }
}

/* ====================================================================== */
/* ===================  ÁREA PRINCIPAL DE REPRODUCCIÓN  ================= */
/* ====================================================================== */
.main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; 
  align-items: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
  background-color: #363739; /* o #ff6666 como tenías antes */
  
  /* Mantenemos el padding-top de 160px si es parte de tu diseño,
     var(--sat) probablemente será 0px ahora. */
  padding-top: 160px; /* O calc(160px + var(--sat, 0px)); si quieres mantener la variable por si acaso */
  /* padding-bottom: var(--sab, 0px); */ /* Ya no es crucial si env() es 0px */
  /* Si necesitas un padding inferior específico por diseño, añádelo aquí */
  /* padding-bottom: 20px; */ /* Ejemplo */

  box-sizing: border-box;
  height: 100%;
}

/* Carátula del tema actual */
.caratula {
  width: 200px;
  height: 200px;
  border-radius: 30px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  /* color de respaldo (carga) */
  background-color: red;
}

/* Información textual */
.info { width: 200px; text-align: left; }

.nombreCancion {
  font-size: 1.25rem; /* 20–22 px aprox. */
  font-weight: 600;
  color: #FFFFFF;
}
.artista {
  font-size: 0.9rem;  /* 14–16 px aprox. */
  font-weight: 400;
  color: #B3B3B3;
}

/* Barra de progreso */
#seekBar { width: 80%; }

/* Botón play / pausa redondo */
#playPause {
  width: 150px;
  height: 150px;
  border: none;
  border-radius: 50%;
  background: white;
  color: black;
  font-size: 64px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
#playPause:hover { background: #eee; }

/* Íconos de play / pause construidos con CSS */
.icon { width: 0; height: 0; border-style: solid; }
.play-icon { border-width: 20px 0 20px 35px; border-color: transparent transparent transparent black; }

.pause-icon { display: flex; gap: 10px; }
.pause-icon div { width: 10px; height: 40px; background: black; }

/* Ícono de replay (Unicode) */
.replay-icon {
  display: block;
  font-size: 80px; /* tamaño grande dentro del botón 150x150 */
  line-height: 1;
  width: auto;
  height: auto;
  color: black;
}

/* Botón de guitarra para alternar audio secundario */
#guitarraBtn {
  width: 50px;
  height: 50px;
  position: absolute; /* Cambiado para posicionamiento absoluto respecto a .main */
  
  /* Centrado horizontal: .main centra sus hijos (como .caratula)
     así que left: 50% y translateX(-50%) centrarán el botón en .main */
  left: 50%;
  
  /* Centrado vertical sobre .caratula:
     - .main padding-top: 160px
     - .caratula height: 200px (su centro está a 100px de su borde superior)
     - Centro vertical de .caratula desde el top de .main = 160px + 100px = 260px
     - #guitarraBtn height: 50px (su centro está a 25px de su borde superior)
     - Para alinear centros: top del botón = 260px (centro carátula) - 25px (mitad botón) = 235px */
  top: 90px; 
  
  transform: translateX(-50%); /* Para ajustar el left: 50% y centrar el botón */
  
  z-index: 2; /* Para asegurar que esté sobre la carátula si es necesario */

  display: none;                    /* Visible solo en covers con audio alternativo */
  align-items: center;              /* Para centrar el contenido del botón (ej. ícono) */
  justify-content: center;          /* Para centrar el contenido del botón (ej. ícono) */

  border: none;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 10px gray;
  cursor: pointer;
}
#guitarraBtn.active {              /* Resalta en rojo cuando está activo */
  box-shadow: 0 0 10px red !important;
}

/* Versión en esquina */
.version {
  position: absolute;
  bottom: 10px;
  right: 20px;
  font-size: 16px;
  color: #999;
}

/* Botón de detalles */
.details-arrow {
  position: absolute;
  top: 60px;
  right: 20px;
  font-size: 36px;
  color: #4a9eff;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 10;
  background: rgba(34,34,34,0.7);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

.details-arrow:hover {
  transform: translateX(5px);
}

.details-arrow.show {
  display: flex;
}

/* Spinner */
#spinner {
  display: none;
  position: fixed;
  bottom: 10px;
  right: 100px;
  width: 20px;
  height: 20px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #555;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 1000;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Deshabilita selección por long-press y el menú contextual en iOS/Android */
html, body, .container, .main, .sidebar, .miniatura, button, a, img, svg, div, p, span {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* evita el menú al mantener presionado */
  -webkit-tap-highlight-color: transparent; /* quita highlight azul */
}

/* Evita arrastrar imágenes (iOS/Safari) */
img {
  -webkit-user-drag: none;
  /* user-drag: none;  eliminado por no estándar */
}

/* Permitir selección y callout en inputs si los usas */
input, textarea, select {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
