/* Audio Player Styles */
.audio-player {
    position: fixed;
    bottom: 0 !important;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(30, 30, 30, 1), rgba(18, 18, 18, 1));
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), height 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
    display: none;
    margin: 0 !important;
    width: 100%;
    padding-bottom: 0 !important;
}

/* Light mode player background */
[data-theme="light"] .audio-player {
    background: linear-gradient(180deg, #ffffff 0%, #f5f7fa 100%);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.1);
}

.audio-player.active {
    transform: translateY(0);
}

.audio-player.closing {
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fade out elements when closing */
.audio-player.closing .player-progress-top,
.audio-player.closing .player-floating-buttons,
.audio-player.closing .player-content {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.audio-player.closing-fullscreen {
    transform: translateY(100vh);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.audio-player.quarter-size {
    height: 160px;
    bottom: 0;
}

.audio-player.fullscreen {
    height: calc(100dvh);
    padding-top: 0;
    overflow-y: auto;
    bottom: 0;
}

/* Add padding to body when player is active so footer is visible */
body.player-active {
    padding-bottom: 160px;
}

@media (max-width: 768px) {
    body.player-active {
        padding-bottom: 160px;
    }
}

/* Progress bar at the top of player */
.player-progress-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease, background 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Light mode progress bar */
[data-theme="light"] .player-progress-top {
    background: rgba(0, 0, 0, 0.08);
}

.audio-player.fullscreen .player-progress-top {
    opacity: 0;
    pointer-events: none;
}

.player-progress-fill {
    height: 100%;
    background: var(--accent-gold);
    width: 0%;
    transition: none;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.player-progress-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--accent-gold);
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.player-content {
    height: 100%;
    padding: 0 2rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Remove padding in fullscreen mode */
.audio-player.fullscreen .player-content {
    padding: 0;
}

.player-content.fade-out {
    opacity: 0;
}

/* Quarter Size Layout */
.audio-player.quarter-size .player-content {
    padding-top: 0.75rem;
}

.player-layout-small {
    display: grid;
    grid-template-columns: 260px 1fr auto;
    align-items: center;
    justify-items: center;
    column-gap: 2rem;
    height: 100%;
}

.player-info-small {
    display: flex;
    flex-direction: column;
    justify-content: center;
    justify-self: start;
    align-items: flex-start;
}

.player-info-small h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.player-info-small .time-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.player-row {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Player controls */
.player-controls-small {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    justify-self: center;
}

.control-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.control-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(201, 162, 39, 0.3);
}

.control-btn svg {
    width: 22px;
    height: 22px;
    color: var(--bg-primary);
}

.skip-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.skip-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.skip-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

/* Volume control */
.volume-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-self: end;
}

.volume-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
}

.volume-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.volume-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
    position: absolute;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.volume-btn svg.active {
    opacity: 1;
}

.volume-slider {
    width: 100px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, var(--accent-gold) 0%, var(--accent-gold) 70%, rgba(255, 255, 255, 0.2) 70%, rgba(255, 255, 255, 0.2) 100%);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-gold);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent-gold);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.volume-slider {
    background-size: 100% 100%;
}

.button-group {
    display: flex;
    align-items: center;
    gap: 8px;
    grid-column: auto;
}

.size-toggle-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, background-color 0.3s ease;
    position: relative;
}

.size-toggle-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.size-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: scale(1.05);
}

/* Fullscreen Layout */
.player-layout-large {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 3rem;
    padding: 0;
    position: relative;
}

.player-layout-large .button-group {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 10;
}

.audio-player.fullscreen .player-layout-small {
    display: none;
}

.audio-player.fullscreen .player-layout-large {
    display: flex;
}

.player-info-large {
    text-align: center;
}

.player-info-large h2 {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 700;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.player-info-large p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.player-controls-large {
    width: 100%;
    max-width: 700px;
}

.progress-section {
    margin-bottom: 2rem;
}

.time-display-large {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    color: var(--text-secondary);
}

.progress-bar-large {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: background 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Light mode large progress bar */
[data-theme="light"] .progress-bar-large {
    background: rgba(0, 0, 0, 0.08);
}

.progress-fill-large {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), #d4af37);
    border-radius: 4px;
    width: 0%;
    transition: none;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.progress-fill-large::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: var(--accent-gold);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.playback-controls-large {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.playback-controls-large .control-btn {
    width: 50px;
    height: 50px;
}

.playback-controls-large .control-btn svg {
    width: 28px;
    height: 28px;
}

.playback-controls-large .skip-btn {
    width: 80px;
    height: 80px;
}

.playback-controls-large .skip-btn svg {
    width: 40px;
    height: 40px;
}

.playback-controls-large .control-btn.play-pause {
    width: 80px;
    height: 80px;
}

.playback-controls-large .control-btn.play-pause svg {
    width: 36px;
    height: 36px;
}

.volume-control-large {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.volume-control-large .volume-slider {
    width: 150px;
    height: 8px;
}

.volume-control-large .volume-slider::-webkit-slider-thumb,
.volume-control-large .volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .player-layout-small {
        grid-template-columns: 250px 1fr auto;
    }
}

/* Hide floating buttons by default (desktop) */
.player-floating-buttons {
    display: none;
}

/* Mobile-specific compact player design */
@media (max-width: 768px) {
    /* Player height is set in base rule - removed 120px override */

    /* Floating buttons pill above player */
    .player-floating-buttons {
        position: absolute;
        bottom: calc(100% + 1.5px);
        right: 16px;
        display: flex;
        gap: 0;
        background: rgba(30, 30, 30, 1);
        padding: 0;
        border-radius: 6px 6px 0 0;
        z-index: 1;
        height: 44px;
    }


    /* Player content above floating buttons */
    .player-progress-top {
        z-index: 10;
        position: relative;
    }

    /* Light mode floating buttons */
    [data-theme="light"] .player-floating-buttons {
        background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    }

    .player-floating-buttons .size-toggle-btn,
    .player-floating-buttons .close-btn {
        width: 44px;
        height: 44px;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background-color 0.2s ease;
    }

    .player-floating-buttons .size-toggle-btn:hover,
    .player-floating-buttons .close-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    [data-theme="light"] .player-floating-buttons .size-toggle-btn:hover,
    [data-theme="light"] .player-floating-buttons .close-btn:hover {
        background: rgba(0, 0, 0, 0.05);
    }

    .player-floating-buttons .size-toggle-btn svg,
    .player-floating-buttons .close-btn svg {
        width: 20px;
        height: 20px;
        color: var(--text-primary);
    }

    /* Hide old action buttons in layout */
    .player-action-buttons {
        display: none !important;
    }

    .audio-player.quarter-size .player-content {
        padding: 16px;
        height: 100%;
        display: flex;
        align-items: center;
        box-sizing: border-box;
    }

    .player-layout-small {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 8px;
        height: 100%;
        width: 100%;
        padding: 0;
        box-sizing: border-box;
    }

    /* Row 1: Title + Time */
    .player-info-small {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        order: 1;
        gap: 12px;
    }

    /* Hide the player-right-section wrapper on mobile - time shows inline */
    .player-info-small .player-right-section {
        display: contents;
    }

    /* Hide the nested action buttons in player-right-section */
    .player-info-small .player-right-section .player-action-buttons {
        display: none;
    }

    /* Title container - flexible width extending to time display */
    .player-info-small h3 {
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--text-primary);
        margin: 0;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        position: relative;
    }

    /* Marquee swing animation for titles - slow and smooth - only when overflowing */
    .player-info-small h3 .player-title-text {
        display: inline-block;
        white-space: nowrap;
    }

    .player-info-small h3 .player-title-text.title-scrolls {
        animation: marquee-swing 25s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
    }

    /* Hide second title span - not needed for swing animation */
    .player-info-small h3 .player-title-text:nth-child(2) {
        display: none;
    }

    @keyframes marquee-swing {

        0%,
        15% {
            transform: translateX(0);
        }

        42.5%,
        57.5% {
            /* Scroll until right edge aligns with container right edge */
            /* -100% is text width, + visible-width is container width */
            transform: translateX(calc(-100% + var(--visible-width, 50vw)));
        }

        85%,
        100% {
            transform: translateX(0);
        }
    }

    .player-info-small .time-display {
        font-size: 0.8rem;
        color: var(--text-secondary);
        flex-shrink: 0;
        min-width: 85px;
        /* Reserve space for "00:00 / 00:00" format */
        font-variant-numeric: tabular-nums;
        /* Use fixed-width numbers */
        text-align: right;
        /* Align to right for consistent positioning */
    }

    /* Row 2: Controls centered */
    .player-controls-small {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 20px;
        order: 2;
        width: 100%;
    }

    .player-controls-small .skip-btn {
        width: 40px;
        height: 40px;
        padding: 0;
    }

    .player-controls-small .skip-btn svg {
        width: 18px;
        height: 18px;
    }

    .player-controls-small .control-btn {
        width: 52px;
        height: 52px;
    }

    .player-controls-small .control-btn svg {
        width: 24px;
        height: 24px;
    }

    /* Volume control - completely hidden on mobile */
    .volume-control {
        display: none;
    }

    /* Progress bar styling for mobile */
    .player-progress-top {
        height: 3px;
    }

    .player-progress-fill::after {
        width: 10px;
        height: 10px;
        right: -5px;
    }

    /* Fullscreen adjustments for mobile */
    .audio-player.fullscreen .player-floating-buttons {
        display: none;
    }

    .player-info-large h2 {
        font-size: 1.5rem;
    }

    .player-info-large p {
        font-size: 0.9rem;
    }

    .playback-controls-large {
        gap: 1.5rem;
    }

    .playback-controls-large .skip-btn {
        width: 56px;
        height: 56px;
    }

    .playback-controls-large .skip-btn svg {
        width: 28px;
        height: 28px;
    }

    .playback-controls-large .control-btn.play-pause {
        width: 64px;
        height: 64px;
    }

    .playback-controls-large .control-btn.play-pause svg {
        width: 28px;
        height: 28px;
    }

    .volume-control-large {
        display: none;
    }

    .player-layout-large {
        padding: 2rem;
        gap: 2rem;
    }

    .player-layout-large .button-group {
        top: 2rem;
        right: 2rem;
    }

    .player-layout-large .button-group .size-toggle-btn {
        width: 32px;
        height: 32px;
    }

    .player-layout-large .button-group .size-toggle-btn svg {
        width: 18px;
        height: 18px;
    }

    .progress-bar-large {
        height: 6px;
    }

    .progress-fill-large::after {
        width: 14px;
        height: 14px;
    }
}

/* Center play button (when player is first opened) */
.center-play-btn {
    position: fixed;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    width: 80px;
    height: 80px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 8px 24px rgba(201, 162, 39, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: none;
}

.center-play-btn.show {
    display: flex;
}

.center-play-btn:hover {
    transform: translate(-50%, 50%) scale(1.05);
    box-shadow: 0 12px 32px rgba(201, 162, 39, 0.5);
}

.center-play-btn svg {
    width: 36px;
    height: 36px;
    color: var(--bg-primary);
}

/* Mobile adjustments: Double height for progress bar and thumb */
@media (max-width: 768px) {
    .player-progress-top {
        height: 8px;
    }

    .player-progress-fill::after {
        width: 20px;
        height: 20px;
        right: -10px;
        /* Center it (half of width) */
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
    }
}