@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800;900&display=swap');

:root {
  --sp-black: #000000;
  --sp-base: #121212;
  --sp-elevated-base: #181818;
  --sp-highlight: #242424;
  --sp-press: #000000;
  --sp-green: #1ed760;
  --sp-green-hover: #1fdf64;
  --sp-green-active: #169c46;
  --sp-text-base: #ffffff;
  --sp-text-subdued: #a7a7a7;
  --sp-text-bright-accent: #1ed760;
  --sp-card-radius: 8px;
  --sp-font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--sp-font);
  background-color: var(--sp-black);
  color: var(--sp-text-base);
  overflow: hidden;
  height: 100vh;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  outline: none;
}

/* App container */
.app {
  display: flex;
  height: calc(100vh - 90px);
  padding: 8px;
  gap: 8px;
  background-color: var(--sp-black);
}

/* Sidebar estilo Spotify v2 */
.sidebar {
  width: 280px;
  background-color: var(--sp-base);
  border-radius: var(--sp-card-radius);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow: hidden;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 20px 12px;
}

.logo-mark {
  width: 38px;
  height: 38px;
  background: var(--sp-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(30, 215, 96, 0.4);
}

.logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--sp-text-subdued);
  margin: 18px 12px 6px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 6px;
  color: var(--sp-text-subdued);
  font-size: 14px;
  font-weight: 700;
  transition: color 0.2s, background-color 0.2s;
}

.nav-item:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #fff;
  background-color: var(--sp-highlight);
}

.nav-item.active .icon {
  color: var(--sp-green);
}

.icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-mini {
  border-top: 1px solid #282828;
  padding: 16px 12px 4px 12px;
  font-size: 13px;
  color: var(--sp-text-subdued);
}

/* Main Area estilo Spotify */
.main {
  flex: 1;
  background: linear-gradient(180deg, #222222 0%, var(--sp-base) 280px);
  border-radius: var(--sp-card-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.topbar {
  height: 64px;
  background: rgba(18, 18, 18, 0.7);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 10;
  position: sticky;
  top: 0;
}

.play-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  transition: transform 0.1s, background-color 0.2s;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.06);
}

.icon-btn.active {
  color: var(--sp-green) !important;
  border: 1px solid var(--sp-green);
}

.icon-btn.play-btn {
  width: 48px;
  height: 48px;
  background: var(--sp-green);
  color: #000;
  font-size: 18px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.icon-btn.play-btn:hover {
  background: var(--sp-green-hover);
  transform: scale(1.08);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: #242424;
  border-radius: 500px;
  width: 380px;
  max-width: 100%;
  border: 1px solid transparent;
  transition: border-color 0.2s, background-color 0.2s;
}

.search:focus-within {
  border-color: #fff;
  background: #2a2a2a;
}

.search .icon {
  color: var(--sp-text-subdued);
  font-size: 16px;
}

.search-input {
  background: transparent;
  border: none;
  color: #fff;
  width: 100%;
  font-size: 14px;
  font-weight: 500;
  outline: none;
}

.search-input::placeholder {
  color: #757575;
}

.user {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: #282828;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #000;
  cursor: pointer;
  transition: transform 0.1s;
}

.user:hover {
  transform: scale(1.05);
}

.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Contenido y Cards Spotify */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 40px 28px;
}

.content::-webkit-scrollbar {
  width: 12px;
}

.content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
}

.section-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 20px;
  color: #fff;
  letter-spacing: -0.6px;
}

.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.song-card {
  position: relative;
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  background: #181818;
  transition: background-color 0.3s cubic-bezier(0.3, 0, 0, 1);
}

.song-card:hover {
  background: #282828;
}

.card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  background: #121212;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  margin-bottom: 14px;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-cover .cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #242424;
  color: var(--sp-text-subdued);
  font-size: 48px;
}

/* Botón flotante Play de Spotify que sube con hover */
.card-play {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 48px;
  height: 48px;
  background: var(--sp-green);
  border-radius: 50%;
  color: #000;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease-out;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.song-card:hover .card-play {
  opacity: 1;
  transform: translateY(0);
}

.card-play:hover {
  background: var(--sp-green-hover);
  transform: scale(1.08) !important;
}

.card-info {
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.card-artist {
  font-size: 13px;
  color: var(--sp-text-subdued);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  color: var(--sp-text-subdued);
  font-size: 16px;
  text-align: center;
  margin-top: 60px;
  font-weight: 500;
  grid-column: 1 / -1;
}

/* GENRE & PLAYLISTS CARDS */
.genre-card {
  position: relative;
  min-height: 140px;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.genre-card:hover {
  transform: scale(1.03);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}
.genre-name {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}
.genre-icon {
  align-self: flex-end;
  font-size: 38px;
  opacity: 0.85;
}

/* PLAYLIST BUTTON */
.btn-add-pl {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s, transform 0.1s;
  z-index: 10;
}
.song-card:hover .btn-add-pl {
  opacity: 1;
}
.btn-add-pl:hover {
  background: var(--sp-green);
  color: #000;
  transform: scale(1.1);
}

/* BOTÓN CORAZÓN (LIKE) EN TARJETA */
.btn-like-card {
  position: absolute;
  left: 48px;
  bottom: 10px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s, transform 0.1s;
  z-index: 10;
}
.song-card:hover .btn-like-card {
  opacity: 1;
}
.btn-like-card:hover {
  background: #282828;
  color: var(--sp-green);
  transform: scale(1.1);
}
.btn-like-card.liked {
  opacity: 1;
  color: var(--sp-green);
}

/* CHIPS DE FILTRO SUPERIORES (inspirado en hiegit/music HomeHeader Chips) */
.home-chips-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  align-items: center;
}
.filter-chip {
  padding: 7px 14px;
  border-radius: 500px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, transform 0.1s;
  border: none;
}
.filter-chip:hover {
  background: rgba(255, 255, 255, 0.15);
}
.filter-chip.active {
  background: #ffffff;
  color: #000000;
  font-weight: 700;
}

/* TARJETAS HORIZONTALES DE ACCESO RÁPIDO (inspirado en hiegit/music TopTracks HorizontalCard) */
.quick-access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.horizontal-card {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  overflow: hidden;
  height: 64px;
  cursor: pointer;
  transition: background-color 0.25s ease;
  position: relative;
}
.horizontal-card:hover {
  background: rgba(255, 255, 255, 0.18);
}
.horizontal-card-img {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  background: #242424;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--sp-green);
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.4);
}
.horizontal-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.horizontal-card-text {
  flex: 1;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.horizontal-card-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sp-green);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  margin-right: 12px;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.2s ease;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}
.horizontal-card:hover .horizontal-card-play {
  opacity: 1;
  transform: scale(1);
}

/* MODAL */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-box {
  background: #181818;
  border: 1px solid #282828;
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}
.btn-close-modal {
  background: transparent;
  color: var(--sp-text-subdued);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.btn-close-modal:hover { color: #fff; }
.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  background: #242424;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #fff;
  margin-bottom: 16px;
}
.form-input:focus {
  border-color: #fff;
  background: #2a2a2a;
  outline: none;
}
.btn-primary {
  background: var(--sp-green);
  color: #000;
  padding: 10px 20px;
  border-radius: 500px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:hover {
  background: var(--sp-green-hover);
}
.btn-secondary {
  background: #242424;
  color: #fff;
  padding: 10px 20px;
  border-radius: 500px;
  font-weight: 700;
  cursor: pointer;
  margin-right: 8px;
}
.btn-secondary:hover {
  background: #333;
}

/* ========================================================
   100% RESPONSIVE PARA DISPOSITIVOS MÓVILES (SMARTPHONES)
   ======================================================== */
@media (max-width: 768px) {
  body {
    overflow-y: auto !important;
    height: auto !important;
    padding-bottom: 120px !important;
  }

  .app {
    flex-direction: column !important;
    height: auto !important;
    padding: 0 !important;
    gap: 0 !important;
  }

  /* Barra superior compacta para móviles */
  .sidebar {
    width: 100% !important;
    height: auto !important;
    border-radius: 0 !important;
    padding: 10px 14px !important;
    background-color: #121212 !important;
    border-bottom: 1px solid #242424;
  }

  .sidebar .logo {
    padding: 0 0 10px 0 !important;
    justify-content: space-between;
  }

  /* Menú de navegación en móviles: scroll horizontal táctil con botones tipo chip */
  .sidebar .nav {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    gap: 8px !important;
    padding-bottom: 6px !important;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar .nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar .nav-section {
    display: none !important;
  }

  .sidebar .nav-item {
    padding: 6px 14px !important;
    border-radius: 20px !important;
    background: #242424 !important;
    font-size: 13px !important;
    color: #fff !important;
    flex-shrink: 0 !important;
  }

  .sidebar .nav-item.active {
    background: var(--sp-green) !important;
    color: #000 !important;
    font-weight: 700;
  }

  .sidebar .user-mini {
    display: none !important;
  }

  /* Área principal de contenido en móviles */
  .main-view {
    border-radius: 0 !important;
    padding: 14px 12px 100px 12px !important;
    height: auto !important;
    overflow-y: visible !important;
  }

  /* Topbar en móviles */
  .topbar-public {
    flex-direction: column !important;
    gap: 12px !important;
    margin-bottom: 18px !important;
    padding: 0 !important;
  }

  .topbar-center {
    width: 100% !important;
    max-width: 100% !important;
  }

  .search-box-wrap {
    width: 100% !important;
  }

  .topbar-right {
    width: 100% !important;
    justify-content: space-between !important;
  }

  /* Cuadrícula de canciones y playlists en móviles: 2 columnas bien proporcionadas */
  .song-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .song-card {
    padding: 10px !important;
  }

  .card-cover {
    height: 140px !important;
  }

  .card-title {
    font-size: 13px !important;
  }

  .card-artist {
    font-size: 11px !important;
  }

  /* Botón de reproducción siempre visible en móviles (sin necesidad de hover) */
  .song-card .card-play {
    opacity: 1 !important;
    transform: none !important;
    bottom: 8px !important;
    right: 8px !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 14px !important;
  }

  .song-card .btn-add-pl {
    opacity: 1 !important;
    bottom: 8px !important;
    left: 8px !important;
  }

  /* Modales en móviles ocupando el ancho completo cómodo */
  .modal-box {
    width: 94% !important;
    padding: 18px !important;
  }
}

@media (max-width: 480px) {
  .song-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .card-cover {
    height: 125px !important;
  }
}