/**
 * رادیو ایثار - استایل پلیر موسیقی
 * شامل: پلیر چسبیده پایین، مودال متن آهنگ، صف پخش
 *
 * @package Radio_Isar
 */

/* ===== Now Playing Bar (پلیر چسبیده پایین) ===== */
.now-playing-bar {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: var(--player-height);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
    z-index: 900;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: translateY(100%);
    transition: transform var(--transition-base);
}

.now-playing-bar.active {
    transform: translateY(0);
}

.now-playing-container {
    height: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    align-items: center;
    gap: 24px;
}

/* ===== Now Playing Info ===== */
.now-playing-info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.now-playing-cover {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-alt);
    position: relative;
}

.now-playing-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.now-playing-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 50%, rgba(220, 38, 38, 0.3) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.now-playing-bar.playing .now-playing-cover::after {
    opacity: 1;
}

.now-playing-text {
    min-width: 0;
    overflow: hidden;
}

.now-playing-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.now-playing-artist {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Player Controls ===== */
.now-playing-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.player-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.player-btn:hover {
    color: var(--primary);
    background: var(--bg);
}

.player-play-pause {
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: #fff;
    font-size: 22px;
    box-shadow: var(--shadow-red);
}

.player-play-pause:hover {
    background: var(--accent);
    color: #fff;
    transform: scale(1.05);
}

.player-play-pause .play-icon,
.player-play-pause .pause-icon {
    transition: transform var(--transition-fast);
}

.now-playing-bar.playing .player-play-pause .play-icon {
    display: none;
}

.now-playing-bar.playing .player-play-pause .pause-icon {
    display: inline-block;
}

/* Player Progress */
.player-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 500px;
}

.player-current-time,
.player-duration {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 36px;
    text-align: center;
}

.player-progress {
    flex: 1;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.player-progress-buffer {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    background: var(--border-strong);
    border-radius: 3px;
    width: 0;
    transition: width 0.2s ease;
}

.player-progress-filled {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    width: 0;
    transition: width 0.1s linear;
}

.player-progress-filled::after {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.player-progress:hover .player-progress-filled::after {
    opacity: 1;
}

.player-progress-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    z-index: 2;
}

/* ===== Now Playing Actions ===== */
.now-playing-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.player-volume {
    position: relative;
}

.player-volume-slider {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    width: 120px;
    height: 36px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.player-volume:hover .player-volume-slider,
.player-volume-slider:hover {
    opacity: 1;
    visibility: visible;
}

.volume-input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--bg);
    border-radius: 2px;
    outline: none;
}

.volume-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.volume-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.player-btn.active {
    color: var(--primary);
    background: rgba(220, 38, 38, 0.1);
}

.player-download {
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-download:hover {
    background: var(--primary);
    color: #fff;
}

/* ===== Player Queue Drawer ===== */
.player-queue-drawer {
    position: fixed;
    bottom: var(--player-height);
    left: 0;
    width: 360px;
    max-width: 90vw;
    height: 480px;
    max-height: 60vh;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) 0 0 0;
    box-shadow: var(--shadow-lg);
    z-index: 950;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    display: flex;
    flex-direction: column;
}

.player-queue-drawer.active {
    transform: translateX(0);
}

.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.queue-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.queue-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.queue-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    list-style: none;
}

.queue-list::-webkit-scrollbar {
    width: 6px;
}

.queue-list::-webkit-scrollbar-track {
    background: var(--bg);
}

.queue-list::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.queue-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.queue-list li:hover {
    background: var(--bg);
}

.queue-list li.playing {
    background: rgba(220, 38, 38, 0.1);
}

.queue-item-cover {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg);
}

.queue-item-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.queue-item-info {
    flex: 1;
    min-width: 0;
}

.queue-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-item-artist {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-item-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: all var(--transition-fast);
}

.queue-list li:hover .queue-item-remove {
    opacity: 1;
}

.queue-item-remove:hover {
    background: var(--primary);
    color: #fff;
}

/* ===== Lyrics Modal ===== */
.lyrics-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.lyrics-modal.active {
    opacity: 1;
    visibility: visible;
}

.lyrics-modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform var(--transition-base);
    position: relative;
}

.lyrics-modal.active .lyrics-modal-content {
    transform: scale(1);
}

.lyrics-modal-close {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    z-index: 2;
    transition: all var(--transition-fast);
}

.lyrics-modal-close:hover {
    background: var(--primary);
    color: #fff;
    transform: rotate(90deg);
}

.lyrics-modal-header {
    padding: 32px;
    background: var(--gradient-red-dark);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 20px;
}

.lyrics-modal-cover {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-md);
    object-fit: cover;
    box-shadow: var(--shadow-md);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.lyrics-modal-title {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 6px;
}

.lyrics-modal-artist {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
}

.lyrics-modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
    color: var(--text);
    line-height: 2.2;
    font-size: 15px;
    text-align: center;
    white-space: pre-wrap;
}

.lyrics-modal-body::-webkit-scrollbar {
    width: 6px;
}

.lyrics-modal-body::-webkit-scrollbar-track {
    background: var(--bg);
}

.lyrics-modal-body::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

/* ===== Inline Player (پلیر داخل کارت) ===== */
.song-card-inline-player {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(100%);
    transition: transform var(--transition-base);
    z-index: 3;
}

.song-card.playing .song-card-inline-player {
    transform: translateY(0);
}

/* ===== Equalizer Animation (نمایش در حال پخش) ===== */
.equalizer {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
}

.equalizer span {
    display: block;
    width: 3px;
    background: var(--primary);
    border-radius: 1px;
    animation: equalizer 1s infinite ease-in-out;
}

.equalizer span:nth-child(1) { animation-delay: 0s; height: 60%; }
.equalizer span:nth-child(2) { animation-delay: 0.2s; height: 100%; }
.equalizer span:nth-child(3) { animation-delay: 0.4s; height: 80%; }
.equalizer span:nth-child(4) { animation-delay: 0.1s; height: 70%; }

@keyframes equalizer {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}

.song-card.playing .song-card-cover::after,
.hero-slide.playing .hero-slide-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(220, 38, 38, 0.4) 0%, transparent 50%);
    pointer-events: none;
}

.song-card.playing .song-card-cover {
    position: relative;
}

.song-card.playing .song-card-play {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    background: var(--accent);
}

.song-card.playing .song-card-play i {
    animation: pulse 1.5s infinite;
}

/* ===== Loading Spinner ===== */
.player-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== Toast Notifications ===== */
.player-toast {
    position: fixed;
    bottom: calc(var(--player-height) + 24px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    border: 1px solid var(--border);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.player-toast i {
    color: var(--primary);
    font-size: 18px;
}

/* ===== Responsive Player ===== */
@media (max-width: 1100px) {
    .now-playing-container {
        grid-template-columns: 200px 1fr 200px;
        gap: 16px;
    }

    .player-progress-wrap {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    :root {
        --player-height: 130px;
    }

    .now-playing-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        padding: 8px 12px;
        gap: 6px;
    }

    .now-playing-info {
        gap: 10px;
    }

    .now-playing-cover {
        width: 44px;
        height: 44px;
    }

    .now-playing-title {
        font-size: 13px;
    }

    .now-playing-artist {
        font-size: 11px;
    }

    .now-playing-controls {
        gap: 6px;
    }

    .player-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .player-play-pause {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .player-current-time,
    .player-duration {
        font-size: 10px;
        min-width: 32px;
    }

    .now-playing-actions {
        gap: 2px;
    }

    .player-volume,
    .player-shuffle,
    .player-repeat,
    .player-queue {
        display: none;
    }

    .player-queue-drawer {
        width: 100%;
        max-width: 100%;
        bottom: var(--player-height);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .lyrics-modal-content {
        max-height: 90vh;
    }

    .lyrics-modal-header {
        padding: 20px;
    }

    .lyrics-modal-cover {
        width: 70px;
        height: 70px;
    }

    .lyrics-modal-title {
        font-size: 18px;
    }

    .lyrics-modal-body {
        padding: 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .player-progress-wrap {
        gap: 6px;
    }

    .now-playing-text {
        max-width: 120px;
    }
}

/* Audio element hidden */
audio {
    display: none !important;
}
