* { box-sizing: border-box; }

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-dark);
  color: var(--text-secondary);
}

h2 {
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* Sticky player at bottom */
#player-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-darker);
  border-top: 2px solid var(--color-primary);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 100;
}

#now-playing {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player {
  flex: 2;
  min-width: 200px;
  accent-color: var(--color-primary);
}

/* Artist groups */
.group {
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.group-content {
  display: flex;
  flex-direction: column;
}

.group-nested {
  margin: 8px 10px 10px 18px;
  border-radius: 6px;
}

.group summary {
  cursor: pointer;
  padding: 10px 16px;
  background: var(--bg-darker);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  font-weight: bold;
  color: var(--text-primary);
}

.group summary::-webkit-details-marker { display: none; }

.group > summary .arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 12px;
  color: var(--color-primary);
}

.group[open] > summary .arrow {
  transform: rotate(90deg);
}

.group summary .count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: normal;
}

.group-nested summary {
  background: var(--bg-hover);
  font-size: 13px;
  padding-left: 14px;
}

.song-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.song-list li {
  padding: 8px 16px 8px 30px;
  cursor: pointer;
  border-top: 1px solid var(--border-color);
  transition: background 0.15s;
  font-size: 14px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-list li:hover {
  background: var(--bg-hover);
}

.song-list li.playing {
  background: var(--bg-playing);
  color: #fff;
  font-weight: bold;
  padding-left: 14px;
}

.song-list li.playing::before {
  content: "▶ ";
  color: var(--text-primary);
}

/* Pantalla de login */
#login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#login-screen.hidden {
  display: none;
}

.login-box {
  background: var(--bg-darker);
  border: 2px solid var(--color-primary);
  border-radius: 12px;
  padding: 40px;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.login-box h1 {
  color: var(--text-primary);
  margin-bottom: 30px;
  font-size: 28px;
}

.login-box input {
  width: 100%;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.login-box input::placeholder {
  color: var(--text-muted);
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s;
}

.login-box button:hover {
  background: var(--color-primary-dark);
}

.login-box .user-info {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
}

.login-box .user-info button {
  margin-top: 10px;
  background: var(--color-delete);
  padding: 8px 16px;
  width: auto;
  font-size: 14px;
}

.login-box .user-info button:hover {
  background: var(--color-delete-hover);
}

/* Tema selector */
.theme-selector {
  position: fixed;
  bottom: 70px;
  right: 20px;
  z-index: 50;
  background: var(--bg-darker);
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  padding: 12px;
  display: none;
}

.theme-selector.visible {
  display: block;
}

.theme-selector h4 {
  margin: 0 0 10px 0;
  color: var(--text-primary);
  font-size: 12px;
  text-align: center;
}

.theme-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.theme-btn {
  padding: 6px 8px;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  transition: all 0.3s;
}

/* Color específico para cada tema */
.theme-btn[data-theme="morado"] {
  background: #7c3aed !important;
}

.theme-btn[data-theme="morado"]:hover {
  background: #6d28d9 !important;
}

.theme-btn[data-theme="verde"] {
  background: #10b981 !important;
}

.theme-btn[data-theme="verde"]:hover {
  background: #059669 !important;
}

.theme-btn[data-theme="azul"] {
  background: #3b82f6 !important;
}

.theme-btn[data-theme="azul"]:hover {
  background: #1d4ed8 !important;
}

.theme-btn[data-theme="rojo"] {
  background: #ef4444 !important;
}

.theme-btn[data-theme="rojo"]:hover {
  background: #dc2626 !important;
}

.theme-btn[data-theme="cian"] {
  background: #06b6d4 !important;
}

.theme-btn[data-theme="cian"]:hover {
  background: #0891b2 !important;
}

.theme-btn[data-theme="rosa"] {
  background: #ec4899 !important;
}

.theme-btn[data-theme="rosa"]:hover {
  background: #be185d !important;
}

.theme-btn[data-theme="negro"] {
  background: #111111 !important;
}

.theme-btn[data-theme="negro"]:hover {
  background: #000000 !important;
}

.theme-btn:hover {
  transform: scale(1.05);
}

.theme-btn.active {
  box-shadow: 0 0 10px currentColor !important;
  border: 2px solid white;
}

/* Toggle tema button - SIEMPRE MORADO */
.theme-toggle-btn {
  position: fixed;
  bottom: 100px;
  right: 20px;
  z-index: 50;
  padding: 10px 12px;
  background: #7c3aed !important;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s;
}

.theme-toggle-btn:hover {
  background: #6d28d9 !important;
}

/* Botones primarios - CAMBIAN CON TEMA */
.btn-primary {
  padding: 8px 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

/* Menu superior - CAMBIA CON TEMA */
.header-bar {
  position: fixed;
  top: 0;
  left: 0;
  padding: 15px 20px;
  background: var(--bg-dark);
  border-bottom: 2px solid var(--color-primary);
  border-right: 2px solid var(--color-primary);
  z-index: 500;
  border-radius: 0 0 8px 0;
}

/* Menu toggle button */
.menu-toggle {
  padding: 10px 15px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
  transition: background 0.3s;
}

.menu-toggle:hover {
  background: var(--color-primary-dark);
}

/* Navigation menu - CAMBIA CON TEMA */
.nav-menu {
  position: fixed;
  top: 60px;
  left: 20px;
  background: var(--bg-darker);
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  z-index: 1000;
  min-width: 200px;
}

.nav-menu-item {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.nav-menu-item:last-child {
  border-bottom: none;
}

.nav-menu-item:hover {
  background: var(--bg-hover);
}

.nav-menu-item.active {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* Queue bar - CAMBIA CON TEMA */
.queue-bar {
  position: fixed;
  top: 0;
  right: 0;
  width: 350px;
  padding: 15px 20px;
  background: var(--bg-darker);
  border-bottom: 2px solid var(--color-primary);
  border-left: 2px solid var(--color-primary);
  z-index: 500;
  border-radius: 0 0 0 8px;
  /* Deja espacio para el selector/boton de temas en la zona inferior derecha. */
  max-height: calc(100vh - 250px);
  overflow-y: auto;
}

.queue-bar h3 {
  margin: 0 0 10px 0;
  color: var(--text-primary);
  font-size: 14px;
}

.queue-artwork-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-dark);
}

.queue-artwork-cover {
  position: relative;
  overflow: hidden;
  width: 62px;
  height: 62px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--bg-hover) 100%);
  color: #fff;
  font-weight: bold;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.queue-artwork-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.queue-artwork-fallback {
  position: relative;
  z-index: 1;
}

.queue-artwork-cover.has-image .queue-artwork-image {
  display: block;
}

.queue-artwork-cover.has-image .queue-artwork-fallback {
  display: none;
}

.queue-artwork-meta {
  min-width: 0;
}

.queue-artwork-title {
  margin: 0;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-artwork-artist {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Form input - CAMBIA CON TEMA */
.form-input {
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 14px;
}

.form-input::placeholder {
  color: var(--text-muted);
}

select.form-input {
  padding: 6px;
}

select.form-input option {
  background: var(--bg-darker);
  color: var(--text-secondary);
}

/* Crear playlist section - CAMBIA CON TEMA */
.create-playlist-section {
  background: var(--bg-darker);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.create-playlist-section h3 {
  margin-top: 0;
  color: var(--text-secondary);
}

/* Menú de contexto dinámico - CAMBIA CON TEMA */
.context-menu {
  position: fixed;
  background: var(--bg-darker);
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  z-index: 10000;
  min-width: 200px;
}

.context-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background 0.2s;
}

.context-menu-item:hover {
  background: var(--bg-hover);
}

.context-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background: var(--bg-darker);
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.queue-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.queue-close-mobile {
  display: none;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 14px;
}

.main-content {
  min-width: 0;
}

.mobile-tabs {
  display: none;
}

body.mobile-ui {
  touch-action: manipulation;
}

.nav-mobile-only {
  display: none;
}

.nav-theme-picker {
  margin: 8px 12px 4px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-dark);
}

.nav-theme-title {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-theme-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.nav-theme-btn {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 0;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: bold;
}

.nav-theme-btn[data-theme="morado"] { background: #7c3aed; color: #fff; }
.nav-theme-btn[data-theme="verde"] { background: #10b981; color: #fff; }
.nav-theme-btn[data-theme="azul"] { background: #3b82f6; color: #fff; }
.nav-theme-btn[data-theme="rojo"] { background: #ef4444; color: #fff; }
.nav-theme-btn[data-theme="cian"] { background: #06b6d4; color: #fff; }
.nav-theme-btn[data-theme="rosa"] { background: #ec4899; color: #fff; }
.nav-theme-btn[data-theme="negro"] { background: #111111; color: #fff; }

body.mobile-ui .nav-mobile-only {
  display: block;
}

body.mobile-ui .main-content {
  margin: 72px 0 0 0 !important;
  padding: 10px 10px 130px !important;
}

body.mobile-ui h2 {
  margin: 8px 0 14px;
  font-size: 18px;
}

body.mobile-ui .group summary {
  padding: 13px 12px;
  font-size: 15px;
}

body.mobile-ui .song-list li {
  padding: 12px 12px 12px 16px;
  font-size: 15px;
}

body.mobile-ui .song-list li.playing {
  padding-left: 12px;
}

body.mobile-ui .queue-bar {
  left: 0;
  right: 0;
  top: auto;
  bottom: 58px;
  width: auto;
  max-height: calc(100vh - 150px);
  border-left: none;
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  padding: 10px 12px 85px;
  transform: translateY(100%);
  transition: transform 0.22s ease;
  z-index: 650;
}

body.mobile-ui .queue-bar.queue-open {
  transform: translateY(0);
}

body.mobile-ui .queue-close-mobile {
  display: inline-block;
}

body.mobile-ui #player-bar {
  bottom: 58px;
  padding: 8px 10px;
  gap: 8px;
  flex-wrap: wrap;
}

body.mobile-ui #now-playing {
  flex: 1 1 100%;
  font-size: 12px;
}

body.mobile-ui #player {
  flex: 1 1 100%;
  min-width: 0;
}

body.mobile-ui #btn-prev,
body.mobile-ui #btn-next {
  flex: 1;
  min-height: 40px;
  font-size: 13px;
}

body.mobile-ui .theme-toggle-btn {
  display: none;
}

body.mobile-ui .theme-selector {
  display: none;
}

body.mobile-ui .mobile-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 700;
  display: flex !important;
  justify-content: center;
  align-items: center;
  padding: 8px;
  background: var(--bg-darker);
  border-top: 1px solid var(--border-color);
}

body.mobile-ui .mobile-tab-btn {
  border: 1px solid var(--color-primary);
  border-radius: 9px;
  padding: 10px 22px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-hover);
  font-weight: bold;
}

@media (max-width: 900px) {
  .login-box {
    width: min(95vw, 420px);
    padding: 26px 18px;
  }

  #form-create-playlist {
    flex-direction: column;
  }
}

