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

:root {
    /* 主题颜色 */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    
    /* 背景颜色 */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-dark: #1e293b;
    
    /* 文字颜色 */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    
    /* 边框颜色 */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* 尺寸 */
    --sidebar-width: 240px;
    --header-height: 64px;
    --border-radius: 8px;
    
    /* 动画 */
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

/* ==================== 顶部导航栏 ==================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 24px;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 24px;
}

.credits {
    color: var(--text-secondary);
}

.username {
    color: var(--text-secondary);
}

/* ==================== 主容器 ==================== */
.main-container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* ==================== 左侧导航菜单 ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.nav-menu {
    padding: 24px 0;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    padding: 0 24px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-list {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
}

.nav-item.active {
    background-color: var(--bg-tertiary);
    color: var(--primary-color);
    font-weight: 500;
    border-right: 3px solid var(--primary-color);
}

.nav-icon {
    margin-right: 12px;
    font-size: 18px;
}

.nav-text {
    font-size: 14px;
}

/* ==================== 右侧工作区 ==================== */
.workspace {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    min-height: calc(100vh - var(--header-height));
}

/* ==================== 页面通用样式 ==================== */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-description {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== 内容区块 ==================== */
.content-section {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* ==================== 表单元素 ==================== */
.article-input {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition);
}

.article-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.char-count strong {
    color: var(--primary-color);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
    font-size: 13px;
}

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

/* ==================== 设置组 ==================== */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.radio-label:hover {
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
}

.radio-label input[type="radio"] {
    margin-top: 4px;
    margin-right: 12px;
    cursor: pointer;
}

.radio-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.radio-text strong {
    display: block;
    color: var(--text-primary);
}

.radio-text small {
    color: var(--text-secondary);
    font-size: 12px;
}

.input-number {
    width: 80px;
    padding: 4px 8px;
    margin: 0 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
}

.input-number:disabled {
    background-color: var(--bg-tertiary);
    cursor: not-allowed;
}

/* ==================== 设置网格 ==================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.select-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    background-color: var(--bg-primary);
    cursor: pointer;
    transition: var(--transition);
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.setting-hint {
    color: var(--text-tertiary);
    font-size: 12px;
}

/* ==================== 按钮 ==================== */
.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: #475569;
    transform: translateY(-1px);
}

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

.btn-success:hover:not(:disabled) {
    background-color: #059669;
    transform: translateY(-1px);
}

.btn-icon {
    font-size: 16px;
}

.btn-icon-only {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    transition: var(--transition);
}

.btn-icon-only:hover {
    transform: scale(1.2);
}

/* ==================== 加载状态 ==================== */
.loading-container {
    text-align: center;
    padding: 48px 24px;
}

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

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

.loading-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.loading-subtext {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== 脚本列表 ==================== */
.script-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.script-card {
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.script-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.script-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.script-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.script-number {
    color: var(--primary-color);
    margin-right: 8px;
}

.script-actions {
    display: flex;
    gap: 8px;
}

.script-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.difficulty-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.difficulty-基础 {
    background-color: #dbeafe;
    color: #1e40af;
}

.difficulty-进阶 {
    background-color: #fef3c7;
    color: #92400e;
}

.difficulty-高级 {
    background-color: #fee2e2;
    color: #991b1b;
}

.script-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword-tag {
    padding: 4px 10px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.script-content {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

/* ==================== 结果统计 ==================== */
.result-stats {
    display: flex;
    gap: 24px;
    font-size: 13px;
}

.stat-item {
    color: var(--text-secondary);
}

.stat-item strong {
    color: var(--primary-color);
}

/* ==================== 脚本信息卡片 ==================== */
.script-info-card {
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 13px;
}

/* ==================== 进度条 ==================== */
.progress-bar {
    width: 100%;
    height: 24px;
    background-color: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 12px;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.generation-log {
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

.log-entry {
    padding: 4px 0;
    color: var(--text-secondary);
}

.log-entry.success {
    color: var(--success-color);
}

.log-entry.error {
    color: var(--danger-color);
}

/* ==================== 图片网格 ==================== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.image-item {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid var(--border-color);
}

.image-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

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

.image-status {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.9);
}

.status-completed {
    color: var(--success-color);
}

.status-processing {
    color: var(--warning-color);
}

.status-failed {
    color: var(--danger-color);
}

.image-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    font-size: 12px;
}

/* 重试按钮 */
.retry-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    z-index: 10;
}

.retry-btn:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.retry-btn:active {
    transform: translate(-50%, -50%) scale(0.98);
}

/* ==================== 结果摘要 ==================== */
.result-summary {
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.result-summary p {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.result-summary strong {
    color: var(--primary-color);
    font-size: 16px;
}

/* ==================== 历史记录 ==================== */
.history-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
}

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

.history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.history-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.history-info h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.history-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.success {
    background-color: #d1fae5;
    color: #065f46;
}

.history-actions {
    display: flex;
    gap: 8px;
}

/* ==================== 设置表单 ==================== */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
}

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

.form-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ==================== 模态框 ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background-color: var(--bg-tertiary);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: var(--danger-color);
    color: white;
}

#modalImage {
    max-width: 80vw;
    max-height: 60vh;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.modal-info {
    margin-bottom: 16px;
}

.modal-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-nav {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-nav {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-nav:hover {
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1024px) {
    .workspace {
        margin-left: 0;
        padding: 24px 16px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

