:root {
    --primary: #4A90D9;
    --primary-dark: #3A7BC8;
    --secondary: #2C3E50;
    --accent: #27AE60;
    --accent-dark: #219A52;
    --danger: #E74C3C;
    --bg: #F5F7FA;
    --card-bg: #FFFFFF;
    --text: #333333;
    --text-light: #666666;
    --border: #E1E8ED;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

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

body {
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    padding: 40px 20px;
}

.header h1 {
    font-size: 2.2rem;
    color: var(--secondary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

.main {
    padding: 20px 0;
}

/* 上传区域 */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--card-bg);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(74, 144, 217, 0.05);
}

.upload-area.dragover {
    transform: scale(1.02);
}

.upload-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.upload-area h2 {
    font-size: 1.3rem;
    color: var(--secondary);
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--text-light);
}

.upload-progress {
    display: none;
    margin-top: 20px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.upload-progress.show {
    display: block;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* 书籍信息 */
.book-info {
    margin-bottom: 30px;
}

.book-info.hidden {
    display: none;
}

.book-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.book-cover {
    font-size: 60px;
    width: 80px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 8px;
    flex-shrink: 0;
}

.book-details {
    flex: 1;
}

.book-details h2 {
    font-size: 1.4rem;
    color: var(--secondary);
    margin-bottom: 4px;
}

.book-author {
    color: var(--text-light);
    margin-bottom: 4px;
}

.book-chapters {
    color: var(--primary);
    font-weight: 500;
}

/* 目录区域 */
.toc-section {
    margin-bottom: 30px;
}

.toc-section.hidden {
    display: none;
}

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

.toc-header h3 {
    font-size: 1.1rem;
    color: var(--secondary);
}

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

.toc-list {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 450px;
    overflow-y: auto;
}

.toc-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.toc-item:last-child {
    border-bottom: none;
}

.toc-item:hover {
    background: rgba(74, 144, 217, 0.05);
}

.toc-item.selected {
    background: rgba(74, 144, 217, 0.1);
}

.toc-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 14px;
    cursor: pointer;
    accent-color: var(--primary);
}

.toc-item-content {
    flex: 1;
}

.toc-item-title {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 2px;
}

.toc-item-src {
    font-size: 0.85rem;
    color: var(--text-light);
}

.toc-item-depth-1 {
    padding-left: 40px;
}

.toc-item-depth-2 {
    padding-left: 60px;
}

/* 操作区域 */
.action-section {
    position: sticky;
    bottom: 20px;
}

.action-section.hidden {
    display: none;
}

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.selected-info {
    font-size: 1rem;
    color: var(--text);
}

.selected-info span {
    color: var(--primary);
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: 12px;
}

/* 按钮 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
}

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

.btn-secondary:hover {
    background: #1a252f;
}

.btn-text {
    background: transparent;
    color: var(--primary);
    padding: 8px 12px;
}

.btn-text:hover {
    background: rgba(74, 144, 217, 0.1);
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 28px;
    background: var(--secondary);
    color: white;
    border-radius: 8px;
    font-size: 1rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--accent);
}

.toast.error {
    background: var(--danger);
}

/* 响应式 */
@media (max-width: 600px) {
    .header {
        padding: 30px 16px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .book-card {
        flex-direction: column;
        text-align: center;
    }

    .toc-item-depth-1,
    .toc-item-depth-2 {
        padding-left: 20px;
    }

    .action-bar {
        flex-direction: column;
        gap: 12px;
    }
}
