/* YouTube-style Audio Player */

.yt-audio-player {
    display: block !important;
    width: 100% !important;
    min-width: 400px !important;
    max-width: 600px !important;
    margin: 20px 0;
    position: relative;
}

/* Override Elementor widget constraints */
.elementor-widget-html .yt-audio-player,
.elementor-element .yt-audio-player {
    width: 100% !important;
    min-width: 400px !important;
    max-width: 600px !important;
    display: block !important;
}

.yt-audio-player-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    width: 100%;
    min-width: 400px;
    background: transparent;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

/* Audio bars wrapper - positioned around the play button */
.yt-audio-bars-wrapper {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 60px;
    pointer-events: none;
    z-index: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
}

.yt-audio-bars-left,
.yt-audio-bars-right {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 100%;
    flex: 1 1 auto;
    min-width: 0;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.yt-audio-bars-left.playing,
.yt-audio-bars-right.playing {
    visibility: visible !important;
    opacity: 1 !important;
}

.yt-audio-bars-left {
    justify-content: flex-end;
    padding-right: 15px;
    max-width: calc(50% - 40px);
}

.yt-audio-bars-right {
    justify-content: flex-start;
    padding-left: 15px;
    max-width: calc(50% - 40px);
}

.yt-audio-bar {
    flex: 1;
    min-width: 3px;
    max-width: 6px;
    background: linear-gradient(to top, #243B53, #3a5a7a) !important;
    background-color: #243B53 !important;
    border-radius: 2px;
    transform-origin: center;
    transform: scaleY(0.2);
    transition: transform 0.1s ease-out;
    min-height: 8px;
    max-height: 50px;
    opacity: 0.9 !important;
    visibility: visible !important;
    display: block !important;
}

/* Varying heights for visual interest */
.yt-audio-bar-1,
.yt-audio-bar-3,
.yt-audio-bar-5,
.yt-audio-bar-7,
.yt-audio-bar-9,
.yt-audio-bar-11,
.yt-audio-bar-13,
.yt-audio-bar-15,
.yt-audio-bar-17,
.yt-audio-bar-19 {
    height: 45px;
}

.yt-audio-bar-2,
.yt-audio-bar-4,
.yt-audio-bar-6,
.yt-audio-bar-8,
.yt-audio-bar-10,
.yt-audio-bar-12,
.yt-audio-bar-14,
.yt-audio-bar-16,
.yt-audio-bar-18,
.yt-audio-bar-20 {
    height: 40px;
}

/* Play button - centered */
.yt-audio-play-button {
    position: relative;
    z-index: 2;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid #243B53;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(36, 59, 83, 0.2);
    padding: 0;
    margin: 0;
    backdrop-filter: blur(10px);
}

.yt-audio-play-button:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(36, 59, 83, 0.3), 0 0 0 4px rgba(36, 59, 83, 0.1);
    border-color: #243B53;
}

.yt-audio-play-button:hover .yt-play-icon,
.yt-audio-play-button:hover .yt-pause-icon {
    fill: #243B53;
}

.yt-audio-play-button:active {
    transform: scale(1.02);
    box-shadow: 0 2px 12px rgba(36, 59, 83, 0.25);
}

.yt-audio-play-button:focus,
.yt-audio-play-button:focus-visible,
.yt-audio-play-button:focus-within {
    outline: 3px solid rgba(36, 59, 83, 0.4) !important;
    outline-color: rgba(36, 59, 83, 0.4) !important;
    outline-offset: 2px !important;
    background: rgba(255, 255, 255, 0.98) !important;
    background-color: rgba(255, 255, 255, 0.98) !important;
    border-color: #243B53 !important;
    box-shadow: 0 4px 16px rgba(36, 59, 83, 0.2) !important;
}

.yt-play-icon,
.yt-pause-icon {
    width: 32px;
    height: 32px;
    fill: #243B53;
    margin-left: 3px; /* Slight offset for visual centering */
    transition: fill 0.3s ease;
}

.yt-pause-icon {
    margin-left: 0;
}

/* Audio info - time display */
.yt-audio-info {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.yt-audio-time {
    font-size: 13px;
    font-weight: 500;
    color: #666;
    background: rgba(255, 255, 255, 0.85);
    padding: 5px 14px;
    border-radius: 16px;
    white-space: nowrap;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.yt-current-time {
    color: #243B53;
    font-weight: 600;
}

.yt-time-separator {
    color: #999;
    margin: 0 3px;
}

.yt-total-time {
    color: #666;
}

/* Responsive Design */
@media (max-width: 768px) {
    .yt-audio-player {
        max-width: 100%;
    }

    .yt-audio-player-container {
        min-height: 100px;
        padding: 15px;
        background: transparent;
    }

    .yt-audio-bars-wrapper {
        width: 100%;
        height: 50px;
        padding: 0;
    }
    
    .yt-audio-bars-left,
    .yt-audio-bars-right {
        max-width: calc(50% - 35px);
    }

    .yt-audio-bar {
        min-width: 2px;
        max-width: 5px;
        gap: 3px;
    }

    .yt-audio-bar-1,
    .yt-audio-bar-3,
    .yt-audio-bar-5,
    .yt-audio-bar-7,
    .yt-audio-bar-9,
    .yt-audio-bar-11,
    .yt-audio-bar-13,
    .yt-audio-bar-15,
    .yt-audio-bar-17,
    .yt-audio-bar-19 {
        height: 38px;
    }

    .yt-audio-bar-2,
    .yt-audio-bar-4,
    .yt-audio-bar-6,
    .yt-audio-bar-8,
    .yt-audio-bar-10,
    .yt-audio-bar-12,
    .yt-audio-bar-14,
    .yt-audio-bar-16,
    .yt-audio-bar-18,
    .yt-audio-bar-20 {
        height: 33px;
    }

    .yt-audio-play-button {
        width: 60px;
        height: 60px;
    }

    .yt-play-icon,
    .yt-pause-icon {
        width: 28px;
        height: 28px;
    }

    .yt-audio-time {
        font-size: 12px;
        padding: 3px 10px;
    }
}

@media (max-width: 480px) {
    .yt-audio-player-container {
        min-height: 90px;
        padding: 12px;
        background: transparent;
    }

    .yt-audio-bars-wrapper {
        width: 100%;
        height: 45px;
        padding: 0;
    }
    
    .yt-audio-bars-left,
    .yt-audio-bars-right {
        max-width: calc(50% - 30px);
    }

    .yt-audio-play-button {
        width: 55px;
        height: 55px;
    }

    .yt-play-icon,
    .yt-pause-icon {
        width: 24px;
        height: 24px;
    }
}

/* RTL Support */
[dir="rtl"] .yt-audio-play-button {
    margin-right: 3px;
    margin-left: 0;
}

[dir="rtl"] .yt-play-icon {
    margin-right: 3px;
    margin-left: 0;
    transform: scaleX(-1);
}

/* Accessibility */
.yt-audio-play-button:focus-visible {
    outline: 3px solid rgba(36, 59, 83, 0.5) !important;
    outline-color: rgba(36, 59, 83, 0.5) !important;
    outline-offset: 3px !important;
    background: rgba(255, 255, 255, 0.98) !important;
    background-color: rgba(255, 255, 255, 0.98) !important;
    border-color: #243B53 !important;
    box-shadow: 0 4px 16px rgba(36, 59, 83, 0.2) !important;
}

/* Override any theme or browser default button focus styles */
button.yt-audio-play-button:focus,
button.yt-audio-play-button:focus-visible,
button.yt-audio-play-button:active:focus,
button.yt-audio-play-button:focus-visible:focus {
    outline: 3px solid rgba(36, 59, 83, 0.4) !important;
    outline-color: rgba(36, 59, 83, 0.4) !important;
    outline-style: solid !important;
    outline-width: 3px !important;
    outline-offset: 2px !important;
    background: rgba(255, 255, 255, 0.98) !important;
    background-color: rgba(255, 255, 255, 0.98) !important;
    border-color: #243B53 !important;
    color: inherit !important;
    box-shadow: 0 4px 16px rgba(36, 59, 83, 0.2) !important;
}

/* Animation for bars when playing */
@keyframes barPulse {
    0%, 100% {
        transform: scaleY(0.2);
    }
    50% {
        transform: scaleY(1);
    }
}

/* Hide original audio elements */
audio:not(.yt-audio-element) {
    display: none !important;
}

/* Ensure no background appears on audio elements or player when active/playing */
.yt-audio-element,
.yt-audio-element:active,
.yt-audio-element:focus,
.yt-audio-element:playing,
audio.yt-audio-element,
audio.yt-audio-element:active,
audio.yt-audio-element:focus {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
}

/* Prevent any pink/red backgrounds from browser defaults or theme */
.yt-audio-player-container:has(.yt-audio-element:playing),
.yt-audio-player-container:has(.yt-audio-element[playing]),
.yt-audio-player:has(.yt-audio-element:playing),
.yt-audio-player:has(.yt-audio-element[playing]),
.yt-audio-player-container.playing,
.yt-audio-player.playing,
.yt-audio-player-container[data-playing],
.yt-audio-player[data-playing] {
    background: transparent !important;
    background-color: transparent !important;
}

/* Ensure container and wrapper stay transparent - but NOT bars */
.yt-audio-player,
.yt-audio-player-container {
    background: transparent !important;
    background-color: transparent !important;
}

/* Ensure bars wrapper stays transparent but bars are visible */
.yt-audio-bars-wrapper {
    background: transparent !important;
    background-color: transparent !important;
}

.yt-audio-bars-left,
.yt-audio-bars-right {
    background: transparent !important;
    background-color: transparent !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
}

.yt-audio-bar {
    visibility: visible !important;
    opacity: 0.9 !important;
    display: block !important;
    background: linear-gradient(to top, #243B53, #3a5a7a) !important;
    background-color: #243B53 !important;
    background-image: linear-gradient(to top, #243B53, #3a5a7a) !important;
}

/* Force bar background - highest priority */
.yt-audio-player .yt-audio-bar,
.yt-audio-player-container .yt-audio-bar,
.yt-audio-bars-left .yt-audio-bar,
.yt-audio-bars-right .yt-audio-bar {
    background: linear-gradient(to top, #243B53, #3a5a7a) !important;
    background-color: #243B53 !important;
    background-image: linear-gradient(to top, #243B53, #3a5a7a) !important;
}

/* Override any potential theme or browser styles */
.yt-audio-player-container::before,
.yt-audio-player-container::after,
.yt-audio-player::before,
.yt-audio-player::after {
    display: none !important;
    background: transparent !important;
}

