/* ==========================================================================
   DISCREET COMMUNITY BGM PLAYER (V2 - ULTRA SLEEK & REFINED)
   Zero Ads • Zero YouTube Iframes • Zero Jitter • Premium Audio Glassmorphism
   ========================================================================== */

:root {
  --bgm-card-bg: rgba(12, 14, 22, 0.96);
  --bgm-pill-bg: rgba(14, 17, 26, 0.92);
  --bgm-border: rgba(255, 255, 255, 0.09);
  --bgm-border-hover: rgba(255, 255, 255, 0.2);
  --bgm-accent: #ff384d;
  --bgm-accent-gradient: linear-gradient(135deg, #ff4d61 0%, #d60017 100%);
  --bgm-accent-glow: rgba(255, 56, 77, 0.35);
  --bgm-text-primary: #f8fafc;
  --bgm-text-muted: #94a3b8;
  --bgm-card-w: 324px;
}

/* 1. Floating Collapsed Pill (Discreet, Fixed Bottom-Right) */
.bgm-dock {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.bgm-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bgm-pill-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--bgm-border);
  padding: 0.38rem 0.55rem 0.38rem 0.75rem;
  border-radius: 9999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.bgm-pill:hover {
  border-color: rgba(255, 56, 77, 0.45);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.75), 0 0 14px rgba(255, 56, 77, 0.18);
}

/* Soundwave Animation */
.bgm-soundwave {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 14px;
  width: 14px;
  justify-content: center;
  flex-shrink: 0;
}

.bgm-soundwave span {
  display: inline-block;
  width: 2px;
  height: 4px;
  background: var(--bgm-text-muted);
  border-radius: 2px;
  transition: background 0.2s ease;
}

.bgm-dock.playing .bgm-soundwave span {
  background: var(--bgm-accent);
  animation: bgmWaveAnim 1.1s infinite ease-in-out alternate;
}

.bgm-dock.playing .bgm-soundwave span:nth-child(1) { animation-delay: 0.05s; }
.bgm-dock.playing .bgm-soundwave span:nth-child(2) { animation-delay: 0.35s; }
.bgm-dock.playing .bgm-soundwave span:nth-child(3) { animation-delay: 0.15s; }
.bgm-dock.playing .bgm-soundwave span:nth-child(4) { animation-delay: 0.45s; }

@keyframes bgmWaveAnim {
  0% { height: 3px; }
  50% { height: 13px; }
  100% { height: 4px; }
}

.bgm-pill-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.bgm-pill-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bgm-text-primary);
  max-width: 155px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bgm-pill-sub {
  font-size: 0.64rem;
  color: var(--bgm-text-muted);
}

.bgm-pill-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  margin: 0;
  line-height: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

.bgm-pill-btn:hover {
  background: var(--bgm-accent);
  border-color: var(--bgm-accent);
  box-shadow: 0 0 10px var(--bgm-accent-glow);
}

.bgm-pill-btn svg {
  width: 12px;
  height: 12px;
  display: block;
  fill: currentColor;
  transition: transform 0.15s ease;
}

/* Centrage optique du triangle Play dans un bouton rond */
.bgm-dock:not(.playing) .bgm-pill-btn svg {
  transform: translateX(1px);
}
.bgm-dock.playing .bgm-pill-btn svg {
  transform: none;
}

/* 2. Expanded Floating Card */
.bgm-card {
  position: absolute;
  bottom: 0;
  right: 0;
  width: var(--bgm-card-w);
  background: var(--bgm-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--bgm-border);
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.bgm-dock.expanded .bgm-pill {
  display: none;
}

.bgm-dock.expanded .bgm-card {
  display: flex;
}

/* Card Header */
.bgm-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.bgm-head-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.bgm-head-artist {
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s ease;
}

.bgm-head-artist:hover {
  color: #fff;
}

.bgm-head-artist svg {
  color: var(--bgm-text-muted);
  transition: color 0.15s ease;
}

.bgm-head-artist:hover svg {
  color: #fff;
}

.bgm-head-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--bgm-text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  padding: 0;
  margin: 0;
  line-height: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

.bgm-head-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.bgm-head-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* Card Visual Banner (Track details & YouTube button) */
.bgm-visual-banner {
  padding: 0.95rem 1rem;
  background: linear-gradient(135deg, rgba(230, 0, 18, 0.12) 0%, rgba(15, 18, 28, 0.9) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.bgm-visual-info {
  min-width: 0;
  flex: 1;
}

.bgm-visual-game {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #ff6b7a;
  margin-bottom: 0.2rem;
}

.bgm-visual-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

/* Sleek YouTube Pill Button */
.bgm-yt-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.32rem 0.62rem;
  border-radius: 9999px;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.bgm-yt-link-btn:hover {
  background: #ff0000;
  border-color: #ff0000;
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 0, 0, 0.4);
}

.bgm-yt-link-btn svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

/* Progress Area */
.bgm-progress-box {
  padding: 0.65rem 1rem 0.25rem 1rem;
}

.bgm-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  cursor: pointer;
  position: relative;
  transition: height 0.15s ease;
}

.bgm-progress-bar:hover {
  height: 6px;
}

.bgm-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--bgm-accent-gradient);
  border-radius: 9999px;
  pointer-events: none;
  box-shadow: 0 0 8px var(--bgm-accent-glow);
}

.bgm-time-strip {
  display: flex;
  justify-content: space-between;
  font-size: 0.66rem;
  color: var(--bgm-text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 0.35rem;
}

/* Main Controls (Redesigned & Balanced) */
.bgm-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem 0.65rem 1rem;
}

.bgm-ctrl {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  padding: 0;
  margin: 0;
  line-height: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

.bgm-ctrl:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: scale(1.05);
}

.bgm-ctrl:active {
  transform: scale(0.95);
}

.bgm-ctrl.active {
  color: var(--bgm-accent);
  background: rgba(255, 56, 77, 0.14);
  border-color: rgba(255, 56, 77, 0.4);
  box-shadow: 0 0 10px rgba(255, 56, 77, 0.2);
}

.bgm-ctrl svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

/* Central Play Button */
.bgm-play-circle {
  width: 44px;
  height: 44px;
  background: var(--bgm-accent-gradient);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px var(--bgm-accent-glow);
  cursor: pointer;
  transition: box-shadow 0.2s ease, filter 0.2s ease, transform 0.15s ease;
  padding: 0;
  margin: 0;
  line-height: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

.bgm-play-circle:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(255, 56, 77, 0.55);
  transform: scale(1.06);
}

.bgm-play-circle:active {
  transform: scale(0.96);
}

.bgm-play-circle svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: #fff;
  transition: transform 0.15s ease;
}

/* Centrage optique du triangle de lecture Play */
.bgm-dock:not(.playing) .bgm-play-circle svg {
  transform: translateX(1.5px);
}
.bgm-dock.playing .bgm-play-circle svg {
  transform: none;
}

/* ==========================================================================
   ENHANCED VOLUME BAR (Spotify-Style Smooth Track & Interactive Mute Button)
   ========================================================================== */
.bgm-volume-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 1rem 0.85rem 1rem;
}

.bgm-vol-btn {
  background: transparent;
  border: none;
  color: var(--bgm-text-muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease;
  padding: 0;
  margin: 0;
  line-height: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

.bgm-vol-btn:hover {
  color: #fff;
}

.bgm-vol-btn svg {
  width: 16px;
  height: 16px;
}

.bgm-vol-slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}

.bgm-vol-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(to right, var(--bgm-accent) 0%, var(--bgm-accent) 25%, rgba(255, 255, 255, 0.12) 25%, rgba(255, 255, 255, 0.12) 100%);
  transition: height 0.15s ease;
}

.bgm-vol-slider:hover {
  height: 6px;
}

.bgm-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.bgm-vol-slider::-webkit-slider-thumb:hover {
  background: #ff4d61;
  box-shadow: 0 0 8px rgba(255, 56, 77, 0.6);
}

.bgm-vol-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.bgm-vol-val {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--bgm-text-muted);
  font-variant-numeric: tabular-nums;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* 3. Playlist Drawer */
.bgm-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(8, 10, 16, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bgm-card.show-drawer .bgm-drawer {
  max-height: 230px;
  overflow-y: auto;
}

.bgm-drawer::-webkit-scrollbar {
  width: 4px;
}

.bgm-drawer::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.bgm-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  transition: background 0.12s ease;
}

.bgm-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.bgm-item.active {
  background: rgba(255, 56, 77, 0.12);
  border-left: 3px solid var(--bgm-accent);
}

.bgm-item-idx {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bgm-text-muted);
  font-variant-numeric: tabular-nums;
  width: 16px;
  flex-shrink: 0;
}

.bgm-item.active .bgm-item-idx {
  color: var(--bgm-accent);
}

.bgm-item-text {
  flex: 1;
  min-width: 0;
}

.bgm-item-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bgm-item.active .bgm-item-title {
  color: #fff;
  font-weight: 700;
}

.bgm-item-sub {
  font-size: 0.64rem;
  color: var(--bgm-text-muted);
}

.bgm-item-link {
  color: var(--bgm-text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  line-height: 0;
  box-sizing: border-box;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.bgm-item-link:hover {
  color: #ff0000;
  background: rgba(255, 0, 0, 0.12);
  transform: scale(1.1);
}

.bgm-item-link svg {
  width: 14px;
  height: 14px;
  display: block;
  fill: currentColor;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .bgm-dock {
    bottom: 16px;
    right: 16px;
  }
  .bgm-card {
    width: min(310px, calc(100vw - 32px));
  }
}
