/* ===== 基础样式 ===== */
:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #6B7280;
    --success: #10B981;
    --danger: #EF4444;
    --bg: #F9FAFB;
    --card-bg: #FFFFFF;
    --text: #1F2937;
    --text-light: #6B7280;
    --border: #E5E7EB;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ===== 头部 ===== */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-light);
}

/* ===== 步骤指示器 ===== */
.steps {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-radius: 999px;
    border: 2px solid var(--border);
    opacity: 0.5;
    transition: all 0.3s;
}

.step.active {
    opacity: 1;
    border-color: var(--primary);
}

.step.done {
    opacity: 1;
    border-color: var(--success);
    background: #ECFDF5;
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.step.active .step-number {
    background: var(--primary);
    color: white;
}

.step.done .step-number {
    background: var(--success);
    color: white;
}

.step-label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ===== 卡片 ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.card-error {
    border: 2px solid var(--danger);
    background: #FEF2F2;
}

.hidden {
    display: none !important;
}

/* ===== 上传区域 ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: #F5F3FF;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-hint {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: #F3F4F6;
    border-radius: 8px;
    margin: 1rem 0;
}

.file-name {
    font-weight: 500;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4B5563;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea[readonly] {
    background: #F9FAFB;
    color: var(--text-light);
}

/* ===== 加载动画 ===== */
.loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* ===== 结果预览 ===== */
.result-preview {
    text-align: center;
    margin-bottom: 1.5rem;
}

.result-preview img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== 主题选择卡片 ===== */
.topics-section {
    margin-bottom: 1.5rem;
}

.topics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.topics-header label {
    font-weight: 500;
}

#selected-count {
    color: var(--primary);
    font-weight: 600;
}

.topic-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.topic-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.topic-card:hover {
    border-color: var(--primary);
    background: #F5F3FF;
}

.topic-card.selected {
    border-color: var(--primary);
    background: #EEF2FF;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.topic-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.topic-content {
    flex: 1;
}

.topic-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.topic-description {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.topic-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.keyword-tag {
    background: var(--bg);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    color: var(--primary);
    border: 1px solid var(--primary);
}

/* ===== 多图片展示网格 ===== */
.result-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.result-item {
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.result-item img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}

.result-item img:hover {
    transform: scale(1.02);
}

.result-item-info {
    padding: 0.75rem 1rem;
}

.result-item-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-item-actions {
    display: flex;
    gap: 0.5rem;
}

.result-item-actions .btn {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.75rem;
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.5rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .steps {
        gap: 0.5rem;
    }

    .step-label {
        display: none;
    }
}
/* ===== 上传标签页 ===== */
.upload-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== 文本输入区域 ===== */
.text-input-area {
    margin-bottom: 1.5rem;
}

.text-input-area textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
    min-height: 200px;
}

.text-input-area textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.text-input-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

/* ===== 增强版生成等待页面 ===== */
.generate-container {
    padding: 1rem 0;
}

/* 进度条区域 */
.progress-section {
    margin-bottom: 2rem;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4F46E5, #7C3AED, #EC4899);
    background-size: 200% 100%;
    border-radius: 999px;
    transition: width 0.5s ease-out;
    animation: gradient-shift 2s ease infinite;
}

.progress-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

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

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

#generate-status {
    color: var(--text);
    font-weight: 500;
}

.time-remaining {
    color: var(--primary);
    font-weight: 600;
}

/* 当前任务卡片 */
.current-task-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #EEF2FF 0%, #FDF4FF 100%);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(79, 70, 229, 0.1);
}

.task-icon {
    font-size: 2rem;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.task-info {
    flex: 1;
}

.task-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.task-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.task-pulse {
    position: absolute;
    right: -50px;
    top: -50px;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* 趣味提示轮播 */
.tips-carousel {
    margin-bottom: 1.5rem;
}

.tip-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    animation: fade-in 0.5s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tip-icon {
    font-size: 1.25rem;
}

.tip-text {
    color: var(--text-light);
    font-size: 0.9375rem;
}

/* 友好提醒 */
.wait-reminder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #FFFBEB;
    border: 1px solid #FCD34D;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #92400E;
}

.reminder-icon {
    animation: spin-slow 3s linear infinite;
}

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