/* ===== 云阅电子书 前台样式 - 全面优化版 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #4f6ef7;
    --primary-dark: #3b5de7;
    --primary-light: #eef2ff;
    --primary-gradient: linear-gradient(135deg, #4f6ef7 0%, #7c5cfc 50%, #a855f7 100%);
    --bg: #f0f2f8;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-light: #6b7294;
    --border: #e8eaf3;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 2px 12px rgba(79,110,247,0.06);
    --shadow-hover: 0 12px 32px rgba(79,110,247,0.12);
    --transition: all .3s cubic-bezier(.4,0,.2,1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
a { text-decoration: none; color: inherit; }

/* ---- 顶部导航 ---- */
.site-header {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
    width: 40px; height: 40px;
    background: var(--primary-gradient);
    color: #fff;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
    box-shadow: 0 4px 12px rgba(79,110,247,0.3);
}
.logo-text { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.main-nav { display: flex; gap: 8px; }
.main-nav a {
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: var(--transition);
}
.main-nav a:hover { background: var(--primary-light); color: var(--primary); }
.main-nav a.active { background: var(--primary); color: #fff; }

/* ---- 头部横幅 ---- */
.hero {
    background: var(--primary-gradient);
    color: #fff;
    padding: 64px 0 56px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(255,255,255,0.12) 0%, transparent 60%);
    animation: heroGlow 8s ease-in-out infinite alternate;
}
@keyframes heroGlow {
    0% { transform: translate(0,0); }
    100% { transform: translate(5%,5%); }
}
.hero .container { position: relative; z-index: 1; }
.hero h1 { font-size: 36px; margin-bottom: 10px; font-weight: 800; letter-spacing: -1px; text-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.hero p { opacity: .92; margin-bottom: 28px; font-size: 16px; }
.search-box {
    display: flex;
    max-width: 540px;
    margin: 0 auto;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 50px;
    overflow: hidden;
    backdrop-filter: blur(8px);
    transition: var(--transition);
}
.search-box:focus-within {
    background: rgba(255,255,255,0.28);
    border-color: rgba(255,255,255,0.5);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px 24px;
    font-size: 15px;
    background: transparent;
    color: #fff;
}
.search-box input::placeholder { color: rgba(255,255,255,0.7); }
.search-box button {
    border: none;
    background: #fff;
    color: var(--primary);
    padding: 0 32px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.search-box button:hover { background: rgba(255,255,255,0.9); }

/* ---- 分类栏 ---- */
.cat-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 28px 0 16px;
}
.cat-bar a {
    padding: 7px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    transition: var(--transition);
}
.cat-bar a:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.cat-bar a.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(79,110,247,0.25); }

.book-count { color: var(--text-light); font-size: 13px; margin: 16px 0 8px; }

/* ---- 书籍网格 ---- */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding-bottom: 48px;
}
.book-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.03);
}
.book-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); }
.book-cover { position: relative; aspect-ratio: 3/4; background: var(--primary-light); overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.book-card:hover .book-cover img { transform: scale(1.05); }
.cover-placeholder {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 50%, #ede9fe 100%);
    padding: 20px;
    text-align: center;
}
.cover-type {
    background: var(--primary-gradient);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 6px;
    letter-spacing: 2px;
    box-shadow: 0 2px 8px rgba(79,110,247,0.3);
}
.cover-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}
.book-type-badge {
    position: absolute;
    top: 12px; right: 12px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
}
.book-info { padding: 14px 16px 16px; }
.book-title {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    color: var(--text);
}
.book-author { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.book-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 12px;
}
.read-btn {
    display: block;
    text-align: center;
    background: var(--primary-gradient);
    color: #fff;
    padding: 10px 0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(79,110,247,0.2);
}
.read-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79,110,247,0.35); }

/* ---- 空状态 ---- */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-light);
    font-size: 16px;
}
.empty-state::before {
    content: '📖';
    display: block;
    font-size: 48px;
    margin-bottom: 16px;
    filter: grayscale(0.3);
}

/* ---- 页脚 ---- */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    padding: 28px 0;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

/* ==================== 阅读页 ==================== */
.reader-body { background: #fff; display: flex; flex-direction: column; min-height: 100vh; }

.reader-header {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}
.reader-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.back-link {
    color: var(--primary);
    font-size: 14px;
    white-space: nowrap;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    transition: var(--transition);
}
.back-link:hover { background: var(--primary-light); }
.reader-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
    justify-content: center;
}
.reader-title h1 {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.reader-author { color: var(--text-light); font-size: 13px; white-space: nowrap; }
.admin-link { color: var(--text-light); font-size: 13px; white-space: nowrap; padding: 6px 12px; border-radius: 8px; transition: var(--transition); }
.admin-link:hover { color: var(--primary); background: var(--primary-light); }

.reader-main { flex: 1; }

/* PDF 阅读 */
.pdf-container {
    height: calc(100vh - 60px - 48px);
    background: #525659;
}
.pdf-frame { width: 100%; height: 100%; border: none; }
.pdf-toolbar {
    height: 48px;
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    font-size: 13px;
}
.download-link {
    color: #93c5fd;
    padding: 6px 14px;
    border-radius: 6px;
    transition: var(--transition);
}
.download-link:hover { background: rgba(147,197,253,0.15); text-decoration: none; }

/* 文字阅读器 */
.text-reader {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px 80px;
}
.text-reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.font-controls, .theme-controls { display: flex; gap: 4px; }
.fc-btn, .theme-btn {
    border: 1px solid var(--border);
    background: var(--bg-card);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}
.fc-btn:hover { border-color: var(--primary); color: var(--primary); }
.theme-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(79,110,247,0.3); }
.word-count { font-size: 12px; color: var(--text-light); }

.text-content {
    font-size: 18px;
    line-height: 2;
    color: #2d2d3a;
    text-align: justify;
    word-break: break-word;
    transition: color .3s;
}
.text-content p { margin-bottom: 1em; }
.text-h2 {
    font-size: 24px;
    margin: 36px 0 18px;
    color: var(--text);
    font-weight: 700;
    text-align: center;
}
.text-hr { border: none; border-top: 1px dashed var(--border); margin: 36px 0; }

/* 阅读器主题 */
.text-reader.theme-sepia { background: #faf4e6; }
.text-reader.theme-sepia .text-content { color: #5b4636; }
.text-reader.theme-sepia .text-content .text-h2 { color: #4a3520; }
.text-reader.theme-sepia .text-reader-toolbar { border-bottom-color: #e8d9bf; }

.text-reader.theme-dark { background: #1a1a2e; color: #e0e0e0; }
.text-reader.theme-dark .text-content { color: #c8c8d8; }
.text-reader.theme-dark .text-content .text-h2 { color: #f0f0ff; }
.text-reader.theme-dark .text-reader-toolbar { border-bottom-color: #2a2a4a; }
.text-reader.theme-dark .fc-btn, .text-reader.theme-dark .theme-btn {
    background: #2a2a4a; border-color: #3a3a5a; color: #c8c8d8;
}
.text-reader.theme-dark .word-count { color: #8888aa; }

/* 手机端底部浮动工具栏 */
.mobile-toolbar {
    display: none; /* 默认隐藏，手机端显示 */
}

.reader-footer {
    text-align: center;
    color: var(--text-light);
    font-size: 12px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

/* ================ 手机端响应式 ================ */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .header-inner { height: 56px; }
    .logo-icon { width: 36px; height: 36px; font-size: 17px; border-radius: 10px; }
    .logo-text { font-size: 17px; }
    .main-nav a { padding: 6px 12px; font-size: 13px; }

    .hero { padding: 40px 0 36px; }
    .hero h1 { font-size: 24px; }
    .hero p { font-size: 14px; margin-bottom: 20px; }
    .search-box { border-radius: 40px; }
    .search-box input { padding: 14px 18px; font-size: 14px; }
    .search-box button { padding: 0 20px; }

    .cat-bar { gap: 6px; margin: 20px 0 12px; }
    .cat-bar a { padding: 6px 14px; font-size: 12px; }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .book-info { padding: 10px 12px 14px; }
    .book-title { font-size: 14px; }
    .book-author { font-size: 12px; }
    .book-meta { font-size: 11px; margin-bottom: 10px; }
    .read-btn { padding: 8px 0; font-size: 13px; }

    /* 阅读页手机端 */
    .reader-header-inner { height: 52px; padding: 0 12px; }
    .back-link { font-size: 13px; padding: 4px 8px; }
    .reader-title h1 { font-size: 14px; }
    .reader-author { display: none; }
    .admin-link { display: none; }

    .pdf-container { height: calc(100vh - 52px - 40px); }
    .pdf-toolbar { height: 40px; padding: 0 12px; font-size: 12px; }
    .pdf-toolbar span { display: none; }

    .text-reader { padding: 0 16px 80px; }
    .text-reader-toolbar { gap: 8px; padding: 14px 0; }
    .fc-btn, .theme-btn { padding: 7px 12px; font-size: 12px; }
    .text-content { font-size: 17px; line-height: 1.9; }
    .text-h2 { font-size: 20px; margin: 28px 0 14px; }
    .word-count { font-size: 11px; }

    /* 手机端浮动工具栏 */
    .mobile-toolbar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0; right: 0;
        background: rgba(255,255,255,0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid rgba(0,0,0,0.06);
        padding: 8px 12px;
        gap: 6px;
        justify-content: center;
        z-index: 200;
        transition: transform .3s ease, opacity .3s ease;
    }
    .mobile-toolbar.hidden { transform: translateY(100%); opacity: 0; pointer-events: none; }
    .mt-btn {
        border: 1px solid var(--border);
        background: var(--bg-card);
        padding: 8px 14px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        transition: var(--transition);
        color: var(--text);
    }
    .mt-btn:active { transform: scale(0.95); }
    .mt-btn.active, .mt-theme.active {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
    }
    /* 暗色模式下浮动工具栏 */
    .theme-dark + .mobile-toolbar,
    .text-reader.theme-dark ~ .mobile-toolbar {
        background: rgba(26,26,46,0.95);
        border-top-color: #2a2a4a;
    }

    .reader-footer { padding-bottom: 60px; }
}

@media (max-width: 400px) {
    .book-grid { gap: 10px; }
    .hero h1 { font-size: 22px; }
    .search-box input { padding: 12px 14px; }
    .text-content { font-size: 16px; }
}

/* 桌面端大屏 */
@media (min-width: 1400px) {
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
}
