/* Audio Player Styles */
.audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    transition: transform 0.3s ease, opacity 0.3s ease;
    padding: 20px 1rem;
    color: white;
    max-height: 140px;
    /* Default to minimized state */
    transform: translateY(calc(100% - 5px));
}

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

.audio-player.collapsed {
    transform: translateY(calc(100% - 5px));
}

/* Visible strip when collapsed */
.audio-player::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: #1e40af;
    z-index: -1;
}

.player-toggle {
    position: absolute;
    top: -20px;
    right: 16px;
    z-index: 999;
    width: 32px;
    height: 32px;
    background: #3366cc;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.player-toggle:hover {
    background: #2563eb;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.player-toggle:active {
    transform: scale(0.95);
}

.player-toggle svg {
    transition: transform 0.2s ease;
}

.audio-player.collapsed .player-toggle svg {
    transform: rotate(180deg);
}

.player-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    height: 100px;
}

/* Thumbnail - Consistent size */
.episode-thumbnail {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.episode-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Playback Controls - Inline with thumbnail */
.playback-controls {
    display: flex;
    align-items: center;
    height: 100px;
    flex-shrink: 0;
    margin-left: 12px;
}

.main-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.control-btn:active {
    transform: scale(0.95);
}

#rewind-btn,
#forward-btn {
    width: 52px;
    height: 52px;
}

#play-pause-btn {
    background: white;
    color: #1e40af;
    width: 72px;
    height: 72px;
    border: none;
    margin: 0 8px;
}

#play-pause-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    color: #1d4ed8;
    transform: scale(1.05);
}

/* Episode Info Section - Full width progress layout */
.episode-info-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100px;
    min-width: 0;
    padding: 0 16px;
    text-align: center;
}

.episode-header {
    margin-bottom: 12px;
    width: 100%;
}

.episode-title-display {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

/* Progress Row - Full width layout as specified */
.progress-section {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 16px;
    box-sizing: border-box;
}

.time-display {
    width: 45px;
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    flex-shrink: 0;
}

.progress-bar {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    height: 20px;
    margin: 0 8px;
}

.progress-track {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: white;
    border-radius: 3px;
    transition: width 0.1s ease;
    width: 0%;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.progress-slider {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 20px;
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.progress-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.progress-bar:hover .progress-slider::-webkit-slider-thumb,
.progress-bar:hover .progress-slider::-moz-range-thumb {
    opacity: 1;
}

/* Player Actions - Better spacing and alignment */
.player-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    height: 100px;
    padding-right: 8px;
}

.actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-slider-container {
    width: 80px;
}

.volume-slider {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

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

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

.speed-control {
    position: relative;
}

.speed-btn {
    min-width: 44px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
    height: 40px;
}

.speed-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.speed-dropdown {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 8px 0;
    margin-bottom: 8px;
    display: none;
    z-index: 1003;
    min-width: 90px;
}

.speed-dropdown.show {
    display: block;
}

.speed-option {
    padding: 8px 16px;
    color: #1f2937;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.speed-option:hover {
    background: #f3f4f6;
}

.speed-option.active {
    background: #eff6ff;
    color: #1e40af;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .player-container {
        gap: 16px;
        height: 90px;
    }

    .episode-thumbnail {
        width: 90px;
        height: 90px;
    }

    .playback-controls,
    .episode-info-section,
    .player-actions {
        height: 90px;
    }

    .episode-info-section {
        padding: 0 12px;
    }

    .progress-section {
        padding: 0 12px;
    }

    #play-pause-btn {
        width: 64px;
        height: 64px;
    }

    #rewind-btn,
    #forward-btn {
        width: 48px;
        height: 48px;
    }

    .episode-title-display {
        font-size: 1rem;
    }

    .audio-player {
        max-height: 130px;
        padding: 16px 1rem;
    }
}

@media (max-width: 768px) {
    .audio-player {
        padding: 14px 0.75rem;
        max-height: 120px;
    }

    .player-container {
        gap: 12px;
        height: 80px;
    }

    .episode-thumbnail {
        width: 80px;
        height: 80px;
        border-radius: 10px;
    }

    .playback-controls,
    .episode-info-section,
    .player-actions {
        height: 80px;
    }

    .episode-info-section {
        padding: 0 8px;
    }

    .progress-section {
        padding: 0 8px;
    }

    #play-pause-btn {
        width: 56px;
        height: 56px;
    }

    #rewind-btn,
    #forward-btn {
        width: 44px;
        height: 44px;
    }

    .main-controls {
        gap: 8px;
    }

    .action-btn {
        width: 36px;
        height: 36px;
        padding: 8px;
    }

    .speed-btn {
        height: 36px;
        padding: 6px 8px;
        min-width: 40px;
        font-size: 0.75rem;
    }

    .episode-title-display {
        font-size: 0.95rem;
    }

    .time-display {
        width: 40px;
        font-size: 11px;
    }

    .volume-slider-container {
        width: 70px;
    }

    .actions-row {
        gap: 6px;
    }

    .player-actions {
        gap: 6px;
    }
}

/* MOBILE PORTRAIT ORIENTATION - SIMPLIFIED VERTICAL LAYOUT */
@media screen and (orientation: portrait) and (max-width: 480px) {
    .audio-player {
        padding: 12px 0.75rem;
        max-height: 180px; /* Increased height for vertical layout */
    }

    .player-container {
        flex-direction: column;
        height: auto;
        gap: 8px;
        align-items: center;
        justify-content: flex-start;
    }

    /* Top row: thumbnail + main controls (play/pause) */
    .mobile-top-row {
        display: flex;
        align-items: center;
        gap: 16px;
        width: 100%;
        justify-content: center;
        margin-bottom: 8px;
    }

    .episode-thumbnail {
        width: 60px;
        height: 60px;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .playback-controls {
        height: auto;
        flex: 0;
        margin-left: 0;
        justify-content: center;
    }

    .main-controls {
        justify-content: center;
        gap: 8px;
        align-items: center;
    }

    #play-pause-btn {
        width: 48px;
        height: 48px;
        margin: 0;
    }

    #rewind-btn,
    #forward-btn {
        width: 36px;
        height: 36px;
    }

    /* Episode info section - centered and compact */
    .episode-info-section {
        height: auto;
        padding: 0;
        width: 100%;
        text-align: center;
        align-items: center;
        margin-bottom: 8px;
    }

    .episode-header {
        margin-bottom: 6px;
        width: 100%;
    }

    .episode-title-display {
        font-size: 0.85rem;
        margin-bottom: 0;
        line-height: 1.2;
    }

    /* Progress section - full width */
    .progress-section {
        padding: 0 12px;
        margin-bottom: 8px;
        width: 100%;
        box-sizing: border-box;
    }

    .time-display {
        width: 32px;
        font-size: 10px;
    }

    .progress-bar {
        margin: 0 6px;
    }

    /* Player actions - horizontal row at bottom */
    .player-actions {
        height: auto;
        width: 100%;
        justify-content: center;
        padding-right: 0;
        margin-top: 4px;
    }

    .actions-row {
        gap: 8px;
        justify-content: center;
        align-items: center;
    }

    .action-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    .speed-btn {
        height: 32px;
        padding: 4px 6px;
        min-width: 36px;
        font-size: 0.7rem;
    }

    .volume-slider-container {
        width: 50px;
    }

    .volume-control {
        gap: 4px;
    }

    .player-toggle {
        width: 28px;
        height: 28px;
        top: -16px;
        right: 12px;
    }

    /* Ensure no overlap by creating proper stacking */
    .player-container > * {
        flex-shrink: 0;
    }

    /* Hide some elements to prevent overcrowding in portrait */
    .volume-control {
        display: flex; /* Keep volume control visible */
    }
}

/* MOBILE LANDSCAPE - Keep existing layout (no changes) */
@media screen and (orientation: landscape) and (max-width: 768px) {
    /* Existing landscape styles remain unchanged */
    .audio-player {
        padding: 12px 0.5rem;
        max-height: 120px;
    }

    .player-container {
        flex-direction: row; /* Keep horizontal layout */
        height: 80px;
        gap: 12px;
        align-items: center;
    }

    .episode-thumbnail {
        width: 70px;
        height: 70px;
        border-radius: 8px;
    }

    .playback-controls {
        height: 70px;
        flex: 0;
        justify-content: center;
        margin-left: 0;
    }

    .main-controls {
        justify-content: center;
        gap: 8px;
    }

    #play-pause-btn {
        width: 52px;
        height: 52px;
        margin: 0 4px;
    }

    #rewind-btn,
    #forward-btn {
        width: 40px;
        height: 40px;
    }

    .episode-info-section {
        height: auto;
        padding: 0;
        width: 100%;
        text-align: center;
        align-items: center;
        flex: 1;
    }

    .episode-header {
        margin-bottom: 8px;
    }

    .episode-title-display {
        font-size: 0.9rem;
        margin-bottom: 0;
    }

    .progress-section {
        padding: 0 8px;
        margin-bottom: 8px;
    }

    .time-display {
        width: 35px;
        font-size: 10px;
    }

    .player-actions {
        height: auto;
        width: auto;
        justify-content: center;
        padding-right: 0;
        flex: 0;
    }

    .actions-row {
        gap: 6px;
    }

    .action-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    .speed-btn {
        height: 32px;
        padding: 4px 6px;
        min-width: 36px;
        font-size: 0.7rem;
    }

    .volume-slider-container {
        width: 60px;
    }

    .player-toggle {
        width: 28px;
        height: 28px;
        top: -18px;
        right: 12px;
    }
}

/* Ensure content doesn't get hidden behind player */
body {
    padding-bottom: 140px;
}

@media (max-width: 1024px) {
    body {
        padding-bottom: 130px;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 120px;
    }
}

/* Increased padding for portrait mobile to account for taller player */
@media screen and (orientation: portrait) and (max-width: 480px) {
    body {
        padding-bottom: 180px;
    }
}

/* Animation for player appearance */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.audio-player {
    animation: slideUp 0.3s ease-out;
}