/* --- 全局与基础样式 --- */
:root {
    --primary-color: #00ffff;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #ffffff;
    --text-secondary-color: #b3b3b3;
    --highlight-color: #282828;
    --player-height: 90px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    overflow: hidden;
}

/* --- 布局 --- */
.container {
    display: flex;
    height: calc(100% - var(--player-height));
}

.sidebar {
    width: 350px;
    background-color: var(--surface-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--highlight-color);
}

.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

#visualizer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.5;
}

/* --- 侧边栏：搜索 --- */
.search-wrapper {
    margin-bottom: 20px;
}

#search-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--highlight-color);
    border-radius: 8px;
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 16px;
}

.search-type {
    display: flex;
    gap: 20px;
    margin: 10px 0;
}

#search-button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}
#search-button:hover {
    background-color: #00e6e6;
}

/* --- 侧边栏：结果列表 --- */
#results-container {
    flex: 1;
    overflow-y: auto;
}

#results-container ul {
    list-style: none;
}

#results-container li {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
#results-container li:hover {
    background-color: var(--highlight-color);
}

#results-container img {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    margin-right: 15px;
}

#results-container .song-details {
    display: flex;
    flex-direction: column;
}
#results-container .song-name {
    font-weight: 500;
}
#results-container .artist-name {
    font-size: 14px;
    color: var(--text-secondary-color);
}

/* --- 主内容：当前歌曲视图 --- */
.current-song-view {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.song-visuals {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 40%;
    max-width: 400px;
}

#main-album-art {
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1/1;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    object-fit: cover;
    margin-bottom: 20px;
}

.main-song-info h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-color);
}

.main-song-info p {
    font-size: 16px;
    color: var(--text-secondary-color);
}

.lyric-wrapper {
    flex: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
    /* 添加遮罩效果，让歌词上下渐隐 */
    mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
}

#lyric-container {
    height: 100%;
    overflow-y: auto;
    /* 隐藏滚动条但保留功能 */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
#lyric-container::-webkit-scrollbar { 
    display: none; 
}

#lyric {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 50% 0; /* 让第一句和最后一句也能居中 */
    font-size: 20px;
    line-height: 2;
    color: var(--text-secondary-color);
    transition: transform 0.3s ease-out; /* 平滑滚动 */
}

#lyric p {
    margin: 10px 0;
    transition: all 0.3s ease-in-out;
    opacity: 0.6;
    cursor: pointer; /* 可点击跳转 */
}

#lyric p.active {
    color: var(--primary-color);
    transform: scale(1.2);
    font-weight: bold;
    opacity: 1;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

/* --- 底部播放器 --- */
.player-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--player-height);
    background-color: var(--surface-color);
    border-top: 1px solid var(--highlight-color);
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    position: absolute;
    top: -4px;
    left: 0;
    padding: 0 5px;
}

#progress-bar {
    flex: 1;
    height: 4px;
    background-color: var(--highlight-color);
    cursor: pointer;
    border-radius: 2px;
}

#progress {
    height: 100%;
    width: 0;
    background-color: var(--primary-color);
    border-radius: 2px;
    transition: width 0.1s linear;
}

#current-time, #duration {
    font-size: 12px;
    color: var(--text-secondary-color);
    display: none; /* 默认隐藏，在进度条悬停时显示 */
}

.progress-container:hover #current-time,
.progress-container:hover #duration {
    display: block;
}

.controls-main {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    width: 100%;
}

.song-info {
    display: flex;
    align-items: center;
    justify-self: start;
}

#album-art {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    margin-right: 15px;
}

#song-title {
    font-size: 16px;
    font-weight: 500;
}
#song-artist {
    font-size: 14px;
    color: var(--text-secondary-color);
}

.center-controls {
    justify-self: center;
}

#play-pause-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--text-color);
    background-color: transparent;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}
#play-pause-button:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

#play-pause-button::before {
    content: '';
    display: block;
}

#play-pause-button.play::before {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent currentColor;
    margin-left: 4px;
}

#play-pause-button.pause::before {
    width: 4px;
    height: 14px;
    border-style: double;
    border-width: 0 0 0 14px;
    border-color: currentColor;
    margin-left: 4px;
}

.volume-container {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
}

#volume-slider {
    width: 100px;
}

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: calc(100% - var(--player-height));
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 30%; /* 限制侧边栏高度 */
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--highlight-color);
        z-index: 10;
        padding: 10px;
    }

    .main-content {
        padding: 10px;
        height: 70%; /* 剩余高度 */
    }

    .current-song-view {
        flex-direction: column;
        gap: 10px;
        justify-content: flex-start;
    }

    .song-visuals {
        width: 100%;
        max-width: 150px; /* 移动端进一步缩小封面 */
        flex-direction: row; /* 移动端横向排列封面和信息 */
        gap: 15px;
        text-align: left;
        align-items: center;
    }

    #main-album-art {
        width: 80px;
        height: 80px;
        margin-bottom: 0;
    }

    .main-song-info h2 {
        font-size: 16px;
        margin-bottom: 4px;
    }
    
    .main-song-info p {
        font-size: 14px;
    }

    .lyric-wrapper {
        width: 100%;
        flex: 1;
        mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
        -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
    }
    
    #lyric {
        font-size: 16px;
        padding: 50% 0;
    }

    /* 底部播放器适配 */
    .controls-main {
        grid-template-columns: 1fr auto;
    }

    .song-info {
        display: none; /* 在小屏幕底部隐藏歌曲信息，因为主界面已经有了 */
    }
    
    .center-controls {
        justify-self: start;
    }

    .volume-container {
        justify-self: end;
    }
    
    #volume-slider {
        width: 60px;
    }
}
