/* 悬浮音乐播放器样式 - 移动端优化版 */
#floating-music-player {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* 默认位置，会被JS覆盖 */
    bottom: 30px;
    right: 30px;
    /* 移动优化 */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* 播放器切换按钮 - 50%透明度 */
.player-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(106, 17, 203, 0.5) 0%, rgba(37, 117, 252, 0.5) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all 0.3s ease;
    color: white;
    font-size: 24px;
    position: relative;
    z-index: 10000;
    opacity: 0.5; /* 50%透明度 */
}

.player-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    opacity: 0.8; /* 悬停时稍微增加透明度 */
}

.player-toggle:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.player-toggle.playing {
    opacity: 0.8; /* 播放时增加可见度 */
}

/* 拖拽手柄 */
.drag-handle {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    opacity: 0.6;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.drag-handle svg {
    width: 12px;
    height: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.player-toggle:hover .drag-handle {
    opacity: 1;
}

/* 移动指示器 */
.player-toggle.dragging {
    cursor: grabbing !important;
    transform: scale(1.05);
    box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.5), 0 12px 40px rgba(0, 0, 0, 0.4);
    z-index: 10001;
    opacity: 0.8; /* 拖拽时增加可见度 */
}

/* 移动端拖拽优化 */
.player-toggle.touch-dragging {
    transition: none;
    opacity: 0.8;
}

/* 均衡器动画 */
.equalizer {
    display: none;
    gap: 2px;
    align-items: end;
    height: 20px;
}

.equalizer span {
    width: 3px;
    background: white;
    border-radius: 1px;
    animation: equalizer 1.5s ease infinite;
}

.equalizer span:nth-child(1) { animation-delay: 0s; height: 8px; }
.equalizer span:nth-child(2) { animation-delay: 0.5s; height: 12px; }
.equalizer span:nth-child(3) { animation-delay: 1s; height: 16px; }

@keyframes equalizer {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1); }
}

.player-toggle.playing .play-icon {
    display: none;
}

.player-toggle.playing .equalizer {
    display: flex;
}

/* 播放器面板 - 透明玻璃效果 */
.player-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    max-width: 90vw;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    padding: 0;
    display: none;
    overflow: hidden;
    transition: all 0.3s ease;
}

.player-panel.active {
    display: block;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 播放器头部 */
.player-header {
    background: linear-gradient(135deg, rgba(106, 17, 203, 0.9) 0%, rgba(37, 117, 252, 0.9) 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    cursor: default;
}

.player-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.header-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.header-controls button.active {
    background: rgba(255, 255, 255, 0.4);
}

.close-player {
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: transform 0.2s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-player:hover {
    transform: scale(1.2);
}

/* 播放列表 */
.playlist-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.playlist-container.expanded {
    max-height: 250px;
}

.playlist-header {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.03);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    cursor: default;
}

.playlist-count {
    font-size: 12px;
    color: #888;
    font-weight: normal;
}

.playlist {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

.playlist::-webkit-scrollbar {
    width: 4px;
}

.playlist::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.playlist::-webkit-scrollbar-thumb {
    background: rgba(106, 17, 203, 0.5);
    border-radius: 2px;
}

.playlist li {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    font-size: 14px;
    user-select: none;
    -webkit-user-select: none;
}

.playlist li:hover {
    background: rgba(106, 17, 203, 0.05);
}

.playlist li.playing {
    background: rgba(106, 17, 203, 0.1);
    color: #6a11cb;
    font-weight: 500;
}

.playlist li .file-icon {
    margin-right: 10px;
    font-size: 16px;
    opacity: 0.7;
}

/* 播放控制 */
.player-controls {
    padding: 20px;
}

.song-info {
    text-align: center;
    margin-bottom: 20px;
}

.song-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

.song-artist {
    font-size: 12px;
    color: #666;
    opacity: 0.8;
}

/* 进度条 - 带小圆点 */
.progress-container {
    margin-bottom: 20px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    margin-bottom: 8px;
    touch-action: none;
}

.progress {
    height: 100%;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s ease;
    position: relative;
}

.progress-handle {
    position: absolute;
    top: 50%;
    right: -6px;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid #6a11cb;
    border-radius: 50%;
    transform: translateY(-50%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.2s ease;
    touch-action: none;
}

.progress-bar:hover .progress-handle,
.progress-bar.dragging .progress-handle {
    opacity: 1;
}

.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #888;
}

/* 控制按钮 */
.control-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
}

.control-btn {
    background: rgba(106, 17, 203, 0.1);
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 12px;
    border-radius: 50%;
    transition: all 0.2s ease;
    color: #6a11cb;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:hover {
    background: rgba(106, 17, 203, 0.2);
    transform: scale(1.1);
}

.play-btn, .pause-btn {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    width: 50px;
    height: 50px;
    box-shadow: 0 4px 15px rgba(106, 17, 203, 0.3);
}

.play-btn:hover, .pause-btn:hover {
    box-shadow: 0 6px 20px rgba(106, 17, 203, 0.4);
    transform: scale(1.05);
}

/* 额外控制 */
.extra-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.volume-icon {
    font-size: 16px;
    color: #666;
}

.volume-slider {
    flex: 1;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    max-width: 80px;
    touch-action: manipulation;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #6a11cb;
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #6a11cb;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* 循环模式指示 */
.loop-btn.active[data-mode="all"]::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: #6a11cb;
    border-radius: 50%;
}

.loop-btn.active[data-mode="one"] {
    background: rgba(106, 17, 203, 0.2);
}

/* 移动端适配 */
@media (max-width: 768px) {
    #floating-music-player {
        bottom: 20px;
        right: 20px;
    }
    
    .player-toggle {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    .drag-handle {
        width: 18px;
        height: 18px;
    }
    
    .drag-handle svg {
        width: 10px;
        height: 10px;
    }
    
    .player-panel {
        width: 320px;
        right: -10px;
    }
    
    .player-panel.active {
        right: 0;
    }
    
    .control-buttons {
        gap: 15px;
    }
    
    .play-btn, .pause-btn {
        width: 48px;
        height: 48px;
    }
    
    /* 移动端安全区域 */
    @supports (padding: max(0px)) {
        #floating-music-player {
            bottom: max(20px, env(safe-area-inset-bottom));
            right: max(20px, env(safe-area-inset-right));
        }
    }
}

/* 小屏幕手机适配 */
@media (max-width: 480px) {
    .player-panel {
        width: 280px;
        max-width: 85vw;
    }
    
    .player-controls {
        padding: 15px;
    }
    
    .control-buttons {
        gap: 12px;
    }
    
    .play-btn, .pause-btn {
        width: 45px;
        height: 45px;
    }
    
    .control-btn {
        padding: 10px;
        font-size: 18px;
    }
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { color: rgba(0,0,0,0); text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0); }
    40% { color: #666; text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0); }
    60% { text-shadow: .25em 0 0 #666, .5em 0 0 rgba(0,0,0,0); }
    80%, 100% { text-shadow: .25em 0 0 #666, .5em 0 0 #666; }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .player-panel {
        background: rgba(40, 40, 40, 0.95);
        color: white;
    }
    
    .playlist-header {
        background: rgba(255, 255, 255, 0.05);
        color: #ccc;
    }
    
    .playlist li {
        color: #ccc;
    }
    
    .playlist li:hover {
        background: rgba(106, 17, 203, 0.1);
    }
    
    .song-title {
        color: white;
    }
    
    .song-artist {
        color: #aaa;
    }
    
    .progress-bar {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .control-btn {
        color: #6a11cb;
        background: rgba(106, 17, 203, 0.15);
    }
    
    .volume-slider {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* 拖拽时的视觉反馈 */
.ui-draggable-dragging .player-toggle {
    cursor: grabbing !important;
    transform: scale(1.05);
    box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.5), 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* 位置边界保护 */
#floating-music-player.boundary-left {
    left: 10px !important;
    right: auto !important;
}

#floating-music-player.boundary-right {
    right: 10px !important;
    left: auto !important;
}

#floating-music-player.boundary-top {
    top: 10px !important;
    bottom: auto !important;
}

#floating-music-player.boundary-bottom {
    bottom: 10px !important;
    top: auto !important;
}

/* 移动端点击优化 */
.player-toggle.mobile-touch {
    -webkit-tap-highlight-color: transparent;
}

/* 确保播放器在最上层 */
#floating-music-player * {
    box-sizing: border-box;
}