/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
}

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

/* 侧边栏样式 */
.sidebar {
    width: 300px;
    background-color: #fff;
    border-right: 1px solid #e0e0e0;
    transition: width 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-header h3 {
    font-size: 1.2rem;
    color: #333;
}

#toggleSidebar {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
}

.history-container {
    padding: 15px;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

.history-item {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.history-item:hover {
    background-color: #f0f0f0;
}

.history-item img {
    max-width: 100%;
    border-radius: 5px;
    margin-top: 10px;
}

/* 主内容区样式 */
.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

h1 {
    margin-bottom: 30px;
    color: #444;
    text-align: center;
}

/* 输入区域样式 */
.input-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
    position: relative;
}

.prompt-bubbles {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.bubble {
    background-color: #e8f4fc;
    color: #2980b9;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.bubble:hover {
    background-color: #d1e8f8;
    transform: scale(1.05);
}

.upload-container {
    margin-bottom: 20px;
}

.upload-label {
    display: inline-block;
    background-color: #3498db;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.upload-label:hover {
    background-color: #2980b9;
}

#imageUpload {
    display: none;
}

.preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.image-preview {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 5px;
    overflow: hidden;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

#promptInput {
    width: 100%;
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    min-height: 120px;
    margin-bottom: 20px;
    resize: vertical;
    font-size: 1rem;
}

/* 按钮组样式 */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    width: 100%;
}

/* 按钮共同样式 */
#generateBtn, #newSessionBtn {
    padding: 12px;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

/* 生成按钮样式 */
#generateBtn {
    flex: 1;
    background-color: #2ecc71;
    display: block;
}

#generateBtn:hover {
    background-color: #27ae60;
}

#generateBtn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

/* 新会话按钮样式 */
#newSessionBtn {
    background-color: #f39c12;
    min-width: 100px;
}

#newSessionBtn:hover {
    background-color: #e67e22;
}

#newSessionBtn:active {
    background-color: #d35400;
}

/* 结果区域样式 */
.result-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
    min-height: 200px;
}

.result-content {
    margin-bottom: 20px;
}

.result-content img {
    max-width: 100%;
    border-radius: 5px;
    margin-top: 20px;
}

.result-actions {
    display: flex;
    gap: 10px;
}

#downloadBtn, #retryBtn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

#downloadBtn {
    background-color: #3498db;
    color: white;
}

#downloadBtn:hover {
    background-color: #2980b9;
}

#retryBtn {
    background-color: #e74c3c;
    color: white;
}

#retryBtn:hover {
    background-color: #c0392b;
}

/* 加载动画样式 */
.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    gap: 15px;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 1.2rem;
    color: #3498db;
    font-weight: bold;
    min-width: 100px;
    text-align: center;
}

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

/* 响应式设计 */
@media screen and (max-width: 768px) {
    /* 容器布局调整 */
    .container {
        flex-direction: column;
    }
    
    /* 隐藏侧边栏，改为底部弹出模式 */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70vh;
        z-index: 100;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.mobile-visible {
        transform: translateY(0);
    }
    
    /* 历史记录容器调整 */
    .history-container {
        max-height: calc(70vh - 60px);
    }
    
    /* 主内容区调整 */
    .main-content {
        padding: 15px;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* 右上角新会话按钮调整 */
    .header-actions {
        position: absolute;
        top: 15px;
        right: 15px;
        width: auto;
        text-align: right;
    }
    
    /* 提示词气泡调整为横向滚动 */
    .prompt-bubbles {
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .prompt-bubbles::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Edge */
    }
    
    .bubble {
        flex-shrink: 0;
        margin-right: 8px;
        white-space: nowrap;
    }
    
    /* 移动端底部导航栏 */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: white;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 99;
    }
    
    .mobile-nav button {
        flex: 1;
        padding: 12px;
        border: none;
        background: none;
        font-size: 0.9rem;
        color: #666;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
    }
    
    .mobile-nav button.active {
        color: #3498db;
    }
    
    .mobile-nav-icon {
        font-size: 1.3rem;
    }
    
    /* 页面内容底部添加空间，避免被导航栏遮挡 */
    body {
        padding-bottom: 60px;
    }
    
    /* 输入区域精简 */
    .input-section {
        padding: 15px;
    }
    
    #promptInput {
        min-height: 80px;
    }
    
    /* 移动端头部和输入区域优化 */
    h1 {
        font-size: 1.5rem;
        margin: 50px 0 15px 0; /* 增加顶部间距，为新会话按钮腾出空间 */
        text-align: center;
    }
    
    .input-section {
        margin-bottom: 15px;
    }
    
    .prompt-bubbles {
        margin-bottom: 12px;
    }
    
    .bubble {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .upload-container {
        margin-bottom: 12px;
    }
    
    .upload-label {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .image-preview {
        width: 80px;
        height: 80px;
    }
    
    #promptInput {
        padding: 10px;
        margin-bottom: 12px;
        font-size: 0.95rem;
    }
    
    .button-group {
        margin-top: 10px;
    }
    
    /* 结果区域优化 */
    .result-section {
        padding: 15px;
        margin-bottom: 15px;
        min-height: 150px;
    }
    
    /* 调整API配置提示的尺寸 */
    .api-config-notice {
        padding: 15px 10px;
    }
    
    .api-config-notice p {
        font-size: 0.9rem;
        margin: 5px 0;
    }
    
    /* 新会话按钮样式微调 */
    .header-actions #newSessionBtn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

/* 在正常大小屏幕下隐藏移动导航栏 */
.mobile-nav {
    display: none;
}

/* 拖拽样式 */
.drag-over {
    border: 2px dashed #4a6cf7 !important;
    background-color: rgba(74, 108, 247, 0.05) !important;
}

/* 提示样式 */
#promptInput::before {
    content: "可以将图片拖到这里或粘贴";
    position: absolute;
    top: 10px;
    left: 10px;
    color: #888;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

#promptInput:empty::before, 
#promptInput:focus:not(:has-text)::before {
    opacity: 1;
}

/* 动画 */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 108, 247, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(74, 108, 247, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 108, 247, 0); }
}

#promptInput.drag-over {
    animation: pulse 1.5s infinite;
}

/* 进度条样式 */
.progress-container {
    margin: 20px 0;
    width: 100%;
}

.progress-text {
    font-size: 1.1rem;
    color: #3498db;
    margin-bottom: 10px;
    text-align: center;
    font-weight: bold;
}

/* 生成提示文本 */
.progress-tip, .loading-tip {
    font-size: 0.85rem;
    color: #888;
    text-align: center;
    margin: 8px 0;
    font-style: italic;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #3498db;
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* 结果图片样式 */
.result-image-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.result-image {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 错误消息样式 */
.error-message {
    color: #e74c3c;
    font-size: 1.2rem;
    text-align: center;
    margin: 20px 0;
    font-weight: bold;
}

.ai-response {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    margin: 15px 0;
    white-space: pre-wrap;
    font-family: monospace;
    max-height: 300px;
    overflow-y: auto;
}

/* 新会话动画效果 */
@keyframes fadeIn {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

.new-session-fade {
    animation: fadeIn 0.5s ease;
}

/* 页面右上角新会话按钮 */
.header-actions {
    position: absolute;
    top: 20px;
    right: 30px;
    z-index: 10;
}

#newSessionBtn {
    background-color: #f39c12;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#newSessionBtn:hover {
    background-color: #e67e22;
}

#newSessionBtn:active {
    background-color: #d35400;
}

/* 历史记录删除按钮 */
.delete-history {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(231, 76, 60, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 12px;
}

.history-item:hover .delete-history {
    opacity: 1;
}

.delete-history:hover {
    background-color: rgba(192, 57, 43, 1);
}

/* API配置提示样式 */
.api-config-notice {
    padding: 20px;
    background-color: #fff3cd;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
    margin: 10px 0;
    text-align: center;
}

.api-config-notice p {
    margin: 8px 0;
    color: #856404;
    font-size: 1rem;
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 70px; /* 放在移动导航栏上方 */
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #3498db;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    z-index: 90;
    opacity: 0;
    visibility: hidden;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background-color: #2980b9;
    transform: translateY(-3px);
} 