/* ==================== 全局变量 ==================== */
:root {
    --bg-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #eeeeee;
    --accent-color: #ff7d00;
    --accent-hover: #e56e00;
    --danger-color: #ff4d4f;
    --success-color: #00b42a;
    --header-bg: #ffffff;
    --header-text: #333333;
    --button-bg: #ff7d00;
    --button-hover: #e56e00;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --container-max-width: 1200px;
    --container-padding: 1rem;
}

body.dark {
    --bg-color: #1a1a1a;
    --surface-color: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border-color: #404040;
    --accent-color: #ff9d3e;
    --accent-hover: #ff8c1a;
    --header-bg: #2d2d2d;
    --header-text: #e0e0e0;
    --button-bg: #ff9d3e;
    --button-hover: #ff8c1a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==================== 全局重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 15px;
    padding-bottom: 70px;
}

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* ==================== 头部 ==================== */
header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 1px;
}

nav a, nav button {
    color: var(--header-text);
    text-decoration: none;
    margin-left: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    transition: background 0.2s;
    font-weight: 500;
}

nav a:hover, nav button:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark nav a:hover, body.dark nav button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    color: var(--header-text);
}

/* ==================== 搜索栏 ==================== */
.header {
    background-color: var(--surface-color);
    padding: 8px 16px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-color);
    border-radius: 30px;
    padding: 8px 16px;
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 400;
}

.search-input:focus {
    outline: none;
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

/* ==================== 用户信息卡片 ==================== */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background-color: var(--surface-color);
    margin: 16px 0;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.user-details {
    flex: 1;
}

.username {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.user-stats {
    font-size: 13px;
    color: var(--text-secondary);
}

.arrow {
    font-size: 20px;
    color: var(--text-tertiary);
    text-decoration: none;
}

/* ==================== 功能导航标签 ==================== */
.nav-tabs {
    display: flex;
    justify-content: space-around;
    background-color: var(--surface-color);
    padding: 12px 0;
    margin: 8px 0;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    position: relative;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.nav-item.active {
    color: var(--accent-color);
    font-weight: 600;
}

.nav-icon {
    font-size: 20px;
}

.badge {
    position: absolute;
    top: -4px;
    right: -8px;
    background-color: var(--danger-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

/* ==================== 热门推荐网格 ==================== */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.book-card {
    background-color: var(--surface-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.book-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
}

.book-cover {
    width: 100%;
    height: 240px;
    object-fit: cover;
    background-color: var(--bg-color);
}

.book-info {
    padding: 12px;
    position: relative;
}

.book-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.4;
}

.book-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.book-author {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.book-score {
    font-size: 12px;
    font-weight: 500;
    color: #f5a623;
}

.book-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 0 12px 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

/* ==================== 全部小说列表 ==================== */
.novel-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.novel-item {
    background-color: var(--surface-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.novel-item:hover {
    transform: translateX(6px);
    box-shadow: var(--shadow-md);
}

.novel-cover {
    width: 80px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background-color: var(--bg-color);
}

.novel-info {
    flex: 1;
}

.novel-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}

.novel-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.novel-author {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.novel-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 8px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==================== 章节列表 ==================== */
.chapter-list {
    list-style: none;
    margin: 16px 0;
    background-color: var(--surface-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.chapter-list li {
    border-bottom: 1px solid var(--border-color);
}

.chapter-list li a {
    display: block;
    padding: 14px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 15px;
    font-weight: 500;
}

.chapter-list li a:hover {
    background-color: var(--bg-color);
    padding-left: 28px;
    color: var(--accent-color);
}

/* ==================== 阅读页面 ==================== */
.chapter-content {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: var(--radius-sm);
    margin: 24px 0;
    line-height: 1.8;
    font-size: 16px;
    box-shadow: var(--shadow-sm);
}

.chapter-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
}

.chapter-nav a {
    display: inline-block;
    padding: 8px 20px;
    background-color: var(--surface-color);
    color: var(--accent-color);
    text-decoration: none;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    font-weight: 500;
}

.chapter-nav a:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* ==================== 评论区 ==================== */
.comments-section {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.comment {
    background-color: var(--surface-color);
    padding: 12px;
    margin: 12px 0;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border-left: 3px solid var(--accent-color);
    transition: all 0.2s;
}

.comment:hover {
    transform: translateX(4px);
    border-left-color: var(--accent-color);
}

.comment strong {
    font-weight: 600;
    font-size: 14px;
    color: var(--accent-color);
}

.comment .time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-left: 8px;
    opacity: 0.7;
}

.comment p {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.6;
}

/* 表情选择器 */
.emoji-picker {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.emoji {
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.1s;
}

.emoji:hover {
    transform: scale(1.2);
}

/* ==================== 表单 ==================== */
input, textarea, select {
    width: 100%;
    padding: 10px 12px;
    margin: 8px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--surface-color);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

button, input[type="submit"] {
    background-color: var(--button-bg);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: background 0.2s;
}

button:hover, input[type="submit"]:hover {
    background-color: var(--button-hover);
}

/* ==================== 表格 ==================== */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--surface-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 16px 0;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

th {
    background-color: var(--bg-color);
    font-weight: 600;
}

/* ==================== 底部导航（手机） ==================== */
.bottom-nav {
    display: none;
    justify-content: space-around;
    align-items: center;
    background-color: var(--surface-color);
    padding: 8px 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    position: relative;
    font-weight: 500;
}

.nav-tab.active {
    color: var(--accent-color);
    font-weight: 600;
}

/* ==================== 页脚 ==================== */
footer {
    margin-top: 40px;
    padding: 20px 0;
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border-color);
}

.footer-links a {
    margin: 0 8px;
    color: var(--text-tertiary);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--accent-color);
}

/* ==================== 错误/成功提示 ==================== */
.error {
    color: var(--danger-color);
    background: rgba(231, 76, 60, 0.1);
    padding: 10px;
    border-radius: var(--radius-sm);
    margin: 8px 0;
    border-left: 4px solid var(--danger-color);
}

.success {
    color: var(--success-color);
    background: rgba(39, 174, 96, 0.1);
    padding: 10px;
    border-radius: var(--radius-sm);
    margin: 8px 0;
    border-left: 4px solid var(--success-color);
}

/* ==================== 头衔徽章 ==================== */
.user-title {
    display: inline-flex;
    align-items: center;
    padding: 2px 12px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.3px;
    background: var(--bg-color);
    color: var(--text-secondary);
}

.user-title.admin {
    background: linear-gradient(135deg, #ff7d00, #ffaa3a);
    color: white;
}

.user-title.auditor {
    background: linear-gradient(135deg, #3498db, #5dade2);
    color: white;
}

.user-title.writer {
    background: linear-gradient(135deg, #2ecc71, #48c9b0);
    color: white;
}

.user-title.user {
    background: #95a5a6;
    color: white;
}

.user-title.custom {
    background: linear-gradient(135deg, #9b59b6, #be8ed2);
    color: white;
}

/* ==================== 番茄风格扩展样式 ==================== */
.section-title {
    font-size: 24px;
    font-weight: 600;
    margin: 30px 0 20px;
    padding-left: 12px;
    border-left: 4px solid var(--accent-color);
}

.gender-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

.gender-card {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.gender-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gender-title i {
    font-size: 24px;
}

.gender-book-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gender-book-item {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.gender-book-cover {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.gender-book-info {
    flex: 1;
}

.gender-book-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.gender-book-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.gender-book-author {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.update-table {
    width: 100%;
    border-collapse: collapse;
}

.update-table th, .update-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.update-table th {
    background: var(--bg-color);
    font-weight: 600;
}

.update-book-title a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
}

.update-chapter a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 400;
}

.update-chapter a:hover {
    color: var(--accent-color);
}

/* ==================== 后台管理辅助样式 ==================== */
.admin-nav {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.admin-nav a {
    padding: 8px 20px;
    background: var(--bg-color);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 24px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: var(--accent-color);
    color: white;
}

.action-buttons a,
.action-buttons button {
    display: inline-block;
    padding: 4px 12px;
    margin: 0 4px;
    background: var(--bg-color);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 16px;
    font-size: 12px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.action-buttons a:hover,
.action-buttons button:hover {
    background: var(--accent-color);
    color: white;
}

.table-actions {
    white-space: nowrap;
}

/* ==================== 消息中心样式（三栏布局） ==================== */
.message-container {
    display: flex;
    background: var(--surface-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin: 20px 0;
    height: calc(100vh - 180px);
    min-height: 500px;
}

.message-sidebar {
    width: 260px;
    background: var(--bg-color);
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item.active {
    background: var(--surface-color);
    border-left: 3px solid var(--accent-color);
    color: var(--accent-color);
}

.nav-item:hover:not(.active) {
    background: rgba(0,0,0,0.05);
}

.badge {
    margin-left: auto;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

.message-list {
    width: 320px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.list-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.conversation-item:hover,
.conversation-item.active {
    background: var(--bg-color);
}

.avatar {
    width: 48px;
    height: 48px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.conversation-info {
    flex: 1;
    overflow: hidden;
}

.conversation-name {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.conversation-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

.message-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
}

.detail-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    background: var(--surface-color);
}

.message-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-bubble {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
}

.message-bubble.sent {
    background: var(--accent-color);
    color: white;
    align-self: flex-end;
}

.message-bubble.received {
    background: var(--bg-color);
    align-self: flex-start;
}

.message-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.reply-area {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    background: var(--surface-color);
}

.reply-area input {
    flex: 1;
    padding: 10px;
    border-radius: 20px;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.new-message-btn {
    margin-top: 20px;
    padding: 10px 20px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.filter-select {
    padding: 4px 8px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    :root {
        --container-padding: 12px;
    }

    .book-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .book-cover {
        height: 200px;
    }

    .bottom-nav {
        display: flex;
    }

    body {
        padding-bottom: 70px;
    }

    .section-title {
        font-size: 20px;
    }

    .gender-section {
        grid-template-columns: 1fr;
    }

    .update-table th:nth-child(3),
    .update-table td:nth-child(3),
    .update-table th:nth-child(4),
    .update-table td:nth-child(4) {
        display: none;
    }

    header .container {
        flex-direction: column;
        gap: 0.5rem;
    }

    nav a, nav button {
        margin: 0 0.5rem;
    }

    .message-container {
        flex-direction: column;
        height: auto;
    }

    .message-sidebar,
    .message-list {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

@media (min-width: 769px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 24px;
    }

    .nav-tabs {
        max-width: 600px;
        margin: 0 auto 8px auto;
    }

    .search-bar {
        max-width: 600px;
    }

    .user-info {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .novel-list {
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }

    .gender-section {
        max-width: 1000px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ==================== 滚动条美化 ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}