@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

.custom-audio-player {
  /* Dynamic page accent color fallback */
  --player-accent: #74BCEE;

  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  font-family: 'Open Sans', sans-serif;
  box-sizing: border-box;
}

.custom-audio-player * {
  box-sizing: border-box;
}

.player-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
  background: transparent;
}

.player-album-art {
  width: 100px;
  height: 100px;
  margin: 4px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 8px 6px -6px rgba(0, 0, 0, 0.8);
}

.player-album-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.player-info-meta {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.player-title {
  color: var(--player-accent);
  font-family: "Times New Roman", Times, serif;
  font-size: 15px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-subinfo {
  color: var(--player-accent);
  font-family: "Times New Roman", Times, serif;
  font-size: 13px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Control Bar expanded to full tracklist width */
.player-control-bar {
  position: relative;
  width: calc(100% - 8px);
  height: 36px;
  margin: 6px 4px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(to bottom, #444444 0%, #222222 100%);
  border: 1px solid #222222;
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 3px rgba(0, 0, 0, 0.5);
}

.btn-control {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.btn-play::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent var(--player-accent);
}

.btn-pause::before {
  content: "";
  display: block;
  width: 8px;
  height: 10px;
  border-left: 3px solid var(--player-accent);
  border-right: 3px solid var(--player-accent);
}

.btn-prev::before {
  content: "◄◄";
  font-size: 10px;
  color: var(--player-accent);
}

.btn-next::before {
  content: "►►";
  font-size: 10px;
  color: var(--player-accent);
}

.btn-loop::before {
  content: "⟳";
  font-size: 14px;
  color: var(--player-accent);
}

.btn-loop.active::before {
  color: var(--player-accent);
  text-shadow: 0 0 4px var(--player-accent);
}

/* Progress Bar */
.player-progress-container {
  flex: 1;
  height: 8px;
  background-color: #222222;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  box-shadow: -1px -1px 0 rgba(0, 0, 0, 0.5), 1px 1px 0 rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-loaded {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background-color: #444444;
  border-radius: 4px;
}

.progress-played {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--player-accent);
  border-radius: 4px;
}

/* Volume Control */
.player-volume-container {
  position: relative;
}

.btn-volume::before {
  content: "🕪";
  font-size: 14px;
  color: var(--player-accent);
}

/* Switches symbol when volume is 20% or less */
.btn-volume.low-volume::before {
  content: "🕩";
}

.volume-popover {
  display: none;
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 80px;
  padding: 8px;
  background: linear-gradient(to bottom, #444444 0%, #111111 100%);
  border: 1px solid #222222;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 3px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

/* Invisible bridge so moving the cursor from button to popover maintains hover status */
.volume-popover::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 10px; /* Covers mouse transit zone */
  background: transparent;
}

.player-volume-container:hover .volume-popover,
.player-volume-container.is-dragging .volume-popover {
  display: block;
}

.volume-track {
  width: 100%;
  height: 100%;
  background-color: #222222;
  position: relative;
  cursor: pointer;
  box-shadow: -1px -1px 0 rgba(0, 0, 0, 0.5), 1px 1px 0 rgba(255, 255, 255, 0.1);
}

.volume-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--player-accent);
  box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.5);
}

/* Tracklist */
.player-tracklist-wrapper {
  margin: 4px;
  padding: 12px 12px 16px;
  background: linear-gradient(to bottom, #444444 0%, #111111 100%);
  border: 1px solid #222222;
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 3px rgba(0, 0, 0, 0.5);
}

.player-tracklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.player-track-item {
  color: var(--player-accent);
  font-size: 13px;
  line-height: 28px;
  padding: 2px 10px;
  cursor: pointer;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.8);
  transition: background 0.15s ease, color 0.15s ease;
  border-radius: 2px;
}

.player-track-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Black to grey gradient highlight for selected track */
.player-track-item.active {
  background: linear-gradient(to bottom, #000000 0%, #3a3a3a 50%, #000000 100%);
  color: var(--player-accent);
  font-weight: bold;
}

.player-track-item b {
  color: inherit;
}

/* Floating Miniplayer (100x100) */
.mini-player-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 100px;
  height: 100px;
  background: #111111;
  border: 1px solid var(--player-accent, #74BCEE);
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.8);
  z-index: 9999;
  cursor: grab;
  user-select: none;
  overflow: hidden;
}

.mini-player-container:active {
  cursor: grabbing;
}

.mini-art-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.mini-art-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mini-overlay-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.mini-close-btn {
  position: absolute;
  top: 2px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: none;
  font-size: 14px;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-close-btn:hover {
  background: #ff4444;
}

.mini-return-btn {
  position: absolute;
  top: 2px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: none;
  font-size: 11px;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-return-btn:hover {
  background: var(--player-accent, #74BCEE);
  color: #000;
}