/* Wrapper-Ausrichtung */
.custom-audio-wrapper { margin: 1em 0; }
.custom-audio-wrapper.align-center { display: flex; justify-content: center; }
.custom-audio-wrapper.align-right  { display: flex; justify-content: flex-end; }

/* Player-Container */
.custom-audio-player {
  width: var(--player-width, 400px);
  max-width: 100%;
  background: var(--player-bg, #e6f7ff);
  border-radius: 12px;
  padding: 10px;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Kompaktansicht */
.custom-audio-player.compact { padding: 6px; gap: 6px; }

/* Metadaten-Zeile */
.custom-audio-player .audio-meta {
  font-size: 0.92em;
  color: var(--player-color, #0073e6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Controls-Zeile */
.custom-audio-player .controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

/* Runde Buttons (Normal Mode: fixed size, never shrink) */
.play-pause-btn,
.volume-btn,
.download-link {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  background: var(--player-color, #0073e6);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  text-decoration: none;
  flex: 0 0 auto !important; /* force fixed size */
}

/* Kompakt: kleinere Buttons, can shrink */
.custom-audio-player.compact .play-pause-btn,
.custom-audio-player.compact .volume-btn,
.custom-audio-player.compact .download-link {
  width: 28px;
  height: 28px;
  flex: 0 1 auto;
}

/* SVG-Icons */
.icon {
  width: 20px;
  height: 20px;
  display: block;
  color: var(--player-icon-color, #ffffff);
}
.custom-audio-player.compact .icon { width: 16px; height: 16px; }

/* Volume-Button is clickable */
.volume-btn {
  cursor: pointer;
  pointer-events: auto;
}

/* Zeit + Seekbar */
.current-time, .duration {
  flex: 0 0 auto;       /* fixed size, no flex grow/shrink */
  white-space: nowrap;  /* prevent wrapping */
  text-align: center;
  min-width: 28px;      /* safe minimum */
  font-size: 0.9em;
  color: var(--player-color, #0073e6);
}

.time-and-seek {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px; /* tightened */
}

/* Seekbar must give up space first */
.seek-bar {
  flex: 1 1 0;          /* flexible, shrinkable */
  min-width: 1px;       /* allow extreme shrink */
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--player-color, #0073e6) 0%, #ddd 0%);
  cursor: pointer;
}
.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--player-color, #0073e6);
  position: relative; z-index: 2; cursor: pointer;
}
.seek-bar::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--player-color, #0073e6);
  cursor: pointer;
}

/* Volume-Slider */
.volume-slider {
  width: 70px;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--player-color, #0073e6) 100%, #ddd 0%);
  cursor: pointer;
}

/* Align speaker + slider */
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.volume-wrap .volume-slider {
  margin-left: 0;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--player-icon-color, #ffffff);
  border: 2px solid var(--player-color, #0073e6);
  position: relative; z-index: 2; cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--player-icon-color, #ffffff);
  border: 2px solid var(--player-color, #0073e6);
  cursor: pointer;
}

/* Kompakt: Typo + Slider kürzer */
.custom-audio-player.compact .current-time,
.custom-audio-player.compact .duration { font-size: 0.82em; min-width: 34px; }
.custom-audio-player.compact .volume-slider { width: 50px; }

/* Fokus-Ringe */
.play-pause-btn:focus-visible,
.volume-btn:focus-visible,
.download-link:focus-visible,
.seek-bar:focus-visible,
.volume-slider:focus-visible {
  outline: 2px solid rgba(0,0,0,0.15);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(0,115,230,0.2);
}

/* =========================
   Responsive Fixes
========================= */
@media (max-width: 420px) {
  .custom-audio-player .controls {
    gap: 6px;
  }
  .custom-audio-player .volume-slider {
    width: 56px;
  }
  .custom-audio-player.compact .volume-slider {
    width: 40px;
  }
  .current-time, .duration {
    min-width: 20px;
    font-size: 0.8em;
  }
}

@media (max-width: 360px) {
  .custom-audio-player .controls {
    flex-wrap: wrap;
  }
  .custom-audio-player .time-and-seek {
    order: 2;
    flex: 1 1 100%;
    margin-top: 6px;
  }
}

/* Extreme narrow devices */
@media (max-width: 320px) {
  .play-pause-btn,
  .volume-btn,
  .download-link {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }
  .custom-audio-player.compact .play-pause-btn,
  .custom-audio-player.compact .volume-btn,
  .custom-audio-player.compact .download-link {
    width: 26px;
    height: 26px;
  }
  .icon {
    width: 18px;
    height: 18px;
  }
  .custom-audio-player.compact .icon {
    width: 14px;
    height: 14px;
  }
  .current-time, .duration {
    min-width: 18px;
    font-size: 0.75em;
  }
  .custom-audio-player .controls {
    gap: 4px;
  }
}

/* =========================================
   Ultra-kompakte Variante: .compact.dense
   (noch kleinere Buttons/Abstände, alles sonst unverändert)
========================================= */
.custom-audio-player.compact.dense { padding: 4px; gap: 4px; }

.custom-audio-player.compact.dense .play-pause-btn,
.custom-audio-player.compact.dense .volume-btn,
.custom-audio-player.compact.dense .download-link {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
}

.custom-audio-player.compact.dense .icon { width: 14px; height: 14px; }

.custom-audio-player.compact.dense .controls { gap: 4px; }
.custom-audio-player.compact.dense .time-and-seek { gap: 4px; }

.custom-audio-player.compact.dense .current-time,
.custom-audio-player.compact.dense .duration {
  font-size: 0.78em;
  min-width: 30px;
}

.custom-audio-player.compact.dense .seek-bar { height: 5px; }
.custom-audio-player.compact.dense .seek-bar::-webkit-slider-thumb { width: 10px; height: 10px; }
.custom-audio-player.compact.dense .seek-bar::-moz-range-thumb     { width: 10px; height: 10px; }

.custom-audio-player.compact.dense .volume-slider { width: 40px; height: 5px; }
.custom-audio-player.compact.dense .volume-slider::-webkit-slider-thumb { width: 10px; height: 10px; }
.custom-audio-player.compact.dense .volume-slider::-moz-range-thumb     { width: 10px; height: 10px; }

