/* ===== 全局变量 ===== */
:root {
    --primary-color: #ff2442;
    --primary-hover: #e61e3c;
    --secondary-color: #ff6b81;
    --accent-color: #ffeaa7;
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --card-bg: #ffffff;
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --text-muted: #b2bec3;
    --border-color: #dfe6e9;
    --success-color: #00b894;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s ease;
}

/* ===== 重置样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ===== 应用容器 ===== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* ===== 头部 ===== */
.app-header {
    text-align: center;
    padding: 40px 20px;
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 48px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.logo h1 {
    font-size: 36px;
    font-weight: 900;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.tagline {
    font-size: 18px;
    opacity: 0.9;
    font-weight: 300;
}

/* ===== 主内容区 ===== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* ===== 输入面板 ===== */
.input-panel {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.input-section {
    margin-bottom: 24px;
}

.input-section:last-child {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.section-icon {
    font-size: 24px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
}

.saved-badge {
    background: var(--success-color);
    color: white;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

/* ===== 输入组件 ===== */
.input-group {
    display: flex;
    gap: 12px;
}

input[type="text"] {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(255, 36, 66, 0.1);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* ===== 按钮样式 ===== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(255, 36, 66, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 36, 66, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.btn-icon:hover {
    transform: rotate(180deg);
}

/* ===== 选题标签 ===== */
.topics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.topic-tag {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.topic-tag:hover {
    background: linear-gradient(135deg, var(--accent-color) 0%, #fdcb6e 100%);
    border-color: #fdcb6e;
    transform: translateY(-2px);
}

.topic-tag.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-color: transparent;
}

/* ===== 模板选择器 ===== */
.template-selector {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.template-option {
    cursor: pointer;
}

.template-option input {
    display: none;
}

.template-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.template-option:hover .template-preview {
    border-color: var(--primary-color);
}

.template-option.active .template-preview {
    border-color: var(--primary-color);
    background: rgba(255, 36, 66, 0.05);
}

.template-icon {
    font-size: 32px;
}

.template-name {
    font-size: 14px;
    font-weight: 600;
}

/* ===== 生成按钮 ===== */
.action-section {
    margin-top: 24px;
}

.action-section .btn-primary {
    width: 100%;
    padding: 18px;
    font-size: 18px;
}

/* ===== 状态显示 ===== */
.status-section {
    margin-top: 24px;
}

.status-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--radius-md);
}

.status-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.status-text {
    font-size: 15px;
    color: var(--text-secondary);
}

/* ===== 预览面板 ===== */
.preview-panel {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.preview-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.preview-actions {
    display: flex;
    gap: 12px;
}

/* ===== 文本预览 ===== */
.text-preview {
    margin-bottom: 24px;
}

.preview-block {
    margin-bottom: 20px;
}

.preview-block h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.title-preview {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 16px;
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
    border-radius: var(--radius-md);
    border-left: 4px solid #ffc107;
}

.content-preview {
    font-size: 15px;
    line-height: 1.8;
    padding: 16px;
    background: #f8f9fa;
    border-radius: var(--radius-md);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* ===== 图片预览 ===== */
.images-preview h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.image-thumb {
    aspect-ratio: 3/4;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.image-thumb:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== 渲染容器（隐藏） ===== */
.render-container {
    position: absolute;
    left: -9999px;
    top: 0;
}

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 32px;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--primary-color);
}

#modalImage {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* ===== 渲染卡片样式（用于生成图片） ===== */
.card {
    width: 750px;
    height: 1000px;
    background-color: #ffffff;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 50px 45px;
    font-family: 'Noto Sans SC', sans-serif;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .app-header {
        padding: 20px;
    }
    
    .logo h1 {
        font-size: 24px;
    }
    
    .tagline {
        font-size: 14px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .preview-actions {
        width: 100%;
    }
    
    .preview-actions button {
        flex: 1;
    }
}
