/**
 * ExpertPulse Audio Player — Premium Stylesheet
 *
 * Uses theme CSS custom properties (--accent, --bg-body, --text-main, etc.)
 * where available, with clean fallbacks. Dark-mode via [data-theme="dark"].
 * Font: Inter (system stack fallback). No monospace.
 */

/* ── Font import (lightweight subset) ───────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Custom properties (local scope) ────────────────────────────────────── */
.ep-audio-player,
.ep-audio-download-section,
.ep-audio-premiere-badge {
    /* Directly references the theme accent, #ff3366 fallback removed */
    --ep-p-brand:    var(--accent);
    /* Dynamically calculates 10% and 20% opacity of the accent color */
    --ep-p-brand-10: color-mix(in srgb, var(--ep-p-brand) 10%, transparent);
    --ep-p-brand-20: color-mix(in srgb, var(--ep-p-brand) 20%, transparent);
    /* Buttons & Badges color — wired to theme admin "Buttons & Badges" option */
    --ep-p-btn-bg:   var(--btn-bg);
    --ep-p-btn-text: var(--btn-text);
    --ep-p-btn-bg-20: color-mix(in srgb, var(--ep-p-btn-bg) 20%, transparent);
    
    --ep-p-green:    #22c55e;
    --ep-p-green-10: rgba(34, 197, 94, 0.10);
    --ep-p-track:    rgba(0, 0, 0, 0.10);
    --ep-p-bg:       #ffffff;
    --ep-p-surface:  #f8fafc;
    --ep-p-border:   rgba(0, 0, 0, 0.08);
    --ep-p-text:     #111827;
    --ep-p-muted:    #6b7280;
    --ep-p-radius:   14px;
    --ep-p-font:     'Inter', system-ui, -apple-system, sans-serif;
    --ep-p-shadow:   0 4px 20px rgba(0, 0, 0, 0.08);
    font-family: var(--ep-p-font);
}

/* ── Dark mode overrides ─────────────────────────────────────────────────── */
[data-theme="dark"] .ep-audio-player,
[data-theme="dark"] .ep-audio-download-section,
[data-theme="dark"] .ep-audio-premiere-badge {
    --ep-p-track:   rgba(255, 255, 255, 0.12);
    --ep-p-bg:      #1a1b20;
    --ep-p-surface: #23242b;
    --ep-p-border:  rgba(255, 255, 255, 0.07);
    --ep-p-text:    #f1f5f9;
    --ep-p-muted:   #94a3b8;
    --ep-p-shadow:  0 4px 20px rgba(0, 0, 0, 0.30);
}

/* ═══════════════════════════════════════════════════════════════════════════
   AUDIO PLAYER CARD
   ═══════════════════════════════════════════════════════════════════════════ */

.ep-audio-player {
    position: relative;
    background: var(--ep-p-bg);
    border: 1px solid var(--ep-p-border);
    border-radius: var(--ep-p-radius);
    box-shadow: var(--ep-p-shadow);
    padding: 18px 20px 16px;
    margin: 24px 0;
    overflow: hidden;
    transition: box-shadow 0.25s ease;
}

.ep-audio-player:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* Subtle brand accent line on top */
.ep-audio-player::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ep-p-brand), var(--ep-p-brand-20));
    border-radius: var(--ep-p-radius) var(--ep-p-radius) 0 0;
}

/* ── Inner layout ────────────────────────────────────────────────────────── */
.ep-audio-inner {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ── Play / Pause button ─────────────────────────────────────────────────── */
.ep-audio-play-btn {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ep-p-btn-bg);
    border: none;
    color: var(--ep-p-btn-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 4px 14px var(--ep-p-btn-bg-20);
}

.ep-audio-play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px var(--ep-p-btn-bg-20);
}

.ep-audio-play-btn:active {
    transform: scale(0.96);
}

.ep-audio-play-btn svg {
    transition: opacity 0.15s ease;
}

/* ── Body (title + progress) ─────────────────────────────────────────────── */
.ep-audio-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ep-audio-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.ep-audio-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ep-p-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.ep-audio-time {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 500;
    color: var(--ep-p-muted);
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.ep-audio-sep {
    opacity: 0.5;
}

/* ── Progress bar ────────────────────────────────────────────────────────── */
.ep-audio-progress-wrap {
    position: relative;
}

.ep-audio-progress {
    position: relative;
    height: 4px;
    background: var(--ep-p-track);
    border-radius: 99px;
    cursor: pointer;
    overflow: visible;
}

.ep-audio-progress:hover {
    height: 5px;
}

.ep-audio-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0;
    background: var(--ep-p-brand);
    border-radius: 99px;
    transition: width 0.1s linear;
}

.ep-audio-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;
    height: 12px;
    background: var(--ep-p-brand);
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 3px var(--ep-p-brand-10);
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}

.ep-audio-progress:hover .ep-audio-thumb {
    opacity: 1;
}

/* ── Waveform bar (visual placeholder below controls) ────────────────────── */
.ep-audio-waveform-bar {
    display: none; /* used as hook by JS if needed */
}

/* ── Right controls (repeat + volume) ───────────────────────────────────── */
.ep-audio-controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.ep-audio-repeat-btn {
    background: none;
    border: none;
    color: var(--ep-p-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.18s, background 0.18s;
    line-height: 0;
}

.ep-audio-repeat-btn:hover,
.ep-audio-repeat-btn.active {
    color: var(--ep-p-brand);
    background: var(--ep-p-brand-10);
}

/* ── Volume ──────────────────────────────────────────────────────────────── */
.ep-audio-volume {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ep-audio-vol-icon {
    color: var(--ep-p-muted);
    flex-shrink: 0;
}

.ep-audio-vol-slider {
    width: 56px;
    height: 4px;
    background: var(--ep-p-track);
    border-radius: 99px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.ep-audio-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--ep-p-brand);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.ep-audio-vol-slider::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--ep-p-brand);
    cursor: pointer;
    border: none;
}

/* ── Loading indicator ───────────────────────────────────────────────────── */
.ep-audio-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.80);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ep-p-muted);
    border-radius: var(--ep-p-radius);
}

.ep-audio-loading[hidden] {
    display: none !important;
}

[data-theme="dark"] .ep-audio-loading {
    background: rgba(26, 27, 32, 0.85);
}

.ep-audio-spin {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--ep-p-brand-20);
    border-top-color: var(--ep-p-brand);
    border-radius: 50%;
    animation: ep-audio-spin 0.7s linear infinite;
}

@keyframes ep-audio-spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DOWNLOAD SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.ep-audio-download-section {
    margin: 8px 0 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.ep-audio-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: var(--ep-p-btn-bg);
    color: var(--ep-p-btn-text);
    padding: 11px 26px;
    border-radius: 99px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    box-shadow: 0 4px 14px var(--ep-p-btn-bg-20);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    font-family: var(--ep-p-font);
}

.ep-audio-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--ep-p-btn-bg-20);
    color: var(--ep-p-btn-text);
    text-decoration: none;
    opacity: 0.95;
}

.ep-audio-download-btn:active {
    transform: translateY(0);
}

.ep-audio-download-btn i {
    font-size: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AUTHORIZED PREMIERE BADGE
   ═══════════════════════════════════════════════════════════════════════════ */

.ep-audio-premiere-badge {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--ep-p-green-10);
    border: 1px solid rgba(34, 197, 94, 0.22);
    color: #15803d;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.55;
    text-align: left;
    max-width: 480px;
    box-sizing: border-box;
    font-family: var(--ep-p-font);
}

.ep-audio-premiere-badge svg {
    flex-shrink: 0;
    color: var(--ep-p-green);
    margin-top: 2px;
}

.ep-audio-premiere-badge strong {
    font-weight: 700;
}

[data-theme="dark"] .ep-audio-premiere-badge {
    background: rgba(22, 101, 52, 0.18);
    border-color: rgba(34, 197, 94, 0.25);
    color: #4ade80;
}

[data-theme="dark"] .ep-audio-premiere-badge svg {
    color: #4ade80;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
    .ep-audio-player {
        padding: 14px 16px 13px;
    }

    .ep-audio-inner {
        gap: 10px;
    }

    .ep-audio-play-btn {
        width: 42px;
        height: 42px;
    }

    .ep-audio-play-btn svg {
        width: 17px;
        height: 17px;
    }

    .ep-audio-title {
        font-size: 13px;
    }

    .ep-audio-vol-slider {
  