/* Moment Music Player - 样式文件 */

/* 字体导入 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');

/* 基础样式 */
body {
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* 播放器容器 */
#player-container {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 1s ease;
}

#player-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

#player-content {
    position: relative;
    z-index: 10; /* 高于进度条以确保内容可见 */
    height: 100vh;
    display: flex;
    flex-direction: column;
    pointer-events: none; /* 容器不拦截事件，让点击穿透到进度条 */
}

/* 确保时间标签可以被脚本动态定位 */
#current-time,
#total-duration {
    position: absolute;
}

/* 确保歌词按钮可以接收事件 */
#player-content button {
    pointer-events: auto;
}

/* 进度条样式（替换为Canvas波形+进度遮罩） */
/* 全屏进度条覆盖层：位于背景图上方，其它控件下方 */
.progress-bar-container {
    position: absolute;
    inset: 0; /* 覆盖整个播放器容器 */
    z-index: 5; /* 确保在所有内容之上以接收点击事件 */
    background: transparent; /* 全透明背景 */
    pointer-events: auto; /* 允许点击以进行进度跳转 */
    cursor: pointer; /* 悬停时显示"手指点击"图标 */
    -webkit-user-select: none;
    user-select: none;
}

#waveCanvas { display: none; } /* 去掉中间波浪线 */

#progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2); /* 保持现在前景透明度 */
    z-index: 1;
    pointer-events: none;
}

/* 音频频谱容器 */
.audio-spectrum-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.audio-spectrum-container.active {
    opacity: 1;
}

#audio-spectrum-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 控制按钮容器 */
.controls-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 0;
    z-index: 15; /* 高于进度条以确保控件可点击 */
    background-color: transparent;
    pointer-events: none; /* 容器不拦截事件 */
}

/* 确保控件内的按钮可以接收事件 */
.controls-container button,
.controls-container input {
    pointer-events: auto;
}

/* 音量控制 */
.volume-container {
    position: relative;
    display: flex;
    align-items: center;
}

#volume-slider {
    width: 80px;
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.volume-container:hover #volume-slider {
    opacity: 1;
}

/* 滑块样式 */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

input[type=range]::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* 歌词容器样式 */
#lyrics-container {
    max-height: 0;
    overflow: hidden;
    transition: all 0.5s ease;
    opacity: 0;
    margin-top: 20px;
    width: 100%;
    position: relative;
    left: 0;
    padding: 0;
    pointer-events: none; /* 不拦截进度条点击 */
}

#lyrics-container.active {
    max-height: 400px;
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 20px;
}

#lyrics-content {
    color: white;
    line-height: 1.8;
    text-align: left;
    white-space: pre-line;
    max-width: 800px;
    margin: 0 auto;
}

/* 播放列表弹窗样式 */
#playlist-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#playlist-overlay.active {
    opacity: 1;
    pointer-events: all;
}

#playlist-content {
    background-color: rgba(30, 30, 30, 0.9);
    border-radius: 12px;
    padding: 24px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.playlist-item {
    padding: 12px;
    margin: 8px 0;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.playlist-item:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.playlist-item.active {
    background-color: rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

.playlist-item .song-info {
    display: flex;
    flex-direction: column;
}

.playlist-item .song-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.playlist-item .song-artist {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

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

/* 加载状态样式 */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 1s ease-in-out infinite;
}

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

/* 错误状态样式 */
.error-message {
    background-color: rgba(255, 0, 0, 0.1);
    color: #ff6b6b;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .controls-container .flex {
        gap: 15px;
    }
    
    #player-content {
        padding: 20px;
    }
    
    #playlist-content {
        max-width: 90vw;
    }
    
    .volume-container #volume-slider {
        width: 60px;
    }

    /* 移动端优化：缩小左上/右上时间字体并与标题对齐 */
    #current-time,
    #total-duration {
        font-size: 14px; /* 覆盖 text-3xl */
        line-height: 1.2;
        letter-spacing: 0.08em;
    }
    
    /* 适度缩小标题，保持同一视觉水平线 */
    #song-title {
        font-size: 22px; /* ~text-xl 到 text-2xl 之间 */
        line-height: 1.25;
    }

    /* 控制区采用三列网格布局，避免左右与中间重叠 */
    .controls-row {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 8px;
    }
    .left-controls {
        position: static !important; /* 覆盖 absolute */
        justify-self: start;
        display: flex;
        align-items: center;
        gap: 14px;
    }
    .center-controls {
        justify-self: center;
        min-width: 160px; /* 略收紧让两侧更靠近 */
        display: flex;
        align-items: center;
        gap: 10px; /* 缩小间距让左右更靠近播放按钮 */
    }
    .right-controls {
        position: static !important; /* 覆盖 absolute */
        justify-self: end;
        display: flex !important;
        flex-wrap: nowrap;
        align-items: center;
        gap: 14px;
    }

    /* 缩小播放/暂停按钮 */
    #play-pause-btn {
        width: 56px; /* 原 64px */
        height: 56px;
    }
    #play-icon, #pause-icon {
        width: 24px;
        height: 24px;
    }

    /* 两侧图标略缩小，避免拥挤 */
    .left-controls button svg,
    .right-controls button svg {
        width: 22px;
        height: 22px;
    }
    /* 缩小上一首/下一首按钮图标尺寸 */
    #prev-btn svg,
    #next-btn svg {
        width: 22px;
        height: 22px;
    }
    .volume-container {
        min-width: 72px; /* 预留滑块空间，避免与频谱按钮重叠 */
    }
}

@media (max-width: 480px) {
    #lyrics-container.active {
        width: 95vw;
        height: 60vh;
    }
    
    .playlist-item {
        padding: 12px 15px;
    }
    
    .playlist-item .song-title {
        font-size: 14px;
    }
    
    .playlist-item .song-artist {
        font-size: 12px;
    }

    /* 更小屏幕进一步缩小时间字体 */
    #current-time,
    #total-duration {
        font-size: 12px;
    }
    /* 更小屏幕微调标题尺寸 */
    #song-title {
        font-size: 20px;
    }

    /* 更小屏幕进一步紧凑控制条 */
    .center-controls { min-width: 150px; gap: 8px; }
    .left-controls, .right-controls { gap: 12px; }
    #play-pause-btn { width: 50px; height: 50px; }
    #play-icon, #pause-icon { width: 22px; height: 22px; }
    .left-controls button svg, .right-controls button svg { width: 20px; height: 20px; }
    #prev-btn svg, #next-btn svg { width: 20px; height: 20px; }
}

/* 播放模式相关样式 */
.mode-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    z-index: 1000;
    animation: fadeInOut 2s ease-in-out;
    pointer-events: none;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-icon {
    font-size: 20px;
}

.mode-text {
    font-size: 16px;
    font-weight: 500;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

.playlist-end-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.message-content {
    background-color: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.message-content h3 {
    margin: 0 0 15px 0;
    font-size: 20px;
    font-weight: 600;
}

.message-content p {
    margin: 0 0 20px 0;
    color: #666;
}

.message-content button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.message-content button:hover {
    background-color: #0056b3;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 播放模式按钮样式 */
.play-mode-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.play-mode-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.play-mode-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.play-mode-btn.active {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* 播放统计信息样式 */
.play-stats {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px;
    border-radius: 10px;
    font-size: 12px;
    z-index: 100;
    max-width: 250px;
}

.play-stats h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
}

.play-stats-item {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
}

.play-stats-value {
    font-weight: 500;
    color: #4CAF50;
}

/* 智能推荐提示样式 */
.recommendation-hint {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 100;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}