/**
 * BookSynth样式文件
 * 书籍生成系统的专用样式
 */

/* ============================================
   容器布局
   ============================================ */

.booksynth-container {
    padding: 0;
    max-width: none;
}

.page-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    margin: 0;
    font-size: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-left .subtitle {
    margin: 0.5rem 0 0;
    opacity: 0.9;
    font-size: 1rem;
}

/* ============================================
   卡片样式
   ============================================ */

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    margin: 0;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============================================
   表单样式
   ============================================ */

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #333;
}

.form-control {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.current-project-info {
    color: #666;
    font-style: italic;
}

/* ============================================
   模板编辑区域
   ============================================ */

.template-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 500;
}

.template-contents {
    position: relative;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.template-editor {
    width: 100%;
    min-height: 400px;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}

.template-editor:focus {
    outline: none;
    border-color: #667eea;
}

.editor-info {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.char-count {
    color: #999;
    font-size: 0.875rem;
}

.generation-actions {
    margin-top: 2rem;
    text-align: center;
}

/* ============================================
   进度区域
   ============================================ */

.progress-bar-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 500;
    color: #333;
}

.progress-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.info-item .label {
    font-weight: 500;
    color: #666;
}

.info-item .value {
    color: #333;
}

.progress-log {
    max-height: 200px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 4px;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
}

.log-entry {
    padding: 0.25rem 0;
    color: #333;
}

.log-entry:last-child {
    color: #667eea;
    font-weight: 500;
}

/* ============================================
   项目列表
   ============================================ */

.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
}

.search-box i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.projects-table-container {
    overflow-x: auto;
}

.projects-table {
    width: 100%;
    border-collapse: collapse;
}

.projects-table th,
.projects-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.projects-table th {
    background: #f8f9fa;
    font-weight: 500;
    color: #666;
}

.projects-table tbody tr:hover {
    background: #f8f9fa;
}

.projects-table td {
    color: #333;
}

.text-center {
    text-align: center !important;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-draft {
    background: #e0e0e0;
    color: #666;
}

.status-generating_content,
.status-generating_chapters {
    background: #fff3cd;
    color: #856404;
}

.status-completed {
    background: #d4edda;
    color: #155724;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

.pagination {
    margin-top: 1rem;
}

.pagination-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.page-info {
    color: #666;
}

/* ============================================
   模态框
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content.modal-lg {
    max-width: 900px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.3s;
}

.modal-close:hover {
    background: #f0f0f0;
}

.modal-body {
    padding: 1.5rem;
}

.project-info {
    margin-bottom: 1.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.content-preview,
.chapters-list {
    margin-bottom: 1.5rem;
}

.content-preview h4,
.chapters-list h4 {
    margin: 0 0 1rem;
    font-size: 1.125rem;
    color: #333;
}

.preview-text {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    color: #333;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.chapter-item {
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    transition: all 0.3s;
}

.chapter-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.chapter-item.success {
    border-left: 3px solid #28a745;
}

.chapter-item.error {
    border-left: 3px solid #dc3545;
}

.chapter-number {
    font-size: 0.875rem;
    color: #999;
    margin-bottom: 0.25rem;
}

.chapter-title {
    font-weight: 500;
    color: #333;
    margin-bottom: 0.5rem;
}

.export-actions,
.chapter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.chapter-content {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 4px;
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 1rem;
    white-space: pre-wrap;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* ============================================
   响应式设计
   ============================================ */

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-right {
        width: 100%;
    }
    
    .template-tabs {
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .chapters-grid {
        grid-template-columns: 1fr;
    }
    
    .export-actions,
    .chapter-actions {
        flex-direction: column;
    }
}

/* ============================================
   上下文配置区域样式
   ============================================ */

.contextual-config {
    background: linear-gradient(135deg, #fff5e6 0%, #ffe6cc 100%);
    padding: 1.25rem;
    border-radius: 8px;
    border-left: 4px solid #ff9800;
    margin-top: 1rem;
    box-shadow: 0 2px 4px rgba(255, 152, 0, 0.1);
    transition: all 0.3s ease;
}

.contextual-config:hover {
    box-shadow: 0 4px 8px rgba(255, 152, 0, 0.15);
}

.contextual-config .form-group {
    margin-bottom: 0;
}

.contextual-config label {
    font-weight: 600;
    color: #e65100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.contextual-config label::before {
    content: "📖";
    font-size: 1.2rem;
}

.contextual-config input {
    border: 2px solid #ffb74d;
    background-color: white;
}

.contextual-config input:focus {
    border-color: #ff9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.1);
}

.contextual-config .form-text {
    color: #bf360c;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Generation Mode Select样式 */
#generation-mode {
    font-weight: 500;
    font-size: 1rem;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

#generation-mode:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#generation-mode option {
    padding: 0.75rem;
    font-weight: 500;
}

.form-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.5;
}

.form-text strong {
    color: #495057;
    font-weight: 600;
}

/* 动画效果 */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.contextual-config {
    animation: slideDown 0.3s ease;
}

