/* Estilos del soundboard. Reusa las variables de :root definidas en index.html. */

#sounds {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Auto-fill en vez de un número fijo de columnas: en mobile angosto entran
   3 celdas de ~96px sin scroll horizontal. El máximo de la track tiene que
   ser `1fr` (no un largo fijo como 140px): auto-fill cuenta las columnas
   usando el máximo de la track cuando es un largo fijo, así que con
   `minmax(96px, 140px)` a 390px de ancho solo entraban 2 columnas en vez de
   3 (R3). Con `1fr` el conteo usa el mínimo (96px), y el `max-width` de acá
   abajo es lo que evita que las celdas crezcan gigantes en desktop (si no,
   con pocos sonidos quedaban cuadrados gigantes vacíos). */
.sound-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  padding-bottom: 96px;
  max-width: 760px;
}

/* Contenedor de una celda: el botón "tocar" y el "⋯" son HERMANOS acá
   adentro, nunca uno anidado en el otro (ver fix H5). */
.sound-cell {
  position: relative;
  aspect-ratio: 1;
}

.sound {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: var(--cell);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  overflow: hidden;
  /* evita el menú/callout de "guardar imagen" y la selección de texto al
     hacer un toque largo en mobile (ver M2b) */
  -webkit-touch-callout: none;
  user-select: none;
}
.sound:active {
  background: var(--cell-on);
}
.sound.playing {
  background: var(--cell-on);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(210, 85, 58, 0.35);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(210, 85, 58, 0);
  }
}

.sound img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 12px;
}
.sound .icon-text {
  font-size: 40px;
  line-height: 1;
}
.sound .sound-name {
  font-size: 12px;
  color: var(--dim);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sound-menu {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 16px;
  background: rgba(20, 21, 23, 0.35);
}
.sound-menu:active {
  background: rgba(255, 255, 255, 0.12);
}

.sound-add {
  border: 1px dashed var(--line);
  background: none;
  color: var(--dim);
  font-size: 32px;
}
.sound-add:active {
  color: var(--text);
}

#stopSound {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom));
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  padding: 12px 26px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 21, 23, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  border: 2px dashed var(--accent);
  margin: 12px;
}

/* Hoja modal genérica (subir sonido, elegir canal, menú de un sonido) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 85vh;
  overflow-y: auto;
}
.sheet h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
}
.sheet label {
  font-size: 13px;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sheet input[type="text"] {
  font: inherit;
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
}
.sheet .icon-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
}
.sheet .icon-pick img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
}
.sheet .icon-pick .icon-text {
  font-size: 26px;
}
.sheet .row-actions {
  display: flex;
  gap: 10px;
}
.sheet button.primary {
  flex: 1;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  padding: 13px;
  border-radius: 999px;
  text-align: center;
}
.sheet button.primary[disabled] {
  opacity: 0.5;
}
.sheet button.secondary {
  flex: 1;
  padding: 13px;
  border-radius: 999px;
  background: var(--cell);
  text-align: center;
}
.sheet button.danger {
  color: var(--accent);
}
.sheet .channel-option,
.sheet .menu-option {
  padding: 14px;
  border-radius: 12px;
  background: var(--cell);
  text-align: left;
  font-size: 15px;
}
.sheet .channel-option:active,
.sheet .menu-option:active {
  background: var(--cell-on);
}
.sheet .error {
  color: var(--accent);
  font-size: 13px;
}
