/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'LXGW Marker Gothic', sans-serif;
    background-color: #121212;
    color: #fff;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* 使用 Flexbox 垂直排列 */
}

.container {
    display: flex;
    height: 100vh;
    flex-grow: 1;
}

/* 側邊欄 */
.sidebar {
    width: 250px;
    background-color: #000;
    padding: 20px;
    transition: transform 0.3s ease-in-out;
    /* 增加過渡效果 */
}

.search-bar {
    display: flex;
    margin-bottom: 15px;
}

.search-bar input {
    flex: 1;
    padding: 8px;
    border: none;
    background-color: #222;
    color: #fff;
    border-radius: 3px;
}

.search-bar button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    padding: 10px 0;
    cursor: pointer;
    color: #b3b3b3;
    transition: color 0.2s ease;
    /* 增加過渡效果 */
}

.sidebar li:hover,
.sidebar li.active {
    color: #fff;
}

/* 主要內容區域 */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.main-content h1,
.main-content h2 {
    margin-bottom: 20px;
}

/* 音樂播放器 */
.music-player {
    background-color: #282828;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 音樂播放器中的歌曲資訊 */
.music-player .song-info {
    display: flex;
    align-items: center;
    width: 20%;
    /* 限制 .song-info 的寬度 */
    overflow: hidden;
}

.music-player .song-info img {
    width: 50px;
    height: 50px;
    margin-right: 10px;
    border-radius: 5px;
}

/* 音樂播放器中的歌曲資訊文字容器 */
.music-player .song-info .song-details {
    width: 100%;
    /* 讓文字容器佔滿剩餘空間 */
    overflow: hidden;
    white-space: nowrap;
}

/* 音樂播放器中的歌曲標題 */
.music-player .song-info h3 {
    margin: 0;
    font-size: 1.2em;
    color: #fff;
    /* 移除overflow, white-space 和 text-overflow */
    position: relative;
    /* 保留相對定位 */
    animation: none; /* 先關閉動畫，讓 JS 控制 */
}

.music-player .song-info h3.animate-title {
    animation: scrollText 15s linear infinite;
}

/* 音樂播放器中的歌曲作者 */
.music-player .song-info p {
    margin: 0;
    font-size: 0.9em;
    color: #b3b3b3;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    /* 超過寬度時顯示省略符號 */
}

/* 推薦歌曲區塊 */
.player-controls {
    width: 20%;
    /* 控制按鈕區域的寬度 */
    display: flex;
    justify-content: center;
    /* 讓按鈕水平居中 */
    align-items: center;
}

.player-controls button {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    margin: 0 10px;
    cursor: pointer;
}

.song-progress {
    flex: 1;
    /* 讓進度條佔據剩餘空間 */
    margin: 0 20px;
    display: flex;
    align-items: center;
}

.song-progress input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 5px;
    background: #555;
    outline: none;
    -webkit-transition: .2s;
    transition: opacity .2s;
    background: linear-gradient(to right, #007bff 0%, #007bff var(--progress-percent), #555 var(--progress-percent), #555 100%);
    /* 顏色進度條 */
}

.song-progress input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    /* width: 15px; */
    /* 移除寬度 */
    /* height: 15px; */
    /* 移除高度 */
    width: 0;
    height: 0;
    background: transparent;
    /* 透明背景 */
    cursor: pointer;
    border-radius: 50%;
}

.song-progress .time {
    font-size: 12px;
    color: #b3b3b3;
    margin: 0 5px;
}

/* 跑馬燈動畫 */
@keyframes scrollText {
    0% {
        transform: translateX(10%);
    }

    50% {
        transform: translateX(-50%); /* 向左滾動 */
    }

    100% {
        transform: translateX(10%);
    }
}

/* 播放列表 */
.playlist-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.playlist-item {
    background-color: #1e1e1e;
    padding: 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

.playlist-item img {
    width: 100%;
    border-radius: 5px;
    margin-bottom: 10px;
}

#playlist-list {
    list-style: none;
    padding: 0;
}

#playlist-list li {
    padding: 10px;
    background-color: #1e1e1e;
    border-radius: 5px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#playlist-list li:hover {
    background-color: #3498db;
}

/* Genre list and music list */
.genre-list ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
}

.genre-list li {
    padding: 8px 12px;
    background-color: #1e1e1e;
    border-radius: 5px;
    margin: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease-in-out;
    /* 添加 transform 過渡效果 */
}

.genre-list li:hover,
.genre-list li.active {
    background-color: #34495e;
    transform: scale(1.05);
    /* 點擊時放大一點 */
}

#music-list {
    margin-top: 20px;
}

#music-list ul {
    list-style: none;
    padding: 0;
}

#music-list li {
    padding: 10px;
    background-color: #1e1e1e;
    border-radius: 5px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#music-list li:hover {
    background-color: #333;
}

#music-list li .song-details {
    flex: 1;
}

#music-list li .song-actions {
    display: flex;
}

#music-list li .song-actions button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    margin-left: 10px;
}

/* Featured Songs Section */
.featured-songs {
    margin-bottom: 20px;
}

.featured-songs h2 {
    margin-bottom: 15px;
}

.featured-songs-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    /* 調整磚塊大小 */
    gap: 20px;
}

.featured-song {
    background-color: #1e1e1e;
    padding: 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    /* 垂直對齊 */
}

.featured-song:hover {
    background-color: #2F4F4F;
}

.featured-song img {
    width: 80px;
    /* 調整圖片大小 */
    height: 80px;
    border-radius: 5px;
    margin-right: 15px;
}

.featured-song .song-info {
    flex: 1;
}

.featured-song .song-info h3 {
    margin: 0;
    font-size: 1.2em;
}

.featured-song .song-info p {
    margin: 0;
    color: #b3b3b3;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 10px;
        transform: translateX(0);
        /* 在小螢幕上始終顯示側邊欄 */
    }

    .main-content {
        padding: 10px;
    }

    .music-player {
        flex-direction: column;
        align-items: center;
    }

    .song-info {
        margin-bottom: 10px;
    }

    .song-progress {
        width: 100%;
        margin: 10px 0;
    }
}

/* 搜尋結果彈出視窗 */
#search-results-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    /* 半透明背景 */
    z-index: 1000;
    /* 確保在最上層 */
    overflow: auto;
    /* 內容超出時顯示捲軸 */
}

.search-results-content {
    position: relative;
    background-color: #1e1e1e;
    margin: 10% auto;
    /* 垂直和水平居中 */
    padding: 20px;
    border-radius: 5px;
    width: 80%;
    max-width: 800px;
    /* 限制最大寬度 */
}

.search-results-content h2 {
    margin-bottom: 15px;
}

.search-results-content .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    cursor: pointer;
    color: #fff;
}

/* 圖片放大檢視視窗 */
#image-viewer-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    /* 半透明背景 */
    z-index: 1001;
    /* 確保在搜尋結果上方 */
    display: flex;
    justify-content: center;
    align-items: center;
}

#image-viewer-popup img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    /* 確保圖片完整顯示 */
}

#image-viewer-popup .close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 30px;
    color: #fff;
    cursor: pointer;
}

/* 移除這個，讓javascript判斷 */
.animate-title {
  animation: scrollText 10s linear infinite !important;
}

/* 定義按鈕的基礎樣式 */
.player-controls button,
#download-button {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    margin: 0 10px;
    cursor: pointer;
    transition: color 0.3s ease; /* 添加顏色過渡效果 */
}

/* 按鈕的滑鼠懸停效果 */
.player-controls button:hover,
#download-button:hover {
    color: #007bff; /* 滑鼠懸停時變色 */
}

/* 隨機播放按鈕的樣式 */
.player-controls button#shuffle.active {
    color: #007bff; /* 藍色 */
}

/* 循環播放按鈕的樣式 (active 狀態) */
.player-controls button#repeat.active {
    color: #007bff; /* 藍色 */
}
