/* ============================================================================
   Floating Music Player - 前端播放器样式（终极强制防溢出版）
   ============================================================================ */

:root {
    --fmp-bg-primary: #0A0A0A;
    --fmp-bg-secondary: #141414;
    --fmp-bg-tertiary: #1E1E1E;
    --fmp-bg-card: rgba(20, 20, 20, 0.95);
    --fmp-neon-purple: #8A2BE2;
    --fmp-neon-purple-dark: #4B0082;
    --fmp-neon-blue: #00BFFF;
    --fmp-neon-blue-dark: #1E90FF;
    --fmp-neon-pink: #FF1493;
    --fmp-neon-pink-dark: #DB7093;
    --fmp-neon-green: #00FF00;
    --fmp-text-primary: #F0F0F0;
    --fmp-text-secondary: #A0A0A0;
    --fmp-text-muted: #666666;
    --fmp-border: rgba(255, 255, 255, 0.08);
    --fmp-border-hover: rgba(255, 255, 255, 0.15);
    --fmp-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --fmp-shadow-neon: 0 0 20px rgba(138, 43, 226, 0.3);
    --fmp-radius: 16px;
    --fmp-radius-sm: 8px;
    --fmp-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --fmp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 强制定位，防止被主题父级 div 限制 */
.fmp-container {
    position: fixed !important;
    z-index: 999999 !important;
    font-family: var(--fmp-font);
    -webkit-font-smoothing: antialiased;
    user-select: none;
    box-sizing: border-box;

    left: 20px;
    bottom: 20px;
    right: auto;
    top: auto;
}

.fmp-container * {
    box-sizing: border-box;
}

/* 直接固定左下角，保留这个选择器也不会影响 */
.fmp-container[data-position="bottom-right"] {
    left: 20px;
    bottom: 100px;
    right: auto;
    top: auto;
}

.fmp-container[data-position="bottom-left"] {
    left: 20px;
    bottom: 20px;
    right: auto;
    top: auto;
}

/* 最小化状态条 */
.fmp-mini-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--fmp-bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--fmp-border);
    border-radius: 50px;
    padding: 8px 16px 8px 8px;
    cursor: pointer;
    box-shadow: var(--fmp-shadow);
    transition: all var(--fmp-transition);
    min-width: 280px;
}

.fmp-mini-bar:hover {
    border-color: var(--fmp-neon-purple);
    box-shadow: var(--fmp-shadow), var(--fmp-shadow-neon);
    transform: translateY(-2px);
}

.fmp-mini-cover {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--fmp-neon-purple);
    box-shadow: 0 0 12px rgba(138, 43, 226, 0.4);
}

.fmp-mini-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.fmp-mini-spin {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    border-top-color: var(--fmp-neon-blue);
    border-radius: 50%;
    animation: fmp-spin 1s linear infinite;
}

.fmp-mini-bar.playing .fmp-mini-spin {
    display: block;
}

.fmp-mini-bar.playing .fmp-mini-cover-img {
    animation: fmp-cover-spin 8s linear infinite;
}

.fmp-mini-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.fmp-mini-artist {
    color: var(--fmp-text-secondary);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fmp-mini-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fmp-mini-controls button {
    background: none;
    border: none;
    color: var(--fmp-text-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--fmp-transition);
}

.fmp-mini-controls button:hover {
    color: var(--fmp-neon-purple);
    background: rgba(138, 43, 226, 0.15);
}

.fmp-mini-play {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--fmp-neon-purple), var(--fmp-neon-blue)) !important;
    border-radius: 50% !important;
    box-shadow: 0 0 16px rgba(138, 43, 226, 0.5);
}

/* =========================================================
   核心修复：最高权限拦截高度，绝不允许超出屏幕
   ========================================================= */
.fmp-player {
    width: var(--fmp-width, 360px);
    max-height: calc(100vh - 40px) !important;
    max-width: 100vw !important;
    height: auto !important;
    display: flex;
    flex-direction: column;
    background: var(--fmp-bg-card);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--fmp-border);
    border-radius: var(--fmp-radius);
    box-shadow: var(--fmp-shadow);
    overflow: hidden;
    transition: box-shadow var(--fmp-transition), border var(--fmp-transition);
    animation: fmp-slide-up 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes fmp-slide-up {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 头部可拖拽区域 */
.fmp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--fmp-border);
    background: linear-gradient(180deg, rgba(138, 43, 226, 0.08) 0%, transparent 100%);
    flex-shrink: 0;
    cursor: move;
}

.fmp-header-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--fmp-text-primary);
    background: linear-gradient(135deg, var(--fmp-neon-purple), var(--fmp-neon-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fmp-header-actions { display: flex; gap: 6px; }
.fmp-header-actions button {
    background: none;
    border: none;
    color: var(--fmp-text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--fmp-transition);
}
.fmp-header-actions button:hover {
    color: var(--fmp-text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* 封面与波形 */
.fmp-cover-section {
    padding: 12px 18px 4px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}
.fmp-cover-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.fmp-cover-disc {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--fmp-neon-purple);
    box-shadow: 0 0 25px rgba(138, 43, 226, 0.25);
    position: relative;
}
.fmp-cover-disc::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: var(--fmp-bg-primary);
    border-radius: 50%;
    border: 2px solid var(--fmp-neon-purple);
    z-index: 2;
}
.fmp-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.fmp-player.playing .fmp-cover-img {
    animation: fmp-cover-spin 12s linear infinite;
}
@keyframes fmp-cover-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.fmp-wave-canvas {
    margin-top: 8px;
    width: 100%;
    height: 44px;
    opacity: 0.85;
}

/* 信息、进度、控制 */
.fmp-song-info {
    text-align: center;
    padding: 6px 18px 10px;
    flex-shrink: 0;
}
.fmp-song-title {
    margin: 0 0 2px;
    font-size: 16px;
    font-weight: 700;
    color: var(--fmp-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fmp-song-artist {
    margin: 0 0 2px;
    font-size: 13px;
    color: var(--fmp-neon-blue);
    font-weight: 500;
}
.fmp-song-album {
    margin: 0;
    font-size: 11px;
    color: var(--fmp-text-muted);
}

.fmp-progress-section {
    padding: 0 18px 8px;
    flex-shrink: 0;
}
.fmp-progress-bar {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: height var(--fmp-transition);
}
.fmp-progress-bar:hover {
    height: 6px;
}
.fmp-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fmp-neon-purple), var(--fmp-neon-blue), var(--fmp-neon-pink));
    border-radius: 2px;
    position: relative;
    transition: width 0.1s linear;
}
.fmp-progress-fill::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: var(--fmp-neon-purple);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(138, 43, 226, 0.8);
    opacity: 0;
    transition: opacity var(--fmp-transition);
}
.fmp-progress-bar:hover .fmp-progress-fill::after {
    opacity: 1;
}
.fmp-time-display {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--fmp-text-muted);
}

.fmp-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 4px 18px 10px;
    flex-shrink: 0;
}
.fmp-controls button {
    background: none;
    border: none;
    color: var(--fmp-text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--fmp-transition);
}
.fmp-controls button:hover {
    color: var(--fmp-neon-purple);
    transform: scale(1.1);
}
.fmp-btn-play {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--fmp-neon-purple), var(--fmp-neon-blue)) !important;
    border-radius: 50% !important;
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.4);
}
.fmp-btn-shuffle.active,
.fmp-btn-repeat.active {
    color: var(--fmp-neon-purple) !important;
}

.fmp-volume-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px 10px;
    flex-shrink: 0;
}
.fmp-btn-volume {
    background: none;
    border: none;
    color: var(--fmp-text-secondary);
    padding: 4px;
}
.fmp-volume-slider {
    flex: 1;
    cursor: pointer;
}
.fmp-volume-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}
.fmp-volume-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fmp-neon-blue), var(--fmp-neon-purple));
    border-radius: 2px;
}

.fmp-action-bar {
    display: flex;
    gap: 6px;
    padding: 0 18px 12px;
    flex-shrink: 0;
}
.fmp-btn-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 10px;
    border: 1px solid var(--fmp-border);
    border-radius: var(--fmp-radius-sm);
    background: rgba(255, 255, 255, 0.02);
    color: var(--fmp-text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--fmp-transition);
}

/* =========================================================
   强制让列表区域产生内卷（滚动），绝不向外撑开父级
   ========================================================= */
.fmp-playlist-section {
    border-top: 1px solid var(--fmp-border);
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    flex: 1 1 150px !important;
    min-height: 100px !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
}

.fmp-playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}
.fmp-playlist-header h4 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--fmp-text-primary);
}
.fmp-playlist-count {
    font-size: 11px;
    color: var(--fmp-text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 6px;
    border-radius: 10px;
}

.fmp-playlist {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto !important;
    height: 100% !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.fmp-playlist::-webkit-scrollbar {
    width: 4px;
}
.fmp-playlist::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

.fmp-playlist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    cursor: pointer;
    transition: all var(--fmp-transition);
    border-left: 3px solid transparent;
}
.fmp-playlist-item:hover {
    background: rgba(255, 255, 255, 0.03);
}
.fmp-playlist-item.active {
    background: rgba(138, 43, 226, 0.1);
    border-left-color: var(--fmp-neon-purple);
}
.fmp-playlist-index {
    width: 16px;
    font-size: 12px;
    color: var(--fmp-text-muted);
    text-align: center;
    flex-shrink: 0;
}
.fmp-playlist-thumb {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}
.fmp-playlist-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.fmp-playlist-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.fmp-playlist-title {
    font-size: 13px;
    color: var(--fmp-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fmp-playlist-artist {
    font-size: 11px;
    color: var(--fmp-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fmp-playlist-duration {
    font-size: 11px;
    color: var(--fmp-text-muted);
    flex-shrink: 0;
}

/* 响应式 */
@media (max-width: 768px) {
    .fmp-container[data-position="bottom-right"],
    .fmp-container[data-position="bottom-left"] {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .fmp-player {
        width: 100% !important;
        max-height: calc(100vh - 24px) !important;
    }

    .fmp-playlist-section {
        flex: 1 1 130px !important;
    }

    .fmp-cover-disc {
        width: 110px;
        height: 110px;
    }
}

/* 拖拽效果与亮色主题 */
.fmp-container.dragging {
    opacity: 0.95;
}
.fmp-container.dragging .fmp-player {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), var(--fmp-shadow-neon);
}

.fmp-container[data-theme="light"] {
    --fmp-bg-primary: #FFFFFF;
    --fmp-bg-secondary: #F5F5F5;
    --fmp-bg-tertiary: #EEEEEE;
    --fmp-bg-card: rgba(255, 255, 255, 0.96);
    --fmp-text-primary: #1A1A1A;
    --fmp-text-secondary: #666666;
    --fmp-text-muted: #999999;
    --fmp-border: rgba(0, 0, 0, 0.06);
    --fmp-border-hover: rgba(0, 0, 0, 0.12);
    --fmp-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}
.fmp-container[data-theme="light"] .fmp-btn-play,
.fmp-container[data-theme="light"] .fmp-mini-play {
    color: #FFFFFF !important;
}

/* 紧凑模式 */
.fmp-container[data-compact="true"] .fmp-player {
    width: 290px;
}
.fmp-container[data-compact="true"] .fmp-cover-disc {
    width: 100px;
    height: 100px;
}
.fmp-container[data-compact="true"] .fmp-playlist-section {
    flex: 0 1 130px !important;
}