/**
 * 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 MODAL (shown when returning to site with saved state)
   ============================================================================ */
.mini-player-resume-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10010;
    background: rgba(8, 6, 18, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: miniPlayerResumeFadeIn 0.18s ease-out;
}

@keyframes miniPlayerResumeFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.mini-player-resume-backdrop.mini-player-resume-closing {
    opacity: 0;
    transition: opacity 0.18s ease;
}

.mini-player-resume-modal {
    background: linear-gradient(160deg, #1f1535 0%, #0f0c1f 100%);
    border: 1px solid rgba(167, 139, 250, 0.28);
    border-radius: 18px;
    padding: 2rem 2rem 1.6rem;
    max-width: 460px;
    width: 100%;
    color: #e9e7f5;
    text-align: center;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: miniPlayerResumePopIn 0.22s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}

@keyframes miniPlayerResumePopIn {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.mini-player-resume-kicker {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: #a78bfa;
    margin-bottom: 0.7rem;
    font-weight: 600;
}

.mini-player-resume-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    margin-bottom: 0.35rem;
    word-break: break-word;
}

.mini-player-resume-preacher {
    font-size: 0.95rem;
    color: rgba(233, 231, 245, 0.78);
    margin-bottom: 0.5rem;
}

.mini-player-resume-position {
    font-size: 0.85rem;
    color: rgba(233, 231, 245, 0.6);
    font-variant-numeric: tabular-nums;
    margin-bottom: 1.6rem;
    letter-spacing: 0.02em;
}

.mini-player-resume-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.95rem 1.5rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    color: #fff;
    border: none;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
    transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
    margin-bottom: 0.6rem;
}

.mini-player-resume-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(139, 92, 246, 0.5);
}

.mini-player-resume-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.4);
}

.mini-player-resume-btn .bi-play-fill {
    font-size: 1.4rem;
    margin-left: -4px;
}

.mini-player-resume-dismiss-btn {
    background: transparent;
    color: rgba(233, 231, 245, 0.6);
    border: none;
    font-size: 0.92rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.12s, background 0.12s;
}

.mini-player-resume-dismiss-btn:hover {
    color: rgba(233, 231, 245, 0.95);
    background: rgba(255, 255, 255, 0.06);
}

html[data-theme="light"] .mini-player-resume-modal {
    background: linear-gradient(160deg, #ffffff 0%, #f3f1fb 100%);
    color: #1a1a2e;
    border-color: rgba(139, 92, 246, 0.32);
}
html[data-theme="light"] .mini-player-resume-title { color: #1a1a2e; }
html[data-theme="light"] .mini-player-resume-preacher { color: rgba(26, 26, 46, 0.75); }
html[data-theme="light"] .mini-player-resume-position { color: rgba(26, 26, 46, 0.6); }
html[data-theme="light"] .mini-player-resume-kicker { color: #6d28d9; }
html[data-theme="light"] .mini-player-resume-dismiss-btn { color: rgba(26, 26, 46, 0.65); }
html[data-theme="light"] .mini-player-resume-dismiss-btn:hover {
    color: rgba(26, 26, 46, 0.95);
    background: rgba(139, 92, 246, 0.08);
}

@media (max-width: 480px) {
    .mini-player-resume-modal { padding: 1.6rem 1.4rem 1.3rem; border-radius: 16px; }
    .mini-player-resume-title { font-size: 1.25rem; }
    .mini-player-resume-btn { font-size: 1rem; padding: 0.85rem 1.25rem; }
}

/* ============================================================================
   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;
    }
}
