/**
 * Sermon Audio Player Styles
 *
 * Modern, mobile-friendly audio player for long-form content
 *
 * @version 1.0.0
 */

.sermon-audio-player {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: all 0.3s ease;
}

/* Sticky Player */
.sermon-audio-player.sap-sticky {
    position: fixed;
    top: 56px; /* Default, will be set dynamically by JS */
    left: 0;
    right: 0;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1030; /* Higher than Bootstrap navbar (1020-1030) */
    padding: 8px 16px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sermon Info - Hidden by default, shown when sticky */
.sap-sermon-info {
    display: none;
    margin-bottom: 8px;
    padding-bottom: 0;
}

.sermon-audio-player.sap-sticky .sap-sermon-info {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.sap-sermon-code {
    display: inline-block;
    background: #28a745;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.sap-sermon-title {
    font-size: 13px;
    font-weight: 600;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.sap-sermon-subtitle {
    display: none; /* Hide subtitle in sticky mode for space */
}

.sermon-audio-player[data-theme="dark"] {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

.sermon-audio-player[data-theme="dark"] .sap-sermon-title {
    color: #e2e8f0;
}

/* Main Controls */
.sap-main-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.sap-btn {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #495057;
    text-decoration: none;
}

.sap-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

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

.sermon-audio-player[data-theme="dark"] .sap-btn {
    background: #4a5568;
    border-color: #718096;
    color: #e2e8f0;
}

.sermon-audio-player[data-theme="dark"] .sap-btn:hover {
    background: #2d3748;
}

.sap-btn-play {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #28a745;
    border-color: #28a745;
    color: white;
    flex-shrink: 0;
}

.sap-btn-play:hover {
    background: #218838;
    border-color: #1e7e34;
}

.sap-btn-play i {
    font-size: 18px;
}

/* Time Display */
.sap-time-display {
    font-size: 13px;
    font-weight: 500;
    color: #495057;
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.sermon-audio-player[data-theme="dark"] .sap-time-display {
    color: #cbd5e0;
}

.sap-separator {
    margin: 0 4px;
    color: #adb5bd;
}

/* Progress Bar */
.sap-progress-container {
    flex: 1;
    min-width: 100px;
}

.sap-progress-bar {
    position: relative;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
}

.sermon-audio-player[data-theme="dark"] .sap-progress-bar {
    background: #1a202c;
}

.sap-progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #cbd5e0;
    transition: width 0.3s;
}

.sap-progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #28a745;
    transition: width 0.1s;
    z-index: 1;
}

.sap-progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: white;
    border: 2px solid #28a745;
    border-radius: 50%;
    cursor: grab;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.sap-progress-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
}

/* Secondary Controls */
.sap-secondary-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.sap-left-controls,
.sap-right-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Skip Buttons */
.sap-skip-label {
    font-size: 11px;
    font-weight: 600;
}

/* Speed Control */
.sap-speed-control {
    position: relative;
}

.sap-speed-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 4px;
    z-index: 1000;
    min-width: 80px;
}

.sermon-audio-player[data-theme="dark"] .sap-speed-menu {
    background: #2d3748;
    border-color: #4a5568;
}

.sap-speed-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    color: #495057;
    transition: background 0.2s;
}

.sermon-audio-player[data-theme="dark"] .sap-speed-option {
    color: #e2e8f0;
}

.sap-speed-option:hover {
    background: #e9ecef;
}

.sermon-audio-player[data-theme="dark"] .sap-speed-option:hover {
    background: #4a5568;
}

.sap-speed-option.active {
    background: #28a745;
    color: white;
}

.sap-speed-label {
    font-weight: 600;
    min-width: 28px;
    text-align: center;
}

/* Volume Control */
.sap-volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sap-volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #e9ecef;
    border-radius: 2px;
    outline: none;
}

.sermon-audio-player[data-theme="dark"] .sap-volume-slider {
    background: #1a202c;
}

.sap-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #28a745;
    border-radius: 50%;
    cursor: pointer;
}

.sap-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #28a745;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Status Bar */
.sap-status-bar {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

.sap-status-bar[data-type="info"] {
    background: #cfe2ff;
    color: #084298;
}

.sap-status-bar[data-type="error"] {
    background: #f8d7da;
    color: #842029;
}

.sermon-audio-player[data-theme="dark"] .sap-status-bar[data-type="info"] {
    background: #1e3a8a;
    color: #bfdbfe;
}

.sermon-audio-player[data-theme="dark"] .sap-status-bar[data-type="error"] {
    background: #7f1d1d;
    color: #fecaca;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sap-main-controls {
        flex-wrap: wrap;
    }

    .sap-progress-container {
        order: 3;
        width: 100%;
        margin-top: 8px;
    }

    .sap-secondary-controls {
        flex-wrap: wrap;
    }

    .sap-left-controls,
    .sap-right-controls {
        flex-wrap: wrap;
    }

    .sap-skip-label {
        display: none;
    }

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

    .sap-btn {
        padding: 6px 10px;
        font-size: 13px;
    }

    /* Sticky player adjustments for mobile */
    .sermon-audio-player.sap-sticky {
        padding: 6px 8px;
    }

    .sap-sermon-code {
        font-size: 10px;
        padding: 2px 6px;
    }

    .sermon-audio-player.sap-sticky .sap-sermon-title {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .sermon-audio-player {
        padding: 12px;
    }

    .sap-time-display {
        font-size: 12px;
    }

    .sap-btn {
        padding: 6px 8px;
    }

    .sap-volume-control {
        width: 100%;
        margin-top: 8px;
    }

    .sap-volume-slider {
        flex: 1;
    }
}

/* Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.sap-btn-play.loading i {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Print */
@media print {
    .sermon-audio-player {
        display: none;
    }
}
