/***
 * @package CPlayer-Pro
 * @author ChKSz
 * @version 1.1
 * @date 2025-08-29
*/
:root {
    /* Dark Theme Variables (Black-Green) */
    --bg-color: #0d1a0f; /* Deep dark green background */
    --primary-color: #00ff7f; /* Bright green (SpringGreen) */
    --secondary-color: #1a2b1f; /* Slightly lighter dark green */
    --text-color: #e0e0e0;
    --text-light-color: #a0a0a0;
    --cover-shadow-color: rgba(0, 255, 127, 0.3);
    --button-border-color: var(--primary-color);
    --button-bg-hover: var(--primary-color);
    --button-text-hover: var(--bg-color); /* Text color on button hover is background color */
    --progress-bar-bg: rgba(0, 255, 127, 0.2);
    --player-container-bg: rgba(0, 0, 0, 0.4); /* Used for gradient, ensure it's a solid-like color for best effect */
    --search-input-bg: rgba(0, 255, 127, 0.1);
    --search-input-border: var(--primary-color);
    --search-item-hover-bg: rgba(0, 255, 127, 0.15);
    --scrollbar-thumb-color: var(--primary-color);
    --scrollbar-track-color: rgba(0, 255, 127, 0.1);

    /* Visual Effect Style Variables */
    --cover-size: 220px;
    --canvas-size: 400px; /* Increased canvas size */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
                 Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.5s ease, color 0.5s ease;
    padding: 20px 15px;
}

.main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    margin: 50px auto 0;
    padding: 0;
}

.search-row {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
    padding: 0 10px;
}

.search-section {
    width: 100%;
    max-width: 800px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.content-row {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: flex-start; /* Changed to flex-start */
    justify-content: center;
    gap: 25px;
}

.player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
    margin-top: 0;
}

.lyrics-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
}

.player-container {
    width: 100%;
    max-width: 500px; /* 确保与歌词容器宽度一致 */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    padding: 20px;
    height: 580px; /* 固定高度，与歌词容器和歌单容器保持一致 */
    background-color: var(--player-container-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.playlist-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 500px;
    background-color: var(--player-container-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 15px;
    height: 580px;
    overflow: hidden;
}

.lyrics-container {
    width: 100%;
    height: 580px; /* 固定高度 */
    max-width: 500px; /* 确保与播放器容器宽度一致 */
    overflow-y: auto;
    text-align: center;
    position: relative;
    padding: 20px 15px;
    background-color: var(--player-container-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.lyrics-container::-webkit-scrollbar { 
    display: none; 
}

.lyrics-container.has-lyrics {
    justify-content: flex-start; /* 有歌词时从顶部开始对齐 */
}

/* 移动端适配 */
@media (max-width: 768px) {
    .content-row {
        flex-direction: column;
        align-items: center;
    }
    
    .player-lyrics-section, .playlist-section {
        width: 100%;
        max-width: 100%;
    }
    
    .playlist-section {
        margin-top: 25px;
        height: 400px;
    }
    
    .player-container {
        max-width: 100%;
    }
}

.lyrics-container::-webkit-scrollbar { display: none; }

.lyrics-container.has-lyrics {
    justify-content: flex-start; /* Align lyrics to top when present */
}

.search-section input {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid var(--search-input-border);
    border-radius: 25px;
    background-color: var(--search-input-bg);
    color: var(--text-color);
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    min-width: 0;
}

.search-section input::placeholder { color: var(--text-light-color); }
.search-section input:focus { box-shadow: 0 0 10px var(--cover-shadow-color); }

.search-section button {
    padding: 12px 20px;
    background-color: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-weight: bold;
    flex-shrink: 0;
}

.search-results {
    width: 100%;
    max-width: 800px;
    max-height: 250px;
    overflow-y: auto;
    background-color: var(--player-container-bg);
    backdrop-filter: blur(5px);
    border-radius: 10px;
    padding: 5px;
    margin-top: 5px;
    display: none;
    z-index: 100; /* Ensure search results are on top */
    position: relative;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.search-results::-webkit-scrollbar { display: none; }

.search-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(128,128,128,0.1);
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background-color: var(--search-item-hover-bg); }
.search-item .song-name { font-weight: 500; }
.search-item .artist-list { font-size: 0.85em; color: var(--text-light-color); }

/* 歌单上传区域样式 */
.playlist-upload-area {
    width: 100%;
    max-width: 800px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.upload-container {
    width: 100%;
    padding: 30px 20px;
    border: 2px dashed var(--primary-color);
    border-radius: 15px;
    background-color: var(--search-input-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-container:hover {
    background-color: var(--search-item-hover-bg);
    transform: scale(1.01);
}

.upload-container.dragover {
    background-color: var(--search-item-hover-bg);
    border-color: #00ff7f;
    box-shadow: 0 0 15px var(--cover-shadow-color);
}

.upload-icon {
    font-size: 40px;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.upload-container p {
    color: var(--text-color);
    text-align: center;
}

.upload-container label {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
}

.playlist-info {
    width: 100%;
    padding: 15px;
    background-color: var(--player-container-bg);
    backdrop-filter: blur(5px);
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.playlist-info h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
    text-align: center;
}

.playlist-songs {
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.playlist-songs::-webkit-scrollbar { display: none; }

.playlist-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(128,128,128,0.1);
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.playlist-item:last-child { border-bottom: none; }
.playlist-item:hover { background-color: var(--search-item-hover-bg); }
.playlist-item.active { background-color: var(--search-item-hover-bg); color: var(--primary-color); }

.playlist-item .song-info {
    text-align: left;
}

.playlist-item .song-name {
    font-size: 14px;
    margin-bottom: 3px;
}

.playlist-item .song-artist {
    font-size: 12px;
    color: var(--text-light-color);
}

.visualizer-container {
    position: relative;
    width: var(--canvas-size);
    height: var(--canvas-size);
    margin-top: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#audioVisualizer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.album-art-wrapper {
    width: var(--cover-size);
    height: var(--cover-size);
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 25px var(--cover-shadow-color);
    position: relative;
    z-index: 2;
    border: 3px solid rgba(128,128,128,0.1);
    transition: box-shadow 0.5s ease, width 0.3s ease, height 0.3s ease;
}

#albumArt {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    animation: rotateArt 20s linear infinite paused;
}

#albumArt.playing { animation-play-state: running; }

@keyframes rotateArt { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.song-info { margin-bottom: 15px; }
.song-title { font-size: 20px; font-weight: bold; margin-bottom: 5px; }
.artist-name { font-size: 14px; color: var(--text-light-color); }

.custom-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 320px;
    margin-bottom: 15px;
}

.time-display {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 13px;
    color: var(--text-light-color);
    margin-bottom: 8px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--progress-bar-bg);
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 15px;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

#progressBar {
    width: 0%;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 4px;
    transition: width 0.1s linear, background-color 0.5s ease;
}

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

.control-buttons button {
    background-color: transparent;
    border: 2px solid var(--button-border-color);
    color: var(--primary-color);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-buttons button#playPauseBtn { width: 55px; height: 55px; font-size: 26px; }

.control-buttons button:hover {
    background-color: var(--button-bg-hover);
    color: var(--button-text-hover);
    transform: scale(1.05);
}

/* 播放模式控制按钮 */
.play-mode-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.play-mode-controls button {
    background-color: transparent;
    border: 2px solid var(--button-border-color);
    color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.play-mode-controls button:hover {
    background-color: var(--button-bg-hover);
    color: var(--button-text-hover);
}

.play-mode-controls button.mode-active {
    background-color: var(--primary-color);
    color: var(--bg-color);
}

.lyric-line {
    padding: 10px 0;
    font-size: 17px;
    color: var(--text-light-color);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.5;
    transform-origin: center;
    will-change: transform, opacity;
    position: relative;
    cursor: pointer;
}

.lyric-line.active {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 20px;
    transform: scale(1.05);
    opacity: 1;
    text-shadow: 0 0 10px var(--primary-color);
}

.lyric-line.previous, .lyric-line.next {
    opacity: 0.6;
    font-size: 18px;
    transform: scale(0.98);
}

/* 移除歌词容器的黑色渐变效果 */

.footer {
    margin-top: 40px;
    font-size: 12px;
    color: var(--text-light-color);
    opacity: 0.8;
    text-align: center;
    width: 100%;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover { text-decoration: underline; }

.loader {
    border: 4px solid var(--progress-bar-bg);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
    display: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile Responsive */
@media (max-width: 768px) {
    body { padding: 10px; }
    .main-container { margin-top: 40px; padding: 0 5px; }
    .search-row { margin-bottom: 20px; padding: 0 5px; }
    .search-section { max-width: 100%; }
    .search-results { max-width: calc(100% - 10px); left: 0; right: 0; margin-left: auto; margin-right: auto; }

    .content-row { flex-direction: column; align-items: center; gap: 20px; }
    .player-section, .lyrics-section { width: 100%; max-width: none; flex: none; }
    .player-container, .lyrics-container { width: 100%; height: auto; min-height: 0; }
    .player-container { padding: 15px; }
    .lyrics-container { max-height: 400px; padding: 15px 10px; }

    .lyrics-container::before, .lyrics-container::after { height: 40px; }

    :root {
        --cover-size: 180px;
        --canvas-size: 280px;
    }

    #audioVisualizer {
        width: var(--canvas-size) !important;
        height: var(--canvas-size) !important;
    }

    .song-title { font-size: 18px; }
    .artist-name { font-size: 13px; }
    .lyric-line { font-size: 15px; padding: 8px 0;}
    .lyric-line.active { font-size: 18px; }
    .lyric-line.previous, .lyric-line.next { font-size: 16px; }

    .custom-controls { max-width: 100%; }
    .control-buttons button { width: 40px; height: 40px; font-size: 18px;}
    .control-buttons button#playPauseBtn { width: 50px; height: 50px; font-size: 24px;}
    .play-mode-controls button { width: 35px; height: 35px; font-size: 16px; }

    .footer { margin-top: 25px; }
}

@media (max-width: 480px) {
    :root {
        --cover-size: 150px;
        --canvas-size: 230px;
    }
    .song-title { font-size: 16px; }
    .artist-name { font-size: 12px; }
    .lyric-line { font-size: 14px; padding: 7px 0;}
    .lyric-line.active { font-size: 16px; }
    .lyric-line.previous, .lyric-line.next { font-size: 15px; }
    .play-mode-controls { gap: 10px; }
    .play-mode-controls button { width: 30px; height: 30px; font-size: 14px; }
}