/**
 * SunMoon Theme - Player & Rightbar Enhancement
 * Modern player with mobile support
 */

/* ================================================
   RIGHT BAR / PLAYER PANEL
   ================================================ */
#rightbar {
  position: fixed;
  right: 0;
  top: var(--header-height);
  width: 300px;
  height: calc(100vh - var(--header-height));
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  transition: transform var(--transition-normal);
}

#rightbar.rightbar-hidden {
  transform: translateX(100%);
}

/* Player Header */
#rightbar-header,
#rb_header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
}

#rightbar-header h4,
#rb_header h4 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#rightbar-minimize {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

#rightbar-minimize:hover {
  background: var(--bg-card);
  color: var(--primary);
}

/* Playlist Items */
#rb_current_playlist {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm);
}

#rb_current_playlist ul,
#rb_current_playlist .playlist-songs {
  list-style: none;
  padding: 0;
  margin: 0;
}

#rb_current_playlist li,
#rb_current_playlist .playlist-song {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

#rb_current_playlist li:hover,
#rb_current_playlist .playlist-song:hover {
  background: var(--bg-tertiary);
}

#rb_current_playlist li.active,
#rb_current_playlist .playlist-song.playing {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}

#rb_current_playlist li.active a,
#rb_current_playlist .playlist-song.playing a {
  color: var(--primary);
}

/* Song info in playlist */
#rb_current_playlist .song-info {
  flex: 1;
  min-width: 0;
}

#rb_current_playlist .song-title {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

#rb_current_playlist .song-artist {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

#rb_current_playlist .song-duration {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Now Playing Art */
.now-playing-art {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

/* ================================================
   PLAYER CONTROLS (Bottom)
   ================================================ */
.player-controls {
  display: flex;
  flex-direction: column;
  padding: var(--spacing-md);
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
}

/* Progress Bar */
.progress-container {
  margin-bottom: var(--spacing-sm);
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
}

.progress-bar .progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.progress-time {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

/* Control Buttons */
.player-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.player-buttons button,
.player-buttons .control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.player-buttons button:hover,
.player-buttons .control-btn:hover {
  background: var(--bg-card-hover);
  color: var(--primary);
}

.player-buttons .play-btn {
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: white;
}

.player-buttons .play-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.player-buttons .active-btn {
  background: var(--primary-light);
  color: var(--primary);
}

/* Volume Control */
.volume-control {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.volume-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: var(--bg-primary);
  border-radius: 2px;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ================================================
   RB ACTION MENU
   ================================================ */
#rb_action {
  display: flex;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

#rb_action li {
  display: inline-flex;
}

#rb_action a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

#rb_action a:hover {
  background: var(--primary);
  color: white;
}

#rb_action .submenu {
  position: absolute;
  right: 310px;
  top: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
}

/* ================================================
   LOCALPLAY CONTROLS
   ================================================ */
#localplay-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
}

#localplay-control img {
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

#localplay-control img:hover {
  opacity: 1;
}

/* ================================================
   RESPONSIVE PLAYER (MOBILE)
   ================================================ */
@media (max-width: 992px) {
  #rightbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: auto;
    max-height: 60vh;
    transform: translateY(calc(100% - 60px));
    border-left: none;
    border-top: 1px solid var(--border-color);
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    z-index: var(--z-fixed);
  }
  
  #rightbar.expanded,
  #rightbar:focus-within {
    transform: translateY(0);
  }
  
  #rightbar-header {
    cursor: pointer;
  }
  
  #rightbar.expanded #rb_current_playlist {
    min-height: 200px;
  }
  
  .player-buttons .play-btn {
    width: 48px;
    height: 48px;
  }
  
  .player-buttons button,
  .player-buttons .control-btn {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  #rightbar {
    transform: translateY(calc(100% - 50px));
  }
  
  .player-buttons {
    gap: var(--spacing-xs);
  }
  
  .player-buttons .play-btn {
    width: 44px;
    height: 44px;
  }
  
  .player-buttons button {
    width: 32px;
    height: 32px;
  }
}

/* ================================================
   MINI PLAYER TOGGLE
   ================================================ */
#webplayer-minimize {
  position: fixed;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  z-index: var(--z-fixed);
}

#webplayer-minimize a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-fast);
}

#webplayer-minimize a:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

/* ================================================
   WEB PLAYER EMBEDDED
   ================================================ */
#webplayer {
  background: var(--bg-secondary);
}

/* ================================================
   ANIMATIONS
   ================================================ */
@keyframes pulse-playing {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.now-playing-indicator {
  display: inline-flex;
  gap: 3px;
  margin-right: var(--spacing-xs);
}

.now-playing-indicator span {
  width: 3px;
  height: 12px;
  background: var(--primary);
  border-radius: 1px;
  animation: bars 0.8s ease infinite;
}

.now-playing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.now-playing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bars {
  0%, 100% { height: 4px; }
  50% { height: 12px; }
}

/* ================================================
   QUEUE ITEM ACTIONS
   ================================================ */
.queue-action {
  opacity: 0;
  transition: opacity var(--transition-fast);
}

#rb_current_playlist li:hover .queue-action,
#rb_current_playlist .playlist-song:hover .queue-action {
  opacity: 1;
}

.queue-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.queue-action-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.queue-action-btn.remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}