/* ========== 全局样式重置与变量 ========== */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --background-main: #0a0a0a;
    --background-card: rgba(255, 255, 255, 0.03);
    --background-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-accent: #667eea;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-primary: 0 20px 40px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 30px 60px rgba(0, 0, 0, 0.4);
    --border-radius: 24px;
    --animation-duration: 0.6s;
    --animation-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background-main);
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* ========== 动态背景与浮动元素 ========== */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.floating-bubble {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(45deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    backdrop-filter: blur(20px);
    animation: float 20s infinite ease-in-out;
}

.floating-bubble:nth-child(1) {
    width: 80px;
    height: 80px;
    left: 10%;
    animation-delay: 0s;
}

.floating-bubble:nth-child(2) {
    width: 120px;
    height: 120px;
    left: 70%;
    animation-delay: 5s;
}

.floating-bubble:nth-child(3) {
    width: 60px;
    height: 60px;
    left: 40%;
    animation-delay: 10s;
}

.floating-bubble:nth-child(4) {
    width: 100px;
    height: 100px;
    left: 80%;
    animation-delay: 15s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10%, 90% {
        opacity: 0.6;
    }
    50% {
        transform: translateY(-100px) rotate(180deg);
        opacity: 0.8;
    }
}

/* ========== 主应用容器 ========== */
.app-container {
    max-width: 420px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--background-glass);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    transition: all var(--animation-duration) var(--animation-ease);
}

/* ========== 音乐生成专注模式 ========== */
.app-container.music-generation-mode {
    /* 专注模式下的特殊布局 */
}

.app-container.music-generation-mode .app-content {
    gap: 20px; /* 保持正常间距 */
    position: relative;
}

.app-container.music-generation-mode .chat-container {
    /* 聊天区域在专注模式下保持正常样式 */
    margin-bottom: 0;
}

.app-container.music-generation-mode .progress-container {
    /* 进度条占据输入框的位置 */
    position: absolute;
    bottom: 0;
    left: 24px;
    right: 24px;
    margin: 0;
    z-index: 100;
    
    /* 模拟输入框的样式，保持视觉一致性 */
    background: var(--background-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    
    /* 添加向上的渐变和发光效果 */
    box-shadow: 
        0 -4px 20px rgba(102, 126, 234, 0.15),
        0 0 40px rgba(102, 126, 234, 0.1);
    
    /* 动画过渡 */
    transform: translateY(0);
    transition: all var(--animation-duration) var(--animation-ease);
}

.app-container.music-generation-mode .progress-container::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--text-accent), transparent);
    opacity: 0.6;
    animation: connectionPulse 2s ease-in-out infinite;
    border-radius: 1px;
}

@keyframes connectionPulse {
    0%, 100% { 
        opacity: 0.4; 
        transform: scaleX(0.8);
    }
    50% { 
        opacity: 0.8; 
        transform: scaleX(1);
    }
}

.app-container.music-generation-mode .message-area {
    /* 聊天区域保持正常样式 */
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

/* 专注模式下的进度条标签特殊样式 */
.app-container.music-generation-mode .progress-label {
    color: var(--text-accent);
    font-weight: 600;
    text-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
    font-size: 15px;
}

/* 专注模式下的进度条增强样式 */
.app-container.music-generation-mode .progress-bar {
    background: var(--success-gradient);
    box-shadow: 0 0 20px rgba(79, 172, 254, 0.3);
}

/* 确保专注模式下有足够的底部空间 */
.app-container.music-generation-mode .app-content {
    padding-bottom: 140px; /* 为进度条留出空间 */
}

/* ========== 顶部标题区域 ========== */
.app-header {
    padding: 30px 24px 20px;
    text-align: center;
    background: var(--primary-gradient);
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: headerShine 8s infinite linear;
}

@keyframes headerShine {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.app-subtitle {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 400;
    position: relative;
    z-index: 1;
    margin-bottom: 16px;
}

.header-actions {
    position: relative;
    z-index: 1;
}

.history-link {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--animation-duration) var(--animation-ease);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.history-link:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ========== 主内容区域 ========== */
.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
}

/* ========== 对话区域 ========== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 400px;
}

.message-area {
    flex: 1;
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
    background: var(--background-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    scroll-behavior: smooth;
}

.message-area::-webkit-scrollbar {
    width: 6px;
}

.message-area::-webkit-scrollbar-track {
    background: transparent;
}

.message-area::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3px;
}

.message {
    margin-bottom: 16px;
    animation: messageSlideIn var(--animation-duration) var(--animation-ease);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    text-align: right;
}

.message.system {
    text-align: left;
}

.message-bubble {
    display: inline-block;
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    backdrop-filter: blur(10px);
}

.message.user .message-bubble {
    background: var(--primary-gradient);
    color: white;
    margin-left: auto;
}

.message.system .message-bubble {
    background: var(--background-glass);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* ========== 输入区域 ========== */
.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    padding: 20px;
    background: var(--background-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#user_input {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-radius: 20px;
    background: var(--background-glass);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    border: 1px solid var(--border-color);
    transition: all var(--animation-duration) var(--animation-ease);
}

#user_input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

#user_input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.send-button {
    padding: 16px;
    border: none;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    cursor: pointer;
    transition: all var(--animation-duration) var(--animation-ease);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: var(--shadow-primary);
}

.send-button:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-hover);
}

.send-button:active {
    transform: translateY(-1px) scale(0.98);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== 进度条区域 ========== */
.progress-container {
    padding: 20px;
    background: var(--background-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--animation-duration) var(--animation-ease);
    margin-top: 0; /* 默认无间距 */
}

.progress-container.show {
    opacity: 1;
    transform: translateY(0);
}

.progress-label {
    text-align: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: var(--background-glass);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: var(--success-gradient);
    width: 0%;
    transition: width 0.8s var(--animation-ease);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

/* ========== 艺术感音乐播放器 ========== */
.music-player-container {
    margin-top: 24px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9) translateY(30px);
    transition: all 0.8s var(--animation-ease);
}

.music-player-container.show {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.music-player-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    animation: musicPlayerRotate 10s infinite linear;
    z-index: -1;
}

@keyframes musicPlayerRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.music-header {
    text-align: center;
    margin-bottom: 20px;
}

.music-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.music-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.music-tags {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(102, 126, 234, 0.2);
    color: var(--text-accent);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.vinyl-container {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    position: relative;
}

.vinyl-disc {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a1a, #333);
    border: 3px solid #444;
    position: relative;
    animation: vinylSpin 3s infinite linear;
}

.vinyl-disc.playing {
    animation-duration: 2s;
}

.vinyl-disc::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: #666;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.vinyl-disc::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    border: 1px solid #555;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.vinyl-cover {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    transform: translate(-50%, -50%);
    z-index: 1;
    border: 2px solid #333;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

@keyframes vinylSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.audio-player {
    width: 100%;
    outline: none;
    background: transparent;
    margin-bottom: 20px;
}

.audio-player::-webkit-media-controls-panel {
    background: var(--background-glass);
    border-radius: 12px;
}

/* ========== 歌词区域 ========== */
.lyrics-container {
    margin-top: 20px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.lyrics-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 12px;
    text-align: center;
}

.lyrics-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    text-align: center;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

.lyrics-content::-webkit-scrollbar {
    width: 4px;
}

.lyrics-content::-webkit-scrollbar-track {
    background: transparent;
}

.lyrics-content::-webkit-scrollbar-thumb {
    background: var(--text-accent);
    border-radius: 2px;
}

/* ========== 加载状态 ========== */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-accent);
    animation: loadingBounce 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes loadingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========== 历史记录页面样式 ========== */
.history-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
}

.history-header {
    text-align: center;
    margin-bottom: 32px;
}

.history-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.history-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.back-link {
    display: inline-block;
    padding: 12px 24px;
    background: var(--primary-gradient);
    color: white;
    text-decoration: none;
    border-radius: 24px;
    font-weight: 500;
    margin-bottom: 24px;
    transition: all var(--animation-duration) var(--animation-ease);
}

.back-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.history-item {
    background: var(--background-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 20px;
    backdrop-filter: blur(10px);
    transition: all var(--animation-duration) var(--animation-ease);
}

.history-item:hover {
    transform: translateY(-4px);
    border-color: var(--text-accent);
    box-shadow: var(--shadow-primary);
}

.history-item-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.history-item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.history-item-prompt {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 8px;
}

.history-item-actions {
    display: flex;
    gap: 8px;
}

.play-button {
    flex: 1;
    padding: 8px 16px;
    background: var(--success-gradient);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--animation-duration) var(--animation-ease);
}

.play-button:hover {
    transform: translateY(-2px);
}

.download-button {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--animation-duration) var(--animation-ease);
}

.download-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========== 响应式设计 ========== */
@media (max-width: 480px) {
    .app-container {
        max-width: 100vw;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    .app-content {
        padding: 16px;
    }

    .app-title {
        font-size: 18px;
    }

    .message-area {
        max-height: 400px;
        padding: 16px;
    }

    .chat-container {
        min-height: 350px;
    }

    .vinyl-container {
        width: 100px;
        height: 100px;
    }

    .history-container {
        padding: 16px;
    }

    .history-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (max-height: 600px) {
    .message-area {
        max-height: 300px;
    }
    
    .chat-container {
        min-height: 250px;
    }
}

/* ========== 触摸优化 ========== */
@media (hover: none) and (pointer: coarse) {
    .send-button:hover {
        transform: none;
        box-shadow: var(--shadow-primary);
    }

    .send-button:active {
        transform: scale(0.95);
    }

    .history-item:hover {
        transform: none;
    }
}

/* ========== 成功状态动画 ========== */
.success-message {
    color: #4facfe;
    font-weight: 600;
    text-align: center;
    animation: successPulse 2s infinite;
}

@keyframes successPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 响应式设计优化 */
@media (max-width: 768px) {
    .app-container {
        padding: 15px;
    }
    
    .app-title {
        font-size: 24px;
    }
    
    .chat-container {
        margin-top: 20px;
    }
    
    .input-wrapper textarea {
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .music-player-container {
        padding: 20px;
    }
    
    .music-tags {
        justify-content: center;
    }
    
    .vinyl-container {
        width: 100px;
        height: 100px;
    }
    
    .lyrics-content {
        font-size: 14px;
    }

    .main-header {
        padding: 15px 0;
    }

    .app-subtitle {
        font-size: 14px;
    }

    .app-content {
        padding: 15px;
        gap: 15px;
    }

    .message-area {
        max-height: 45vh;
        padding: 15px;
    }

    .message-bubble {
        padding: 12px 16px;
    }

    .input-wrapper textarea {
        font-size: 16px; /* 防止iOS缩放 */
        min-height: 44px;
    }

    .send-button {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .progress-container {
        padding: 16px;
        gap: 12px;
    }

    .progress-label {
        font-size: 14px;
    }

    .progress-text {
        font-size: 13px;
    }

    /* 移动端音乐生成专注模式优化 */
    .app-container.music-generation-mode .progress-container {
        left: 15px;
        right: 15px;
        /* 移动端稍微调整位置，避免过于贴边 */
    }
    
    .app-container.music-generation-mode .app-content {
        padding-bottom: 120px; /* 移动端减少底部空间 */
    }

    /* 音乐播放器移动端优化 */
    .music-player-container {
        padding: 20px;
    }

    .vinyl-container {
        width: 180px;
        height: 180px;
    }

    .audio-player {
        margin: 20px 0;
    }

    .music-tags {
        gap: 6px;
        flex-wrap: wrap;
    }

    .tag {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* 开发者信息样式 */
.developer-footer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.developer-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.developer-link:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
}

.developer-icon {
    font-size: 16px;
}

.developer-text {
    font-weight: 500;
}

/* 移动端开发者信息样式 */
@media (max-width: 768px) {
    .developer-footer {
        bottom: 15px;
        right: 15px;
    }
    
    .developer-link {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .developer-icon {
        font-size: 14px;
    }
} 