/* ===== 全局变量 ===== */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #f472b6;
    --accent: #34d399;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --radius: 16px;
    --radius-sm: 8px;
    --warning: #f59e0b;
    --error: #ef4444;
}

/* ===== 基础样式 ===== */
* {
    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-dark) 0%, #1a1a2e 50%, #16213e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== 容器 ===== */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 头部 ===== */
.header {
    text-align: center;
    padding: 30px 20px;
    margin-bottom: 20px;
    position: relative;
}

/* API设置按钮 */
.api-settings-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    color: var(--primary-light);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.api-settings-btn:hover {
    background: var(--primary);
    color: white;
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 450px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--error);
}

.modal-body {
    padding: 20px;
}

.modal-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn.primary {
    background: var(--primary);
    color: white;
}

.modal-btn.primary:hover {
    background: var(--primary-dark);
}

.modal-btn.secondary {
    background: var(--bg-dark);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.modal-btn.secondary:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.api-status {
    margin-top: 15px;
    font-size: 0.85rem;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-icon {
    font-size: 48px;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.5));
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 8px;
}

/* ===== 主内容区 ===== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
    flex: 1;
}

/* ===== 面板通用样式 ===== */
.input-panel,
.preview-panel {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 10px;
}

.panel-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== 表单组件 ===== */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.label-icon {
    font-size: 1.2rem;
}

.required-hint {
    font-size: 0.8rem;
    color: var(--warning);
    font-weight: 400;
}

/* 保存风格按钮 */
.style-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.save-style-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.save-style-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(16, 185, 129, 0.4);
}

.saved-style-hint {
    color: var(--accent);
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 上传区域 */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(52, 211, 153, 0.1);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.upload-icon {
    font-size: 3rem;
    opacity: 0.7;
}

.upload-placeholder p {
    color: var(--text-secondary);
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.upload-preview {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.upload-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.remove-btn {
    position: absolute;
    top: -10px;
    right: calc(50% - 110px);
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.remove-btn:hover {
    transform: scale(1.1);
}

.remove-btn.small {
    width: 22px;
    height: 22px;
    font-size: 12px;
    top: -5px;
    right: -5px;
}

/* 选填提示 */
.optional-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 8px;
    font-weight: 400;
}

/* 内容库上传区域 */
.content-library-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(99, 102, 241, 0.02);
}

.content-library-upload:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.library-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.library-upload-placeholder p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.library-upload-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
}

.library-upload-preview .file-icon {
    font-size: 2rem;
}

.library-upload-preview .file-name {
    color: var(--text-primary);
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-upload-preview .file-status {
    font-size: 0.8rem;
    color: var(--accent);
    background: rgba(52, 211, 153, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
}

.library-upload-preview .remove-btn {
    position: relative;
    top: auto;
    right: auto;
}

/* 风格设置区域 */
.style-group {
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.style-input-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.style-input-row:last-of-type {
    margin-bottom: 0;
}

.sub-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 70px;
}

.style-input-row .form-input {
    flex: 1;
}

.style-upload-area {
    flex: 1;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.style-upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.style-upload-placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.style-upload-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.style-upload-preview img {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
}

.style-validation-msg {
    color: var(--warning);
    font-size: 0.85rem;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: var(--radius-sm);
}

/* 文本输入 */
.form-textarea,
.form-input {
    width: 100%;
    padding: 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    resize: vertical;
}

.form-textarea:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-textarea::placeholder,
.form-input::placeholder {
    color: var(--text-muted);
}

/* 页数选择器 */
.slide-count-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.count-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.count-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.count-input {
    width: 80px;
    height: 40px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
}

.count-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* 生成按钮 */
.generate-btn {
    width: 100%;
    padding: 18px 30px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 1.15rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px -10px rgba(99, 102, 241, 0.5);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px -10px rgba(99, 102, 241, 0.6);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 1.3rem;
}

/* 进度条 */
.progress-container {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.progress-bar {
    height: 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    background-size: 200% 100%;
    animation: progressGradient 2s ease infinite;
    transition: width 0.3s ease;
    border-radius: 4px;
}

@keyframes progressGradient {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.progress-text {
    text-align: center;
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== 预览面板 ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-muted);
    line-height: 1.8;
}

.slide-format-info {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    padding: 15px 25px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
}

.slide-format-info span {
    color: var(--primary-light);
    font-size: 0.9rem;
}

/* 下载按钮组 */
.download-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.download-btn {
    padding: 10px 18px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--bg-dark);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(52, 211, 153, 0.4);
}

.download-btn.secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.download-btn.secondary:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.4);
}

/* Slides画廊 - 3:4比例 */
.slides-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    padding-right: 10px;
}

.slides-gallery::-webkit-scrollbar {
    width: 6px;
}

.slides-gallery::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 3px;
}

.slides-gallery::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.slide-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.slide-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

/* 3:4 比例容器 */
.slide-image-container {
    aspect-ratio: 3 / 4;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.slide-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slide-placeholder {
    color: var(--text-muted);
    font-size: 2rem;
}

.slide-info {
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.slide-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.slide-number {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-dark);
    padding: 4px 10px;
    border-radius: 20px;
    margin-left: 10px;
}

.slide-download-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.2s;
}

.slide-download-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .slides-gallery {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .logo h1 {
        font-size: 1.8rem;
    }

    .input-panel,
    .preview-panel {
        padding: 20px;
    }

    .slides-gallery {
        grid-template-columns: 1fr;
    }

    .style-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .sub-label {
        margin-bottom: 5px;
    }

    .download-buttons {
        width: 100%;
        justify-content: center;
    }
}

/* ===== 加载动画 ===== */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-dark);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 生成中的Slide卡片 */
.slide-card.generating .slide-image-container {
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-card));
}

.slide-card.generating .slide-image-container::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.slide-card.error .slide-image-container {
    background: rgba(239, 68, 68, 0.1);
}

.slide-card.error .slide-placeholder {
    color: #ef4444;
}