:root {
    --primary-color: #4a6fa5;
    --secondary-color: #166088;
    --highlight-color: #4fc3f7;
    --text-color: #333;
    --light-text: #f8f9fa;
    --bg-color: #fff;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --safe-area-top: env(safe-area-inset-top, 20px);
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
    --safe-area-left: env(safe-area-inset-left, 20px);
    --safe-area-right: env(safe-area-inset-right, 20px);
}

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    padding: var(--safe-area-top) var(--safe-area-right) var(--safe-area-bottom) var(--safe-area-left);
    background-color: #f5f5f5;
    min-height: 100vh;
}

/* 主浮动播放器容器 */
.floating-player-container {
    position: fixed;
    top: var(--safe-area-top);
    right: var(--safe-area-right);
    width: 550px;
    max-height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom));
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

/* 小屏幕适配 */
@media (max-width: 480px) {
    .floating-player-container {
        width: calc(100% - var(--safe-area-left) - var(--safe-area-right));
        left: var(--safe-area-left);
        right: var(--safe-area-right);
    }
}

/* 播放器头部 - 包含标签切换 */
.player-header {
    background-color: var(--primary-color);
    color: var(--light-text);
    display: flex;
    flex-direction: column;
    cursor: move;
    padding-top: max(10px, var(--safe-area-top));
}

/* 标题和控制按钮 */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
}

.player-title {
    font-weight: bold;
    font-size: 16px;
}

.player-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    background: none;
    border: none;
    color: var(--light-text);
    cursor: pointer;
    font-size: 16px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.control-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 标签切换导航 */
.tab-nav {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.tab-btn.active {
    color: var(--light-text);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background-color: var(--highlight-color);
    border-radius: 3px 3px 0 0;
}

.tab-btn:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 标签内容区域 */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.tab-content.active {
    display: block;
}

/* 播放器内容 - 保留原有样式但调整选择器 */
#playerContent {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.now-playing {
    text-align: center;
    margin-bottom: 15px;
}

.song-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 14px;
    color: #666;
}

.progress-container {
    margin-bottom: 15px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    margin-bottom: 5px;
    cursor: pointer;
    overflow: hidden;
}

.progress {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.1s linear;
}

.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
}

.main-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
}

.play-pause-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.play-pause-btn:hover {
    transform: scale(1.05);
    background-color: var(--secondary-color);
}

.prev-btn, .next-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-color);
    cursor: pointer;
    transition: color 0.2s;
}

.prev-btn:hover, .next-btn:hover {
    color: var(--primary-color);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.volume-icon {
    color: var(--text-color);
    font-size: 18px;
}

.volume-slider {
    flex-grow: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

/* 播放模式 */
.playback-modes {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin: 20px 0;
    padding: 16px 30px;
    background-color: rgba(74, 111, 165, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(74, 111, 165, 0.1);
    min-height: 64px;
    box-sizing: border-box;
}

.mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(74, 111, 165, 0.15);
    border-radius: 10px;
    font-size: 15px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
    white-space: nowrap;
}

.mode-btn.active {
    background-color: rgba(74, 111, 165, 0.15);
    color: var(--primary-color);
    border-color: rgba(74, 111, 165, 0.3);
}

/* 播放列表样式 */
.playlist-container {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

.playlist-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.playlist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.playlist-item {
    counter-increment: playlist-counter;
    padding: 10px 15px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 5px;
    position: relative;
    white-space: normal;
    word-break: break-word;
    min-height: 50px;
}

.playlist-item::before {
    content: counter(playlist-counter);
    display: inline-block;
    width: 24px;
    text-align: center;
    margin-right: 10px;
    font-weight: bold;
    color: #666;
}

.playlist-item:hover {
    background-color: #f0f0f0;
}

.playlist-item.active {
    background-color: rgba(74, 111, 165, 0.1);
    border-left: 3px solid var(--primary-color);
}

.playlist-item.active::before {
    color: var(--primary-color);
}

.song-info {
    flex-grow: 1;
    white-space: normal;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    cursor: pointer;
    overflow: visible;
    min-width: 0;
}

.song-name {
    font-size: 14px;
    white-space: normal;
    word-break: break-word;
    width: 100%;
}

.remove-btn {
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 14px;
    margin-left: 10px;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 5px;
}

.playlist-item:hover .remove-btn {
    opacity: 1;
}

/* 歌曲库样式 */
.library-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.library-item {
    background-color: #f9f9f9;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.library-item:hover {
    background-color: #f0f0f0;
}

.library-song-info {
    flex-grow: 1;
    overflow: hidden;
}

.library-song-name {
    font-weight: bold;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-song-artist {
    font-size: 13px;
    color: #666;
}

.library-controls {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

.library-add-btn, .library-remove-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: opacity 0.2s;
}

.library-add-btn {
    background-color: #28a745;
    color: white;
}

.library-remove-btn {
    background-color: #dc3545;
    color: white;
}

.library-add-btn:hover, .library-remove-btn:hover {
    opacity: 0.8;
}

/* 添加歌曲表单 */
.add-song-form {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.form-group {
    margin-bottom: 10px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #666;
}

.form-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.add-btn, .clear-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    width: 100%;
    margin-top: 10px;
}

.clear-btn {
    background-color: #dc3545;
    max-width: 150px;
}

.add-btn:hover {
    background-color: var(--secondary-color);
}

.clear-btn:hover {
    background-color: #c82333;
}

/* 错误状态 */
.playlist-item.error {
    background-color: rgba(255, 0, 0, 0.05);
    border-left: 3px solid #ff6b6b;
}

.playlist-item.error::before {
    color: #ff6b6b;
    content: "⚠";
}

.playlist-item.error .song-name {
    color: #ff6b6b;
    text-decoration: line-through;
}

/* 提示消息 */
.toast-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    z-index: 1000;
    animation: fadeInOut 2.5s ease-in-out;
    opacity: 0;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* 重新打开按钮 */
.reopen-player-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background-color: var(--primary-color);
    color: white;
    padding: 10px 15px;
    border-radius: 50px;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
    z-index: 999;
    transition: var(--transition);
    font-size: 18px;
    font-weight: bold;
    opacity: 0.9;
}

.reopen-player-btn:hover {
    opacity: 1;
    background-color: var(--secondary-color);
    transform: translateY(-2px) scale(1.1);
}

/* 歌曲库滚动容器 */
.library-scroll-container {
    max-height: 300px; /* 固定高度，根据实际需求调整 */
    overflow-y: auto;  /* 垂直滚动条 */
    border: 1px solid #eee;
    border-radius: 8px;
    margin-top: 10px;
}

/* 优化滚动条样式（可选） */
.library-scroll-container::-webkit-scrollbar {
    width: 8px;
}
.library-scroll-container::-webkit-scrollbar-thumb {
    background-color: rgba(74, 111, 165, 0.3);
    border-radius: 4px;
}
.library-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}

/* 调整原有歌曲库列表样式 */
.library-list {
    padding: 0;
    margin: 0;
    list-style: none;
}
/* 歌曲库滚动容器 */
.library-scroll-container {
    max-height: 600px; /* 固定高度，根据实际需求调整 */
    overflow-y: auto;  /* 垂直滚动条 */
    border: 1px solid #eee;
    border-radius: 8px;
    margin-top: 10px;
}

/* 优化滚动条样式（可选） */
.library-scroll-container::-webkit-scrollbar {
    width: 8px;
}
.library-scroll-container::-webkit-scrollbar-thumb {
    background-color: rgba(74, 111, 165, 0.3);
    border-radius: 4px;
}
.library-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}

/* 调整原有歌曲库列表样式 */
.library-list {
    padding: 0;
    margin: 0;
    list-style: none;
}
/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    padding: 10px 0;
    border-top: 1px solid #eee;
}

/* 最小化状态 */
.floating-player-container.minimized {
    height: 60px;
    overflow: hidden;
}

.floating-player-container.minimized .tab-content {
    display: none;
}

.floating-player-container.minimized .tab-nav {
    display: none;
}