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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --danger: #ef4444;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 12px;
}

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

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }

/* ===== 按钮 ===== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { display: block; width: 100%; }
.btn-disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }

/* ===== 头部导航 ===== */
.site-header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.logo { font-size: 20px; font-weight: 700; color: var(--text); white-space: nowrap; }
.main-nav { display: flex; gap: 8px; }
.main-nav a {
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
}
.main-nav a:hover, .main-nav a.active { background: var(--primary); color: #fff; }
.user-area { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 14px; color: var(--text-light); white-space: nowrap; }

/* ===== 容器 ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ===== 认证页面 ===== */
.auth-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.auth-container { width: 100%; max-width: 420px; padding: 20px; }
.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.auth-header { text-align: center; margin-bottom: 30px; }
.auth-header h1 { font-size: 26px; margin-bottom: 8px; }
.auth-header p { color: var(--text-light); font-size: 14px; }
.auth-form .form-group { margin-bottom: 20px; }
.auth-form label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.auth-form input, .auth-form select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.auth-form input:focus, .auth-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-light); }
.form-message { min-height: 20px; font-size: 13px; margin-bottom: 10px; }
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--success); }

/* ===== 表单通用 ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.form-group label small { color: var(--text-light); font-weight: normal; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-group textarea { resize: vertical; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-label input { width: auto; }
.file-info { margin-top: 6px; font-size: 13px; }
.file-name { color: var(--primary); }

/* ===== 工具栏 ===== */
.page-toolbar { margin-bottom: 24px; }
.search-bar { margin-bottom: 16px; }
.search-form { display: flex; gap: 8px; }
.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}
.search-input:focus { outline: none; border-color: var(--primary); }
.category-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.category-bar a {
    padding: 6px 16px;
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--text-light);
    font-size: 13px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.category-bar a:hover, .category-bar a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 小说网格 ===== */
.novel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}
.novel-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.novel-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.novel-cover { display: block; position: relative; }
.cover-placeholder {
    height: 160px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 36px;
    font-weight: 700;
}
.cover-placeholder.sm { height: 60px; width: 60px; border-radius: 8px; font-size: 20px; }
.cover-placeholder.lg { height: 200px; width: 140px; border-radius: 8px; font-size: 40px; }
.novel-category {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.novel-info { padding: 12px; }
.novel-title { font-size: 15px; margin-bottom: 4px; line-height: 1.4; }
.novel-title a { color: var(--text); }
.novel-title a:hover { color: var(--primary); }
.novel-author { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.novel-meta { display: flex; gap: 10px; font-size: 12px; color: var(--text-light); }
.novel-desc { font-size: 12px; color: var(--text-light); margin-top: 6px; line-height: 1.5; }

/* ===== 标签 ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}
.badge-category { background: #eef2ff; color: var(--primary); }
.badge-fav { background: #fef3c7; color: #d97706; }

/* ===== 分页 ===== */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 30px; }
.page-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state p { color: var(--text-light); margin-bottom: 20px; font-size: 16px; }

/* ===== 上传页面 ===== */
.upload-page { max-width: 600px; margin: 0 auto; }
.upload-page h2 { margin-bottom: 24px; }
.upload-form {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ===== 页面头部 ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; }
.page-subtitle { color: var(--text-light); font-size: 14px; margin-top: 4px; }

/* ===== 小说详情 ===== */
.novel-detail { background: var(--card-bg); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); }
.novel-detail-header { display: flex; gap: 30px; margin-bottom: 30px; }
.novel-detail-info { flex: 1; }
.novel-detail-info h1 { font-size: 28px; margin-bottom: 12px; }
.novel-detail-meta { display: flex; gap: 16px; margin-bottom: 16px; font-size: 14px; color: var(--text-light); flex-wrap: wrap; align-items: center; }
.novel-stats { display: flex; gap: 30px; margin-bottom: 20px; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.stat-item { text-align: center; }
.stat-item strong { display: block; font-size: 20px; color: var(--primary); }
.stat-item span { font-size: 12px; color: var(--text-light); }
.novel-description { margin-bottom: 20px; }
.novel-description h4 { margin-bottom: 8px; }
.novel-description p { color: var(--text-light); line-height: 1.8; }
.novel-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.fav-btn.faved { color: var(--danger); border-color: var(--danger); }

/* ===== 章节列表 ===== */
.chapter-list-section { margin-top: 30px; }
.chapter-list-section h3 { margin-bottom: 16px; }
.chapter-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.chapter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s;
}
.chapter-item:hover { border-color: var(--primary); background: #f5f3ff; }
.chapter-item.reading { border-color: var(--success); background: #ecfdf5; }
.chapter-num { color: var(--primary); font-weight: 500; white-space: nowrap; }
.chapter-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-words { font-size: 12px; color: var(--text-light); white-space: nowrap; }

/* ===== 阅读页面 ===== */
.read-page { background: #f8f6f3; }
.read-container { max-width: 800px; margin: 0 auto; padding: 30px 20px; }
.read-header { text-align: center; margin-bottom: 30px; }
.back-link { display: inline-block; margin-bottom: 16px; font-size: 14px; }
.read-title { font-size: 22px; margin-bottom: 8px; }
.chapter-title-lg { font-size: 18px; color: var(--text-light); font-weight: normal; }
.read-content {
    background: #fff;
    padding: 40px 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 17px;
    line-height: 2;
    color: #2d2d2d;
    margin-bottom: 30px;
    min-height: 300px;
}
.read-content h1, .read-content h2, .read-content h3 { margin: 20px 0 12px; }
.read-content p { margin-bottom: 16px; text-indent: 2em; }
.read-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 10px 20px;
    margin: 16px 0;
    background: #f5f3ff;
    color: var(--text-light);
}
.read-content code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.read-content pre { background: #1e293b; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; margin: 16px 0; }
.read-content pre code { background: none; padding: 0; }
.read-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.read-progress { color: var(--text-light); font-size: 14px; }
.read-end { color: var(--success); font-size: 14px; }

/* ===== 小说列表 (书架/历史) ===== */
.novel-list, .history-list { display: flex; flex-direction: column; gap: 12px; }
.novel-list-item, .history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: opacity 0.3s;
}
.novel-list-info, .history-info { flex: 1; min-width: 0; }
.novel-list-info h3, .history-info h3 { font-size: 16px; margin-bottom: 4px; }
.novel-list-meta, .history-meta { display: flex; gap: 12px; font-size: 13px; color: var(--text-light); flex-wrap: wrap; align-items: center; }
.novel-list-progress { font-size: 13px; color: var(--primary); margin-top: 4px; }
.novel-list-actions, .history-actions { display: flex; gap: 8px; flex-shrink: 0; }
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }
.history-time { font-size: 12px; color: var(--text-light); }
.empty-text { color: var(--text-light); padding: 20px; text-align: center; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
    .main-nav { order: 3; width: 100%; overflow-x: auto; }
    .main-nav a { white-space: nowrap; padding: 6px 12px; font-size: 13px; }
    .novel-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
    .cover-placeholder { height: 120px; font-size: 24px; }
    .novel-detail-header { flex-direction: column; align-items: center; text-align: center; }
    .novel-detail-meta { justify-content: center; }
    .novel-stats { justify-content: center; gap: 20px; }
    .novel-actions { justify-content: center; }
    .read-content { padding: 20px 16px; font-size: 16px; }
    .novel-list-item, .history-item { flex-wrap: wrap; }
    .novel-list-actions, .history-actions { width: 100%; justify-content: flex-end; }
    .form-row { flex-direction: column; }
    .search-form { flex-direction: column; }
}
