/**
 * Audio Player Widget CSS
 */
.audio-player-wrapper {
    display: inline-block;
    text-align: center;
    width: 100%;
}

.audio-player-wrapper.whatsapp-wrapper {
    display: block;
    width: 100%;
}

.audio-player-icon {
    display: inline-block;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    position: relative;
    min-width: 1em;
    min-height: 1em;
    /* Stelle sicher, dass Icon-Farben nicht überschrieben werden */
    color: inherit;
}

.audio-player-icon-play,
.audio-player-icon-pause {
    display: inline-block;
    transition: opacity 0.2s ease;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 1;
    /* Stelle sicher, dass die Farbe vererbt wird */
    color: inherit;
}

/* Für Icons */
.audio-player-icon-play i,
.audio-player-icon-pause i {
    display: inline-block;
    line-height: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Für SVG-Icons (Elementor verwendet SVG) */
.audio-player-icon-play svg,
.audio-player-icon-pause svg {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
    fill: currentColor;
}

/* SVG-Pfade direkt ansprechen für Farben */
.audio-player-icon-play svg path,
.audio-player-icon-pause svg path {
    fill: currentColor;
}

/* SVG-Polygon und andere Formen */
.audio-player-icon-play svg polygon,
.audio-player-icon-pause svg polygon,
.audio-player-icon-play svg circle,
.audio-player-icon-pause svg circle,
.audio-player-icon-play svg rect,
.audio-player-icon-pause svg rect,
.audio-player-icon-play svg ellipse,
.audio-player-icon-pause svg ellipse {
    fill: currentColor;
}

/* Für Bilder */
.audio-player-icon-play img,
.audio-player-icon-pause img {
    display: block;
    max-width: 100%;
    height: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.audio-player-icon:hover {
    opacity: 0.8;
}

.audio-player-icon:hover .audio-player-icon-play,
.audio-player-icon:hover .audio-player-icon-pause {
    transform: translate(-50%, -50%) scale(1.1);
}

.audio-player-icon.playing {
    /* Animation kann hier hinzugefügt werden, wenn gewünscht */
}

.audio-player-icon img {
    max-width: 100%;
    height: auto;
    display: block;
    transition: all 0.3s ease;
}

.audio-player-icon:hover img {
    transform: scale(1.1);
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Elementor Editor Anpassungen */
.elementor-editor-active .audio-player-icon {
    pointer-events: auto;
}

/* WhatsApp Style Player */
.whatsapp-audio-player {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background-color: #dcf8c6;
    border-radius: 7.5px;
    width: 100%;
    max-width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-sizing: border-box;
}


/* Profilbild Positionierung */
.whatsapp-audio-player[style*="flex-direction: row"] .whatsapp-profile-image {
    margin-right: 12px;
    margin-bottom: 0;
}

.whatsapp-audio-player[style*="flex-direction: row-reverse"] .whatsapp-profile-image {
    margin-left: 12px;
    margin-right: 0;
    margin-bottom: 0;
}

.whatsapp-audio-player[style*="flex-direction: column"] {
    align-items: center;
}

.whatsapp-audio-player[style*="flex-direction: column"] .whatsapp-profile-image {
    margin-right: 0;
    margin-bottom: 12px;
    align-self: center;
}

.whatsapp-audio-player[style*="flex-direction: column"] .whatsapp-audio-content {
    width: 100%;
    justify-content: center;
}

.whatsapp-profile-image {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #e0e0e0;
}

.whatsapp-profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.whatsapp-audio-content {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

/* Stelle sicher, dass Play-Button und Audio-Info vertikal zentriert sind */
.whatsapp-play-button,
.whatsapp-audio-info {
    align-self: center;
}

.whatsapp-play-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #25d366;
}

.whatsapp-play-button:hover {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.whatsapp-play-button svg {
    width: 16px;
    height: 16px;
    margin-left: 2px; /* Zentriert das Play-Icon optisch */
}

.whatsapp-play-button.playing svg {
    display: none;
}

.whatsapp-play-button.playing::after {
    content: '';
    width: 12px;
    height: 12px;
    border-left: 4px solid currentColor;
    border-right: 4px solid currentColor;
    box-sizing: border-box;
}

.whatsapp-audio-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    justify-content: center;
    position: relative;
    align-items: flex-start;
    min-height: 32px; /* Gleiche Höhe wie Play-Button */
}

.whatsapp-audio-time {
    font-size: 12px;
    font-weight: 500;
    color: inherit;
    line-height: 1;
    flex-shrink: 0;
    white-space: nowrap;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.whatsapp-audio-time .current-time,
.whatsapp-audio-time .total-duration,
.whatsapp-audio-time .duration-separator {
    color: inherit;
}

.whatsapp-audio-time .duration-separator {
    opacity: 0.7;
    margin: 0 2px;
}

.whatsapp-audio-waveform {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    height: 20px;
    width: 100%;
    flex: 0 0 auto;
    min-width: 0;
    max-width: 100%;
    margin: auto 0;
    position: relative;
    /* Zentriere die Wellenform vertikal: Die Mitte der Wellenform (10px von oben bei 20px Höhe) 
       soll mit der Mitte des Play-Buttons (16px von oben bei 32px Höhe) übereinstimmen */
    align-self: center;
}

.whatsapp-audio-waveform .wave-bar {
    flex: 1 1 0;
    min-width: 2px;
    min-height: 4px;
    height: 50%;
    background-color: #25d366;
    border-radius: 2px;
    transition: height 0.3s ease, max-height 0.3s ease, max-width 0.3s ease;
    animation: waveAnimation 1.2s ease-in-out infinite;
    align-self: flex-end;
}

/* Dynamische Animation-Delays für variable Anzahl von Segmenten */
.whatsapp-audio-waveform .wave-bar:nth-child(1) {
    animation-delay: 0s;
}

.whatsapp-audio-waveform .wave-bar:nth-child(2) {
    animation-delay: 0.15s;
}

.whatsapp-audio-waveform .wave-bar:nth-child(3) {
    animation-delay: 0.3s;
}

.whatsapp-audio-waveform .wave-bar:nth-child(4) {
    animation-delay: 0.45s;
}

.whatsapp-audio-waveform .wave-bar:nth-child(5) {
    animation-delay: 0.6s;
}

.whatsapp-audio-waveform .wave-bar:nth-child(6) {
    animation-delay: 0.75s;
}

.whatsapp-audio-waveform .wave-bar:nth-child(7) {
    animation-delay: 0.9s;
}

.whatsapp-audio-waveform .wave-bar:nth-child(8) {
    animation-delay: 1.05s;
}

/* Für mehr als 8 Segmente: Wiederhole das Muster */
.whatsapp-audio-waveform .wave-bar:nth-child(n+9) {
    animation-delay: calc((var(--segment-index, 0) * 0.15s) % 1.2s);
}

.whatsapp-audio-player.playing .whatsapp-audio-waveform .wave-bar {
    animation-play-state: running;
}

.whatsapp-audio-player:not(.playing) .whatsapp-audio-waveform .wave-bar {
    animation-play-state: paused;
    height: 4px !important;
    min-height: 4px;
}

@keyframes waveAnimation {
    0%, 100% {
        transform: scaleY(0.5);
    }
    50% {
        transform: scaleY(1);
    }
}

/* Responsive Anpassungen */
@media (max-width: 768px) {
    .audio-player-icon {
        font-size: 40px !important;
    }
    
    .audio-player-icon img {
        max-width: 40px !important;
        height: auto !important;
    }
    
    .whatsapp-audio-player {
        width: 100%;
        max-width: 100%;
        padding: 10px 14px;
    }
    
    .whatsapp-profile-image {
        width: 36px;
        height: 36px;
        margin-right: 10px;
    }
    
    .whatsapp-play-button {
        width: 28px;
        height: 28px;
        margin-right: 10px;
    }
    
    .whatsapp-play-button svg {
        width: 14px;
        height: 14px;
    }
}

