/**
 * Stream Playlist History Pro — Frontend Styles
 * Includes all free styles plus Pro-only additions.
 */

:root {
    --sph-accent:     #1db954;
    --sph-bg-start:   #121212;
    --sph-bg-end:     #1e1e1e;
    --sph-text:       #ffffff;
    --sph-card-bg:    rgba(255, 255, 255, 0.05);
    --sph-card-hover: rgba(255, 255, 255, 0.09);
    --sph-radius:     10px;
    --sph-shadow:     0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ── CSS Visibility System (same as free) ──────────────────────────────────── */

.sph-show-when-playing { display: none !important; }
body.sph-stream-has-track .sph-show-when-playing { display: revert !important; }
.sph-hide-when-playing { display: revert; }
body.sph-stream-has-track .sph-hide-when-playing { display: none !important; }
.sph-show-when-history { display: none !important; }
body.sph-stream-has-history .sph-show-when-history { display: revert !important; }
.sph-hide-when-history { display: revert; }
body.sph-stream-has-history .sph-hide-when-history { display: none !important; }

/* ── Now Playing Widget ─────────────────────────────────────────────────────── */

.sph-nowplaying-widget {
    background: linear-gradient(135deg, var(--sph-bg-start), var(--sph-bg-end));
    border-radius: var(--sph-radius);
    padding: 20px 24px 24px;
    box-shadow: var(--sph-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--sph-text);
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sph-np-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--sph-accent);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--sph-accent);
    border-radius: 20px;
    padding: 3px 12px 3px 8px;
    margin-bottom: 16px;
}

.sph-np-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sph-accent);
    animation: sph-pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes sph-pulse {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.75); }
}

.sph-np-body {
    display: flex;
    gap: 20px;
    align-items: center;
}

.sph-np-art {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid var(--sph-accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sph-np-art img { width: 100%; height: 100%; object-fit: cover; }

.sph-np-art-placeholder {
    font-size: 36px;
    color: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sph-np-info { flex: 1; min-width: 0; }

.sph-np-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--sph-accent);
    line-height: 1.2;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sph-np-artist {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sph-np-album {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sph-np-time {
    display: inline-block;
    font-size: 11px;
    color: var(--sph-accent);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-radius: 10px;
    padding: 2px 10px;
    margin-bottom: 6px;
}

/* Music links inside the Now Playing card */
.sph-np-info .sph-music-link { margin-top: 4px; }

.sph-np-offline {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    font-style: italic;
    padding: 16px 0;
}

.sph-np-offline-icon { font-size: 24px; opacity: 0.5; }

/* ── Widget Shell ──────────────────────────────────────────────────────────── */

.sph-playlist-widget {
    background: linear-gradient(135deg, var(--sph-bg-start), var(--sph-bg-end));
    border-radius: var(--sph-radius);
    padding: 20px 24px;
    box-shadow: var(--sph-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--sph-text);
    box-sizing: border-box;
}

/* ── Header ────────────────────────────────────────────────────────────────── */

.sph-playlist-header {
    text-align: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
}

.sph-playlist-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--sph-accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.sph-tagline {
    font-size: 11px;
    color: var(--sph-accent);
    font-style: italic;
    margin-top: 4px;
    opacity: 0.85;
}

/* ── Track List ────────────────────────────────────────────────────────────── */

.sph-playlist-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@keyframes sph-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.sph-playlist-items.sph-refresh .sph-track {
    animation: sph-fade-in 0.4s ease-out;
}

/* ── Individual Track ──────────────────────────────────────────────────────── */

.sph-track {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    background: var(--sph-card-bg);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.sph-track:hover {
    background: var(--sph-card-hover);
    border-color: rgba(255, 255, 255, 0.16);
    transform: translateX(4px);
}

.sph-track--current {
    background: rgba(255, 255, 255, 0.10);
    border: 1.5px solid var(--sph-accent);
    box-shadow: 0 0 14px rgba(29, 185, 84, 0.12);
}

/* ── Album Art ─────────────────────────────────────────────────────────────── */

.sph-albumart {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sph-track--current .sph-albumart {
    width: 58px;
    height: 58px;
    border-color: var(--sph-accent);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.sph-albumart img { width: 100%; height: 100%; object-fit: cover; }
.sph-albumart-placeholder { font-size: 20px; color: rgba(255, 255, 255, 0.3); }

/* ── Track Text ────────────────────────────────────────────────────────────── */

.sph-track-info { flex: 1; min-width: 0; }

.sph-track-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--sph-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sph-track--current .sph-track-title {
    font-size: 15px;
    color: var(--sph-accent);
}

.sph-track-artist {
    font-size: 12px;
    color: var(--sph-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    opacity: 0.9;
}

.sph-track-album {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* ── PRO: Music Service Links ──────────────────────────────────────────────── */

/* Shared base for all three links — sits in a flex row */
.sph-music-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 10px;
    padding: 2px 8px 2px 6px;
    border: 1px solid transparent;
    transition: opacity 0.2s, border-color 0.2s;
    white-space: nowrap;
    margin-top: 6px;
    margin-right: 4px;
}

.sph-music-link:hover { opacity: 1 !important; text-decoration: none; }

/* Spotify — green */
.sph-spotify-link {
    color: #1db954;
    border-color: rgba(29, 185, 84, 0.3);
    background: rgba(29, 185, 84, 0.08);
    opacity: 0.85;
}
.sph-spotify-link:hover { border-color: #1db954; color: #1db954; }

/* Apple Music — pink/red */
.sph-apple-link {
    color: #fc3c44;
    border-color: rgba(252, 60, 68, 0.3);
    background: rgba(252, 60, 68, 0.08);
    opacity: 0.85;
}
.sph-apple-link:hover { border-color: #fc3c44; color: #fc3c44; }

/* Amazon Music — orange */
.sph-amazon-link {
    color: #ff9900;
    border-color: rgba(255, 153, 0, 0.3);
    background: rgba(255, 153, 0, 0.08);
    opacity: 0.85;
}
.sph-amazon-link:hover { border-color: #ff9900; color: #ff9900; }

/* ── Timestamp ─────────────────────────────────────────────────────────────── */

.sph-track-time {
    font-size: 10px;
    color: var(--sph-accent);
    opacity: 0.75;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 3px 9px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.sph-track--current .sph-track-time {
    opacity: 1;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--sph-accent);
}

/* ── PRO: Compact Mode ─────────────────────────────────────────────────────── */

.sph-compact .sph-track {
    padding: 8px 12px;
    gap: 10px;
}

.sph-compact .sph-track-title { font-size: 13px; }
.sph-compact .sph-track--current .sph-track-title { font-size: 14px; }

/* ── States ────────────────────────────────────────────────────────────────── */

.sph-empty, .sph-error {
    text-align: center;
    padding: 24px 16px;
    font-size: 13px;
    border-radius: 8px;
}

.sph-empty { color: rgba(255, 255, 255, 0.5); font-style: italic; }

.sph-error {
    color: #ffaaaa;
    background: rgba(220, 50, 50, 0.15);
    border: 1px solid rgba(220, 50, 50, 0.3);
}

/* ── Light Theme Overrides ─────────────────────────────────────────────────── */

/* Light theme passes text=#212529 via CSS var. Force readable colors. */
.sph-playlist-widget[style*="--sph-text:#212529"] .sph-track-album { color: rgba(0,0,0,0.5); }

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .sph-playlist-widget { padding: 14px 16px; }
    .sph-track { flex-wrap: wrap; gap: 10px; }
    .sph-track-time { width: 100%; text-align: center; margin-top: 4px; }
    .sph-track-info { min-width: 0; flex: 1 1 140px; }
    .sph-albumart { width: 42px; height: 42px; }
    .sph-track--current .sph-albumart { width: 50px; height: 50px; }
}
