/* ── 书香悦享 - 前台样式 ── */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --text: #1e293b;
    --text-sec: #64748b;
    --text-light: #94a3b8;
    --bg: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width:100%; display:block; }

.container { max-width:1200px; margin:0 auto; padding:0 16px; }

/* ── Header ── */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}
.logo:hover { color: var(--primary); }
.logo-icon { font-size: 28px; }

.search-form {
    display: flex;
    flex: 1;
    max-width: 480px;
}

.search-input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}
.search-input:focus { border-color: var(--primary); }

.search-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: var(--white);
    border: 1px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    font-size: 14px;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

/* ── 分类导航 ── */
.category-nav {
    display: flex;
    gap: 4px;
    padding: 8px 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display:none; }

.cat-link {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-sec);
    white-space: nowrap;
    transition: all .2s;
}
.cat-link:hover { background: var(--primary-light); color: var(--primary); }
.cat-link.active { background: var(--primary); color: var(--white); }

/* ── Main ── */
.main { padding: 24px 16px; min-height: 60vh; }

/* ── 面包屑 ── */
.breadcrumb {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-sec); }
.sep { margin: 0 6px; }

/* ── 区块标题 ── */
.section { margin-bottom: 32px; }
.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}
.section-title small { font-weight: 400; color: var(--text-sec); font-size: 14px; }

/* ── 书籍卡片网格 ── */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}
.featured-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.book-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    display: block;
    color: var(--text);
}
.book-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    color: var(--text);
}

.book-cover {
    position: relative;
    aspect-ratio: 5/7;
    background: #f1f5f9;
    overflow: hidden;
}
.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: linear-gradient(135deg, #e0e7ff, #dbeafe);
}
.cover-placeholder.large { font-size: 72px; }

.book-format {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

.badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.badge-featured { background: #fbbf24; color: #78350f; }

.book-info { padding: 12px; }
.book-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.book-author {
    font-size: 12px;
    color: var(--text-sec);
    margin-bottom: 6px;
}
.book-category { font-size: 12px; color: var(--text-light); }
.book-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text-light);
}

/* ── 书籍详情页 ── */
.book-detail {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}
.detail-top {
    display: flex;
    gap: 24px;
}
.detail-cover {
    flex-shrink: 0;
    width: 220px;
}
.detail-cover img {
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.detail-info { flex: 1; }
.detail-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.3;
}
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 14px;
    color: var(--text-sec);
    margin-bottom: 16px;
}
.detail-desc {
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius);
    margin-top: 12px;
}
.detail-desc h3 { font-size: 15px; margin-bottom: 8px; }
.detail-desc p { font-size: 14px; line-height: 1.8; color: var(--text-sec); }

/* ── 下载区域 ── */
.download-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.download-section h2 { font-size: 18px; margin-bottom: 16px; }

.download-list { display: flex; flex-direction: column; gap: 12px; }

.download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.dl-info { display: flex; align-items: center; gap: 12px; }
.dl-icon { font-size: 24px; }
.dl-pw {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
}
.dl-note { font-size: 12px; color: var(--text-light); margin-left: 8px; }

.download-tip {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-light);
}
.no-links { color: var(--text-light); text-align: center; padding: 24px; }

/* ── 按钮 ── */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .2s;
    text-align: center;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-download {
    background: var(--primary);
    color: var(--white);
    padding: 8px 24px;
    font-weight: 600;
}
.btn-download:hover { background: var(--primary-dark); color: var(--white); }

/* ── 分页 ── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 32px;
}
.page-link {
    display: inline-block;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-sec);
    background: var(--white);
    border: 1px solid var(--border);
}
.page-link.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}
.page-link:hover:not(.active) {
    background: var(--primary-light);
    color: var(--primary);
}

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

/* ── Flash消息 ── */
.flash-messages { margin-bottom: 16px; }
.flash {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 8px;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-light);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}
.footer a { color: var(--text-sec); }

/* ── 响应式 ── */
@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    .search-form { max-width: none; }
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
    .detail-top { flex-direction: column; }
    .detail-cover { width: 160px; }
    .download-item { flex-direction: column; gap: 12px; text-align: center; }
    .nav { flex-wrap: wrap; }
    .logo-text { font-size: 17px; }
}

@media (max-width: 480px) {
    .book-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .book-info { padding: 8px; }
    .book-title { font-size: 13px; }
}
