/* =========================================
   Variables & Base
   ========================================= */
:root {
    --bgm-bg-glass: rgba(18, 18, 22, 0.95);
    --bgm-border: rgba(255, 255, 255, 0.08);
    --bgm-text-main: #eaeaea;
    --bgm-text-sub: #888888;
    --bgm-primary: var(--primary-color, #9da5ff); 
    --bgm-radius: 14px;
    --bgm-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body { margin: 0; padding: 0; overflow: hidden; }

/* =========================================
   Player Container
   ========================================= */
.bgm-player {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 280px;
    background: var(--bgm-bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--bgm-border);
    border-radius: var(--bgm-radius);
    box-shadow: var(--bgm-shadow);
    z-index: 9999;
    font-family: var(--f-pre, sans-serif);
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* =========================================
   Minimized State (PC/Mobile 공통)
   ========================================= */
.bgm-player.minimized {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    cursor: pointer;
    overflow: visible;
}

.bgm-player.minimized .player-content {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    z-index: -1;
}

/* 플레이어가 열려있을 땐 트리거 숨김 */
.bgm-player:not(.minimized) .minimized-trigger {
    display: none;
}

.minimized-trigger {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* 모바일에서 터치감 개선 */
    -webkit-tap-highlight-color: transparent; 
}

/* 음악 파형 애니메이션 */
.music-waves {
    display: flex;
    align-items: flex-end;
    height: 12px;
    gap: 3px;
}
.music-waves span {
    width: 3px;
    background: var(--bgm-primary);
    border-radius: 3px;
    animation: waves 1s ease-in-out infinite;
    transition: height 0.3s ease; /* 멈출 때 부드럽게 */
}

/* ★ 추가: 일시정지 상태일 때 파동 멈춤 */
.bgm-player.paused .music-waves span {
    animation-play-state: paused;
    height: 3px !important; /* 최소 높이로 고정 */
    transform: none;
}

.music-waves span:nth-child(1) { height: 5px; animation-delay: 0.1s; }
.music-waves span:nth-child(2) { height: 10px; animation-delay: 0.2s; }
.music-waves span:nth-child(3) { height: 7px; animation-delay: 0.3s; }
.music-waves span:nth-child(4) { height: 4px; animation-delay: 0.4s; }

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

/* =========================================
   Expanded Content
   ========================================= */
.player-content {
    padding: 12px 16px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 1;
    transition: opacity 0.3s 0.1s;
    height: 100%;
    box-sizing: border-box;
}

/* Header */
.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 4px;
    min-height: 20px;
}

.track-info-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex: 1;
}

.music-icon {
    color: var(--bgm-primary);
    font-size: 13px;
    display: flex;
    align-items: center;
}

.track-info {
    color: var(--bgm-text-main);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    font-weight: 600;
}

.minimize-btn {
    background: none;
    border: none;
    color: var(--bgm-text-sub);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    margin-left: 8px;
}
.minimize-btn:hover { color: var(--bgm-text-main); }

/* Controls */
.player-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.control-btn {
    background: none;
    border: none;
    color: var(--bgm-text-sub);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 8px;
}

.control-btn:hover:not(:disabled) {
    color: var(--bgm-text-main);
}

.play-pause-btn {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    color: var(--bgm-text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 0;
}
.play-pause-btn:hover {
    background: var(--bgm-primary);
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.3);
}

.volume-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
}
.volume-icon { color: var(--bgm-text-sub); font-size: 11px; }
.volume-slider {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    -webkit-appearance: none;
    cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px; height: 10px;
    background: var(--bgm-primary);
    border-radius: 50%;
    cursor: pointer;
}

/* Playlist Section */
.playlist-section {
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.playlist-toggle-btn {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--bgm-text-sub);
    padding: 10px 0 0 0;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: 1px;
}
.playlist-toggle-btn:hover { color: var(--bgm-text-main); }

.playlist-container {
    margin-top: 10px;
    max-height: 150px;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
}

.playlist { list-style: none; padding: 0; margin: 0; }
.playlist li {
    padding: 8px 10px;
    font-size: 11px;
    color: var(--bgm-text-sub);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.playlist li:hover { background: rgba(255,255,255,0.05); color: var(--bgm-text-main); }
.playlist li.current { color: var(--bgm-primary); font-weight: 600; }

/* Scrollbar */
.playlist-container::-webkit-scrollbar { width: 3px; }
.playlist-container::-webkit-scrollbar-thumb { background: var(--bgm-primary); border-radius: 2px; }

/* ★ 수정: 모바일에서도 Bottom Sheet 스타일 제거 및 아이콘 형태 유지 */
@media (max-width: 768px) {
    /* 모바일 전용 확장 스타일 삭제됨 */
    /* 필요하다면 터치 영역만 조금 더 확보 */
    .bgm-player.minimized {
        width: 50px;
        height: 50px;
    }
}