/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 页头样式 */
.header {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2.2em;
    margin-bottom: 10px;
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* 主要内容区域 - 左右布局 */
.main-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    padding: 0;
    overflow: hidden;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 600px;
}

/* 左侧面板 */
.left-panel {
    padding: 25px;
    border-right: 1px solid #e0e6ff;
    overflow-y: auto;
    max-height: 80vh;
}

/* 右侧面板 */
.right-panel {
    padding: 25px;
    background: #fafbff;
    display: flex;
    flex-direction: column;
    height: 80vh;
    overflow: hidden;
}

/* 各个区块的基础样式 */
section {
    margin-bottom: 25px;
}

section h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
}

/* API设置区域 */
.api-key-input {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.api-key-input input {
    flex: 1;
    min-width: 200px;
    padding: 10px;
    border: 2px solid #e0e6ff;
    border-radius: 8px;
    font-size: 1em;
}

.toggle-btn, .test-btn {
    padding: 0 15px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.test-btn {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.test-btn:hover {
    background: #218838;
    border-color: #218838;
}

.toggle-btn:hover {
    background: #f0f4ff;
}

.api-key-status {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
}

.api-status {
    font-size: 0.9em;
    font-weight: bold;
}

.api-status.success {
    color: #28a745;
}

.api-status.error {
    color: #dc3545;
}

/* 快捷选择区域 */
.category-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 8px 15px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: #f0f4ff;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

/* 主题卡片网格 */
.theme-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.theme-card {
    background: #f8f9ff;
    border: 2px solid #e0e6ff;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.theme-card.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.theme-card .icon {
    font-size: 1.8em;
    margin-bottom: 5px;
}

.theme-card .name {
    font-weight: bold;
    font-size: 0.95em;
}

/* 标题选择 */
.title-selection {
    margin-bottom: 15px;
}

.title-select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e6ff;
    border-radius: 8px;
    font-size: 1em;
    background: white;
}

/* 自定义输入区域 */
.custom-input {
    border-top: 2px solid #e0e6ff;
    padding-top: 15px;
}

.custom-input h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
    font-size: 0.95em;
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e6ff;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* 自定义词汇输入区域 */
.custom-words {
    border-top: 2px solid #e0e6ff;
    padding-top: 15px;
    margin-top: 15px;
}

.custom-words h4 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.input-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e6ff;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.3s ease;
}

.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.clear-words {
    margin-top: 15px;
    text-align: right;
}

.clear-btn {
    padding: 8px 20px;
    background: #f8f9ff;
    color: #667eea;
    border: 2px solid #e0e6ff;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: #e0e6ff;
    border-color: #667eea;
}

/* 生成控制区域 */
.generate-btn {
    width: 100%;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.generate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 进度条容器 */
.progress-container {
    margin-top: 15px;
}

.progress-bar {
    background: #f0f0f0;
    border-radius: 20px;
    overflow: hidden;
    height: 25px;
    position: relative;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 20px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 0.9em;
}

.progress-detail {
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

/* 状态消息 */
.status-message {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.95em;
    display: none;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.status-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

/* 预览区域 */
.preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #e0e6ff;
    border-radius: 10px;
    padding: 20px;
    min-height: 400px;
    position: relative;
    overflow-y: auto;
    min-height: 0;
}

.preview-placeholder {
    text-align: center;
    color: #999;
    font-size: 1.2em;
}

.image-container {
    text-align: center;
    max-width: 100%;
    max-height: 100%;
    overflow-y: auto;
}

#resultImage {
    max-width: 100%;
    max-height: 600px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
}

.image-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.download-btn, .new-tab-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 20px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn {
    background: #28a745;
    color: white;
}

.download-btn:hover {
    background: #218838;
    transform: translateY(-2px);
}

.new-tab-btn {
    background: #17a2b8;
    color: white;
}

.new-tab-btn:hover {
    background: #138496;
    transform: translateY(-2px);
}

/* 历史记录 */
.history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    border: 1px solid #e0e6ff;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.history-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.history-item img {
    width: 100%;
    border-radius: 5px;
    margin-bottom: 5px;
    aspect-ratio: 2/3;
    object-fit: cover;
}

.history-item .title {
    font-weight: bold;
    color: #667eea;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px;
    color: #666;
    margin-top: 30px;
    border-top: 1px solid #e0e6ff;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }

    .left-panel {
        border-right: none;
        border-bottom: 1px solid #e0e6ff;
        max-height: none;
    }

    .preview-container {
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .theme-cards {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .category-tabs {
        justify-content: center;
    }

    .tab-btn {
        flex: 1;
        min-width: 80px;
        font-size: 0.8em;
    }

    .history-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 480px) {
    .theme-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .history-list {
        grid-template-columns: 1fr;
    }

    .api-key-input {
        flex-direction: column;
    }

    .api-key-input input {
        min-width: auto;
    }

    .image-actions {
        flex-direction: column;
        align-items: center;
    }

    .download-btn, .new-tab-btn {
        width: 100%;
        max-width: 200px;
    }
}