/* VLZ Media - estilo Spotify, mobile-first */
:root {
  --bg: #121212;
  --bg-elev: #181818;
  --bg-elev2: #282828;
  --bg-card: #1a1a1a;
  --text: #ffffff;
  --text-soft: #b3b3b3;
  --accent: #1db954;
  --accent-hover: #1ed760;
  --danger: #e22134;
  --header-h: 56px;
  --nav-h: 60px;
  --mini-h: 60px;
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
a { color: inherit; }

#app { min-height: 100%; }

/* ---------- Layout principal ---------- */
.app-shell {
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
}
.top-header {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--header-h) + var(--safe-t)); padding-top: var(--safe-t);
  display: flex; align-items: center; gap: 12px; padding-left: 16px; padding-right: 16px;
  background: linear-gradient(180deg, #1f1f1f, var(--bg));
  backdrop-filter: blur(8px);
}
.top-header .logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; }
.top-header .logo img { width: 30px; height: 30px; border-radius: 7px; }
.top-header .spacer { flex: 1; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-soft); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-elev2); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }

/* contenido scrolleable; deja espacio para mini-player + nav */
.content {
  flex: 1; padding: 12px 16px;
  padding-bottom: calc(var(--nav-h) + var(--mini-h) + var(--safe-b) + 16px);
}

/* ---------- Botón de instalar / acciones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #000; font-weight: 700;
  border-radius: 999px; padding: 11px 20px; font-size: 14px;
  transition: transform .1s, background .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--bg-elev2); color: var(--text); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 14px; font-size: 13px; }

/* ---------- Secciones / listas ---------- */
.section-title { font-size: 22px; font-weight: 800; margin: 14px 0 12px; }
.muted { color: var(--text-soft); }
.empty {
  text-align: center; color: var(--text-soft); padding: 40px 16px; line-height: 1.6;
}
.empty svg { width: 56px; height: 56px; opacity: .35; margin-bottom: 12px; }

.song-list { display: flex; flex-direction: column; gap: 2px; }
.song-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px; border-radius: 8px; transition: background .15s;
}
.song-row:hover, .song-row.active { background: var(--bg-elev2); }
.song-cover {
  width: 48px; height: 48px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, #2a2a2a, #404040);
  display: flex; align-items: center; justify-content: center; color: var(--text-soft);
  position: relative; overflow: hidden;
}
.song-cover svg { width: 22px; height: 22px; }
.song-row.active .song-cover { color: var(--accent); }
/* Carátulas: la imagen rellena el contenedor; el icono queda de respaldo. */
.pl-cover, .np-art .cover { position: relative; overflow: hidden; }
.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.song-main { flex: 1; min-width: 0; }
.song-title {
  font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.song-row.active .song-title { color: var(--accent); }
.song-sub {
  font-size: 13px; color: var(--text-soft); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; margin-top: 2px;
}
.song-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.badge-offline { color: var(--accent); display: inline-flex; }
.badge-offline svg { width: 18px; height: 18px; }
.badge-lists {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--text-soft);
  background: var(--bg-elev2); border-radius: 10px; padding: 2px 7px 2px 5px;
}
.badge-lists svg { width: 14px; height: 14px; }
.dl-progress { font-size: 11px; color: var(--accent); min-width: 34px; text-align: right; }

/* menú contextual sencillo */
.row-menu-btn { color: var(--text-soft); padding: 6px; }
.row-menu-btn svg { width: 20px; height: 20px; }

/* ---------- Playlists grid ---------- */
.pl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.pl-card {
  background: var(--bg-elev); border-radius: var(--radius); padding: 12px;
  transition: background .15s;
}
.pl-card:hover { background: var(--bg-elev2); }
.pl-cover {
  width: 100%; aspect-ratio: 1; border-radius: 8px; margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent), #155f33);
  display: flex; align-items: center; justify-content: center;
}
.pl-cover svg { width: 40px; height: 40px; color: #fff; }
.pl-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-count { font-size: 12px; color: var(--text-soft); margin-top: 3px; }

/* ---------- Mini player ---------- */
.mini-player {
  position: fixed; left: 8px; right: 8px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 6px); z-index: 40;
  height: var(--mini-h);
  background: var(--bg-elev2); border-radius: 10px;
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.mini-player .song-cover { width: 44px; height: 44px; }
.mini-info { flex: 1; min-width: 0; }
.mini-progress {
  position: absolute; left: 12px; right: 12px; bottom: 4px; height: 3px;
  background: rgba(255,255,255,.18); border-radius: 2px; overflow: hidden;
}
.mini-progress > i { display: block; height: 100%; background: var(--accent); }
.mini-controls { display: flex; align-items: center; gap: 4px; }
.mini-controls .icon-btn { width: 40px; height: 40px; color: var(--text); }
.mini-controls .icon-btn svg { width: 26px; height: 26px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(16,16,16,.96); backdrop-filter: blur(10px);
  border-top: 1px solid #000;
  display: flex; justify-content: space-around; align-items: center;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-soft); font-size: 11px; flex: 1; padding: 6px 0;
}
.nav-item.active { color: var(--text); }
.nav-item svg { width: 24px; height: 24px; }

/* ---------- Now playing (pantalla completa) ---------- */
.now-playing {
  position: fixed; inset: 0; z-index: 60;
  background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 45%, var(--bg) 100%);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 10px) 22px calc(var(--safe-b) + 26px);
  transform: translateY(0); transition: transform .3s ease;
}
.np-header { display: flex; align-items: center; }
.np-header .np-title { flex: 1; text-align: center; font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 1px; }
.np-art {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 18px 0;
}
.np-art .cover {
  width: min(72vw, 360px); aspect-ratio: 1; border-radius: 12px;
  background: linear-gradient(135deg, #2a2a2a, #505050);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
}
.np-art .cover svg { width: 90px; height: 90px; color: var(--text-soft); }
.np-meta { margin-bottom: 8px; display: flex; align-items: center; gap: 12px; }
.np-meta-text { flex: 1; min-width: 0; }
.np-meta .t { font-size: 23px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-meta .a { font-size: 16px; color: var(--text-soft); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Acciones a la derecha del título: solo iconos */
.np-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
.np-act {
  position: relative; color: var(--text-soft); padding: 8px;
  display: flex; align-items: center; justify-content: center;
}
.np-act svg { width: 24px; height: 24px; }
.np-act.on { color: var(--accent); }
.np-act .spinner { width: 18px; height: 18px; }

/* Panel de volumen vertical (aparece al tocar el icono) */
.np-vol-wrap { position: relative; }
.vol-panel {
  position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 70;
  width: 46px; height: 150px; display: flex; align-items: center; justify-content: center;
  background: #2a2a2a; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.vol-panel input[type=range] { width: 120px; transform: rotate(-90deg); accent-color: var(--accent); }
.vol-backdrop { position: fixed; inset: 0; z-index: 65; }

/* barra de progreso */
.seek { margin: 14px 0 4px; }
.seek input[type=range] { width: 100%; }
.times { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-soft); }

input[type=range] {
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 3px;
  background: #5a5a5a; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: #fff;
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: #fff; }
.seek.playing input[type=range] { accent-color: var(--accent); }

/* controles principales */
.np-controls {
  display: flex; align-items: center; justify-content: space-between; margin-top: 14px;
}
.np-controls .ctl { color: var(--text); }
.np-controls .ctl svg { width: 34px; height: 34px; }
.np-controls .ctl.toggle.on { color: var(--accent); }
.np-controls .ctl.toggle { color: var(--text-soft); position: relative; }
.np-controls .ctl.toggle .one-badge {
  position: absolute; bottom: 2px; right: 2px; font-size: 9px; font-weight: 800;
  background: var(--accent); color: #000; border-radius: 50%; width: 13px; height: 13px;
  display: flex; align-items: center; justify-content: center;
}
.play-big {
  width: 64px; height: 64px; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.play-big svg { width: 30px; height: 30px; color: #000; }

/* Móvil en horizontal: el PWA ahora rota, así que la pantalla "Reproduciendo"
   se compacta y permite scroll para no romperse en pantallas bajas. */
@media (orientation: landscape) and (max-height: 520px) {
  .now-playing { padding: calc(var(--safe-t) + 6px) 18px calc(var(--safe-b) + 12px); overflow-y: auto; }
  .np-art { padding: 8px 0; }
  .np-art .cover { width: auto; height: min(42vh, 190px); }
  .np-art .cover svg { width: 56px; height: 56px; }
  .np-meta .t { font-size: 19px; }
  .np-meta .a { font-size: 14px; }
  .seek { margin: 8px 0 2px; }
  .np-controls { margin-top: 8px; }
  .np-controls .ctl svg { width: 28px; height: 28px; }
  .play-big { width: 52px; height: 52px; }
  .play-big svg { width: 26px; height: 26px; }
}

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px; background: var(--bg-elev2);
  border-radius: 16px 16px 0 0; padding: 18px 18px calc(var(--safe-b) + 18px);
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
.field { width: 100%; background: var(--bg); border: 1px solid #3a3a3a; color: var(--text);
  border-radius: 8px; padding: 12px 14px; font-size: 15px; margin-bottom: 12px; }
.field:focus { outline: none; border-color: var(--accent); }
.field-label { display: block; font-size: 12px; color: var(--text-soft); margin: 10px 0 4px; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-list { max-height: 50vh; overflow-y: auto; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-radius: 8px;
}
.sheet-item:hover { background: var(--bg-elev); }
.sheet-item .ic { color: var(--text-soft); display: flex; flex-shrink: 0; }
.sheet-item .ic svg { width: 22px; height: 22px; }
.sheet-item.danger { color: var(--danger); }
.sheet-item.danger .ic { color: var(--danger); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-icon svg { width: 20px; height: 20px; }
.btn-outline-accent {
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 5px 14px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.btn-outline-accent:hover { background: rgba(29,185,84,.12); }

/* toast */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--mini-h) + var(--safe-b) + 18px);
  z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #fff; color: #000; font-weight: 600; font-size: 13px;
  padding: 10px 16px; border-radius: 999px; box-shadow: 0 4px 16px rgba(0,0,0,.4); }

/* spinner */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Desktop / tablet ---------- */
@media (min-width: 900px) {
  :root { --mini-h: 72px; }
  .app-shell { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 1fr auto;
    grid-template-areas: "side main" "player player"; height: 100vh; }
  .top-header { grid-area: side / side / side / side; display: none; }
  .sidebar { grid-area: side; background: #000; padding: 18px 12px; display: flex; flex-direction: column; gap: 6px;
    position: sticky; top: 0; height: 100%; min-height: 0; overflow-y: auto; }
  .sidebar .logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; padding: 8px 10px 18px; }
  .sidebar .logo img { width: 32px; height: 32px; border-radius: 8px; }
  .update-banner {
    display: flex; align-items: center; gap: 10px; width: 100%;
    margin: 0 0 12px; padding: 10px 12px; border-radius: 8px;
    background: var(--accent); color: #000; font-weight: 700; font-size: 14px;
    text-align: left; cursor: pointer;
  }
  .update-banner svg { width: 18px; height: 18px; flex: 0 0 auto; }
  .update-banner:hover { filter: brightness(1.05); }
  .update-banner:disabled { opacity: .7; cursor: default; }
  .nav-desktop { display: flex; flex-direction: column; gap: 4px; }
  .nav-desktop .nav-item { flex-direction: row; justify-content: flex-start; gap: 14px; font-size: 15px;
    padding: 10px 12px; border-radius: 8px; }
  .nav-desktop .nav-item:hover { background: var(--bg-elev); }
  .sidebar .install-wrap { margin-top: auto; }
  .content { grid-area: main; overflow-y: auto; min-height: 0; padding: 22px 28px;
    padding-bottom: 40px; }
  .bottom-nav { display: none; }
  .mini-player { grid-area: player; position: static; left: auto; right: auto; bottom: auto;
    height: var(--mini-h); border-radius: 0; box-shadow: none; background: var(--bg-elev);
    border-top: 1px solid #2a2a2a; }
  .pl-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .toasts { bottom: calc(var(--mini-h) + 18px); }
}
.hide-desktop { }
@media (min-width: 900px) { .hide-desktop { display: none !important; } .show-desktop { display: flex !important; } }
@media (max-width: 899px) { .sidebar { display: none; } .show-desktop { display: none !important; } }

/* ---------- Login / Registro ---------- */
.auth-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 50% 0%, #1f1f1f 0%, var(--bg) 60%);
}
.auth-card {
  width: 100%; max-width: 360px; background: var(--bg-elev);
  border-radius: 14px; padding: 28px 24px; box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.auth-logo {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; font-size: 20px; margin-bottom: 18px;
}
.auth-logo img { width: 34px; height: 34px; border-radius: 8px; }
.auth-card h2 { text-align: center; margin: 0 0 18px; font-size: 18px; }
.auth-card .field { margin-bottom: 12px; }
.auth-error {
  background: rgba(226,33,52,.12); color: #ff6b78; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; margin-bottom: 12px; text-align: center;
}
.auth-switch { text-align: center; font-size: 13px; color: var(--text-soft); margin-top: 16px; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.user-box {
  margin-top: auto; padding-top: 16px; display: flex; align-items: center;
  gap: 10px; border-top: 1px solid #2a2a2a;
}
.user-box .user-name {
  font-size: 13px; color: var(--text-soft); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex: 1;
}

/* ---------- Descubrir ---------- */
.discover-search { display: flex; gap: 10px; margin: 12px 0 16px; }
.discover-search .field { margin: 0; flex: 1; }
.discover-search .btn { white-space: nowrap; }
.discover-thumb { overflow: hidden; background: var(--bg-elev2); }
.discover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.confirm-lists {
  margin: 4px 0 16px; padding: 10px 12px; list-style: none;
  background: var(--bg-elev2); border-radius: 8px; max-height: 180px; overflow: auto;
}
.confirm-lists li { font-size: 14px; padding: 3px 0; color: var(--text-soft); }
.confirm-lists li::before { content: "• "; color: var(--accent); }

/* ---------- Configuraciones ---------- */
.settings-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.settings-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 16px; background: var(--bg-elev); border-radius: var(--radius);
  text-align: left; color: var(--text);
}
.settings-item:disabled { opacity: .6; }
.settings-item .si-ic { display: flex; color: var(--accent); }
.settings-item .si-ic svg { width: 24px; height: 24px; }
.settings-item .si-main { display: flex; flex-direction: column; flex: 1; }
.settings-item .si-title { font-size: 15px; }
.settings-item .si-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
