/* ════════════════════════════════════════════════════════════════════════════
   Music Widget — Chat-style generator + Background Player
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Music Generation Widget ─────────────────────────────────────────────── */

#music-gen-widget {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.mgw-presets {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.mgw-presets::-webkit-scrollbar { height: 0; }

.mgw-preset {
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid rgba(236, 72, 153, 0.15);
  background: rgba(236, 72, 153, 0.06);
  color: rgba(236, 72, 153, 0.7);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.mgw-preset:hover {
  background: rgba(236, 72, 153, 0.15);
  color: #ec4899;
  border-color: rgba(236, 72, 153, 0.3);
}

/* ── Chat Area ─────────────────────────────────────────────────────────────── */

.mgw-chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.06) transparent;
}

.mgw-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 200px;
  text-align: center;
}

.mgw-msg {
  display: flex;
  max-width: 92%;
}

.mgw-msg-user {
  align-self: flex-end;
}

.mgw-msg-assistant {
  align-self: flex-start;
}

.mgw-msg-bubble {
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.5;
  word-wrap: break-word;
}

.mgw-user-bubble {
  background: rgba(59, 130, 246, 0.15);
  color: rgba(165, 180, 252, 0.85);
  border-bottom-right-radius: 3px;
}

.mgw-asst-bubble {
  background: rgba(255, 255, 255, 0.03);
  color: #e2e8f0;
  border-bottom-left-radius: 3px;
  border: 1px solid rgba(236, 72, 153, 0.1);
}

.mgw-error-bubble {
  border-color: rgba(239, 68, 68, 0.2);
}

.mgw-prompt-used {
  font-size: 10px;
  color: #64748b;
  margin-bottom: 8px;
  font-style: italic;
  line-height: 1.4;
}

.mgw-gen-spinner {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ec4899;
  font-size: 12px;
  padding: 8px 0;
}

.mgw-gen-spinner i {
  font-size: 14px;
}

/* ── Inline Player ─────────────────────────────────────────────────────────── */

.mgw-inline-player {
  margin: 6px 0;
  padding: 8px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  border: 1px solid rgba(236, 72, 153, 0.12);
}

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

.mgw-ip-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.mgw-ip-play:hover {
  transform: scale(1.08);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.4);
}

.mgw-ip-wave {
  flex: 1;
  height: 32px;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.mgw-ip-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mgw-ip-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(51, 65, 85, 0.5);
  cursor: pointer;
}

.mgw-ip-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ec4899, #a855f7);
  border-radius: 0 2px 2px 0;
  transition: width 100ms linear;
}

.mgw-ip-time {
  font-size: 10px;
  font-family: 'Fira Code', monospace;
  color: #64748b;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 55px;
  text-align: right;
}

/* ── Actions ───────────────────────────────────────────────────────────────── */

.mgw-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.mgw-action-btn {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
  text-decoration: none;
}
.mgw-action-btn:hover {
  background: rgba(236, 72, 153, 0.12);
  color: #ec4899;
  border-color: rgba(236, 72, 153, 0.2);
}

/* ── Input Area ────────────────────────────────────────────────────────────── */

.mgw-input-area {
  border-top: 1px solid rgba(59, 130, 246, 0.1);
  background: rgba(10, 14, 26, 0.5);
  padding: 8px 12px 12px;
  flex-shrink: 0;
}

.mgw-duration-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.mgw-duration-label {
  font-size: 10px;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.mgw-duration-slider {
  flex: 1;
  accent-color: #ec4899;
  height: 4px;
}

.mgw-dur-val {
  font-size: 11px;
  font-family: 'Fira Code', monospace;
  color: #ec4899;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.mgw-input-row {
  display: flex;
  gap: 6px;
}

.mgw-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(236, 72, 153, 0.15);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: #e2e8f0;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.mgw-input:focus {
  border-color: rgba(236, 72, 153, 0.4);
}
.mgw-input::placeholder {
  color: #475569;
}

.mgw-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.mgw-send:hover:not(:disabled) {
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.3);
  transform: translateY(-1px);
}
.mgw-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mgw-btn-sm {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(51, 65, 85, 0.4);
  border: 1px solid rgba(59, 130, 246, 0.1);
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 11px;
  flex-shrink: 0;
}
.mgw-btn-sm:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}


/* ════════════════════════════════════════════════════════════════════════════
   Background Music Player — Bottom Bar
   ════════════════════════════════════════════════════════════════════════════ */

.bgp-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9990;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(59, 130, 246, 0.15);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', system-ui, sans-serif;
}

.bgp-bar.bgp-visible {
  transform: translateY(0);
}

.bgp-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  max-width: 100%;
  height: 56px;
}

/* ── Track Info ─────────────────────────────────────────────────────────────── */

.bgp-track-info {
  width: 180px;
  min-width: 120px;
  flex-shrink: 0;
  overflow: hidden;
}

.bgp-track-name {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bgp-track-meta {
  font-size: 10px;
  color: #64748b;
  margin-top: 1px;
}

/* ── Controls ──────────────────────────────────────────────────────────────── */

.bgp-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.bgp-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
  position: relative;
  flex-shrink: 0;
}
.bgp-btn:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
}

.bgp-btn-active {
  color: #ec4899 !important;
}

.bgp-btn-play {
  width: 36px;
  height: 36px;
  background: rgba(236, 72, 153, 0.12);
  border: 1px solid rgba(236, 72, 153, 0.2);
  color: #ec4899;
  font-size: 14px;
}
.bgp-btn-play:hover {
  background: rgba(236, 72, 153, 0.25);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.2);
}

.bgp-btn-close {
  width: 24px;
  height: 24px;
  font-size: 10px;
  border-radius: 4px;
}

.bgp-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ec4899;
  color: white;
  font-size: 8px;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Progress ──────────────────────────────────────────────────────────────── */

.bgp-progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.bgp-time {
  font-size: 10px;
  font-family: 'Fira Code', monospace;
  color: #64748b;
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.bgp-progress {
  flex: 1;
  height: 32px;
  background: rgba(30, 41, 59, 0.6);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.bgp-progress-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #ec4899, #a855f7);
  border-radius: 0 2px 2px 0;
  transition: width 100ms linear;
  z-index: 2;
}

.bgp-wave-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ── Right Section ─────────────────────────────────────────────────────────── */

.bgp-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.bgp-vol-slider {
  width: 70px;
  accent-color: #ec4899;
  height: 3px;
}

/* ── Playlist Panel ────────────────────────────────────────────────────────── */

.bgp-playlist-panel {
  position: absolute;
  bottom: 100%;
  right: 16px;
  width: 300px;
  max-height: 0;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(236, 72, 153, 0.15);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bgp-playlist-panel.bgp-panel-open {
  max-height: 320px;
}

.bgp-playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.bgp-playlist-header .bgp-btn {
  width: 24px;
  height: 24px;
  font-size: 10px;
  border-radius: 4px;
}

.bgp-playlist-items {
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.06) transparent;
}

.bgp-pl-empty {
  color: #475569;
  font-size: 12px;
  text-align: center;
  padding: 30px 16px;
}

.bgp-pl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(51, 65, 85, 0.2);
}
.bgp-pl-item:hover {
  background: rgba(236, 72, 153, 0.06);
}

.bgp-pl-active {
  background: rgba(236, 72, 153, 0.1) !important;
}
.bgp-pl-active .bgp-pl-name {
  color: #ec4899;
}

.bgp-pl-num {
  width: 20px;
  font-size: 10px;
  color: #475569;
  text-align: center;
  flex-shrink: 0;
}

.bgp-pl-name {
  flex: 1;
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.bgp-pl-remove {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.bgp-pl-remove:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .bgp-track-info {
    width: 100px;
    min-width: 80px;
  }
  .bgp-vol-slider {
    display: none;
  }
  .bgp-playlist-panel {
    right: 0;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .bgp-inner {
    padding: 6px 10px;
    gap: 6px;
  }
  .bgp-track-info {
    display: none;
  }
}
