/**
 * Mini Player - Persistent audio player bar
 * Fixed to bottom of viewport, allows listening while browsing
 */

/* ============================================================================
   MINI PLAYER BAR
   ============================================================================ */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    color: #e0e0e0;
    font-size: 14px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mini-player *,
.mini-player *::before,
.mini-player *::after {
    box-sizing: border-box;
}

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

.mini-player-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
}

/* ============================================================================
   SERMON INFO (title + preacher)
   ============================================================================ */
.mini-player-info {
    flex: 0 0 auto;
    max-width: 250px;
    min-width: 0;
    line-height: 1.3;
}

.mini-player-title {
    display: block;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.mini-player-title:hover {
    color: #90caf9;
    text-decoration: underline;
}

.mini-player-preacher {
    display: block;
    color: #9e9e9e;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================================
   PLAYBACK CONTROLS
   ============================================================================ */
.mini-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.mini-player-btn {
    background: none;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    font-size: 18px;
    transition: color 0.15s;
    flex-shrink: 0;
}

.mini-player-btn:hover {
    color: #fff;
}

.mini-player-btn.play-btn {
    font-size: 22px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.mini-player-btn.play-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   PROGRESS BAR
   ============================================================================ */
.mini-player-progress-wrap {
    flex: 1;
    min-width: 80px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mini-player-progress {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: height 0.15s;
}

.mini-player-progress:hover {
    height: 6px;
}

.mini-player-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.mini-player-progress::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.mini-player-progress::-webkit-slider-runnable-track {
    border-radius: 2px;
}

.mini-player-progress::-moz-range-track {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    height: 4px;
}

.mini-player-time {
    color: #9e9e9e;
    font-size: 12px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 90px;
    text-align: center;
}

/* ============================================================================
   VOLUME CONTROL
   ============================================================================ */

/* iOS Safari doesn't allow JS to control audio.volume (hardware-only).
   Hide volume/mute on touch devices since they do nothing. */
@media (pointer: coarse) {
    .mini-player-btn.vol-btn,
    .mini-player-volume {
        display: none !important;
    }
}

.mini-player-btn.vol-btn {
    font-size: 16px;
}

.mini-player-volume {
    width: 70px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    flex-shrink: 0;
}

.mini-player-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

.mini-player-volume::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

.mini-player-volume::-moz-range-track {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    height: 4px;
}

/* ============================================================================
   SPEED CONTROL
   ============================================================================ */
.mini-player-speed {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
}

.mini-player-speed:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mini-player-speed option {
    background: #1a1a2e;
    color: #e0e0e0;
}

/* ============================================================================
   CLOSE BUTTON
   ============================================================================ */
.mini-player-close {
    background: none;
    border: none;
    color: #9e9e9e;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.mini-player-close:hover {
    color: #fff;
}

/* ============================================================================
   BODY PADDING (prevent content from being hidden behind mini player)
   ============================================================================ */
body.mini-player-active {
    padding-bottom: 64px;
}

/* Shift the floating stack up above the mini player bar */
body.mini-player-active .floating-stack {
    bottom: 80px !important;
}

/* Shift toast notifications up above the mini player bar */
body.mini-player-active .favorites-login-toast,
body.mini-player-active .favorites-toast {
    bottom: 64px !important;
}

/* Ensure back-to-top stays aligned within the stack when mini player is active */
body.mini-player-active .floating-stack .back-to-top-btn {
    position: relative !important;
    bottom: auto !important;
    right: auto !important;
}

/* ============================================================================
   SERMON PLAYER ACTION BUTTONS (toggle + listen while browsing)
   ============================================================================ */
.sermon-player-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sermon-player-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: linear-gradient(135deg, #1e5631 0%, #0d3320 100%);
    color: #d4edda;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.sermon-player-btn:hover {
    background: linear-gradient(135deg, #267340 0%, #154228 100%);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

.sermon-player-btn i {
    font-size: 15px;
}

/* Hide the button when mini player is already active for this sermon */
.listen-while-browsing-btn.active-sermon {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */
.mini-player-loading .play-btn {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================================================
   RESUME BANNER (shown when returning to site with saved state)
   ============================================================================ */
.mini-player-resume {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #e0e0e0;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: miniPlayerSlideUp 0.3s ease;
}

@keyframes miniPlayerSlideUp {
    from { transform: translateX(-50%) translateY(100%); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.mini-player-resume-title {
    font-weight: 600;
    color: #fff;
}

.mini-player-resume-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.mini-player-resume-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mini-player-resume-dismiss {
    background: none;
    border: none;
    color: #9e9e9e;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
}

/* ============================================================================
   RESPONSIVE - MOBILE
   ============================================================================ */
@media (max-width: 768px) {
    .mini-player-inner {
        flex-wrap: wrap;
        padding: 6px 10px 8px;
        gap: 2px 6px;
    }

    /* Row 1: title/preacher + close button */
    .mini-player-info {
        flex: 1 1 auto;
        max-width: calc(100% - 36px);
        order: 1;
    }

    .mini-player-close {
        order: 2;
        margin-left: auto;
    }

    /* Row 2: compact controls */
    .mini-player-controls {
        order: 3;
        flex: 0 0 100%;
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }

    /* Hide skip buttons, volume, speed on mobile — keep it simple */
    #mini-player-skip-back,
    #mini-player-skip-fwd,
    .mini-player-btn.vol-btn,
    .mini-player-volume,
    .mini-player-speed {
        display: none !important;
    }

    /* Smaller play button on mobile */
    .mini-player-btn.play-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
        flex-shrink: 0;
    }

    /* Progress bar fills remaining space */
    .mini-player-progress-wrap {
        flex: 1 1 0%;
        min-width: 0;
    }

    .mini-player-progress {
        min-width: 0;
    }

    .mini-player-time {
        min-width: 0;
        font-size: 11px;
        flex-shrink: 0;
        white-space: nowrap;
    }

    body.mini-player-active {
        padding-bottom: 80px;
    }

    body.mini-player-active .floating-stack {
        bottom: 96px !important;
    }

    body.mini-player-active .favorites-login-toast,
    body.mini-player-active .favorites-toast {
        bottom: 80px !important;
    }
}
