/* =============================================
   基础样式与布局 - style.css
   ============================================= */

/* 全局重置与基础变量 */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; -webkit-tap-highlight-color: transparent; }

:root {
    --primary: #4a6fa5; --secondary: #166088; --accent: #ff7e5f;
    --light: #f8f9fa; --dark: #343a40; --gray: #6c757d; --light-gray: #e9ecef;
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --bg-section: #ffffff;
    --text-main: #333333;
    --text-secondary: #444444;
    --border-light: #e9ecef;
    --shadow-soft: rgba(0, 0, 0, 0.05);
}

/* 背景与滚动条 */
body { background-color: var(--bg-body); color: var(--text-main); line-height: 1.6; }
::-webkit-scrollbar { width: 8px; } 
::-webkit-scrollbar-track { background: var(--light); } 
::-webkit-scrollbar-thumb { background: var(--gray); border-radius: 4px; } 
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

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

/* 回到顶部按钮 */
#back-to-top { 
    position: fixed; bottom: 30px; right: 25px; z-index: 100; 
    width: 45px; height: 45px; background: var(--primary); color: white; 
    border-radius: 50%; border: none; cursor: pointer; 
    display: none; align-items: center; justify-content: center; 
    box-shadow: 0 4px 10px rgba(74, 111, 165, 0.3); font-size: 20px; transition: all 0.3s; 
}
#back-to-top:hover { background: var(--secondary); transform: translateY(-3px); }

/* =============================================
   Header 头部导航
   ============================================= */
header { background-color: var(--bg-card); box-shadow: 0 2px 10px var(--shadow-soft); position: sticky; top: 0; z-index: 100; }
.header-content { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo i { font-size: 28px; color: var(--primary); }
.logo h1 { font-size: 22px; color: var(--dark); }
.logo span { color: var(--accent); }
nav ul { display: flex; list-style: none; gap: 20px; }
nav button { background: none; border: 0; cursor: pointer; color: var(--dark); font-weight: 500; padding: 5px 0; font-size: inherit; font-family: inherit; position: relative; transition: color 0.3s; display: flex; align-items: center; gap: 5px; appearance: none; -webkit-appearance: none; }
nav button:hover { color: var(--primary); }
nav a { text-decoration: none; color: var(--dark); font-weight: 500; padding: 5px 0; position: relative; transition: color 0.3s; display: flex; align-items: center; gap: 5px; }
nav a:hover { color: var(--primary); }
nav a.active { color: var(--primary); }
nav a.active:after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 2px; background-color: var(--primary); }

#theme-entry-btn { display: flex; align-items: center; justify-content: center; min-width: 36px; height: 100%; }

/* =============================================
   Hero 主视觉区域
   ============================================= */
.hero { 
    background: linear-gradient(135deg, #4a6fa5 0%, #166088 100%); color: white; 
    padding: 50px 0; text-align: center; border-radius: 0 0 20px 20px; 
    margin-bottom: 40px; box-shadow: 0 10px 20px rgba(22, 96, 136, 0.1); 
}
.hero h2 { font-size: 2.2rem; margin-bottom: 10px; }
.hero p { font-size: 1.1rem; max-width: 700px; margin: 0 auto 20px; opacity: 0.9; }
.stats { display: flex; justify-content: center; margin-top: 20px; }
.stat-item { text-align: center; }
.stat-number { font-size: 2.5rem; font-weight: bold; display: block; color: var(--accent); text-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.stat-label { font-size: 1rem; opacity: 0.9; }

/* =============================================
   搜索与筛选
   ============================================= */
.search-section { background-color: var(--bg-section); padding: 25px; border-radius: 12px; box-shadow: 0 5px 15px var(--shadow-soft); margin-bottom: 30px; }
.search-box { display: flex; gap: 10px; margin-bottom: 20px; }
.search-input-wrapper { position: relative; flex: 1; display: flex; }
.search-input-wrapper input { width: 100%; padding: 12px 40px 12px 40px; border: 1px solid var(--light-gray); border-radius: 8px; font-size: 1rem; transition: border 0.3s; }
.search-input-wrapper input:focus { outline: none; border-color: var(--primary); }
.search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--gray); pointer-events: none; }
.clear-icon { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: var(--gray); cursor: pointer; display: none; transition: color 0.2s; font-size: 1.1rem; }
.clear-icon:hover { color: var(--accent); }
.search-box .result-count { display: flex; align-items: center; padding: 0 15px; background: var(--light); border-radius: 8px; color: var(--primary); font-weight: bold; font-size: 14px; white-space: nowrap; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filter-btn { padding: 6px 16px; background-color: var(--light-gray); color: var(--dark); border: none; border-radius: 20px; cursor: pointer; transition: all 0.3s; font-size: 13px; font-weight: 500; }
.filter-btn:hover { background-color: #dbe2e8; }
.filter-btn.active { background-color: var(--primary); color: white; box-shadow: 0 2px 8px rgba(74, 111, 165, 0.3); }

/* =============================================
   图书网格
   ============================================= */
.section-title { font-size: 1.5rem; margin-bottom: 20px; color: var(--dark); display: flex; align-items: center; gap: 10px; }
.section-title i { color: var(--accent); }
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 25px; margin-bottom: 40px; min-height: 200px; }
.book-card { 
    background-color: var(--bg-card); border-radius: 12px; overflow: hidden; 
    box-shadow: 0 4px 12px var(--shadow-soft); transition: transform 0.3s, box-shadow 0.3s; 
    cursor: pointer; display: flex; flex-direction: column; position: relative; 
}
.book-card:hover { transform: translateY(-6px); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1); }
.book-cover { height: 260px; background-color: var(--light-gray); display: flex; align-items: center; justify-content: center; position: relative; border-bottom: 1px solid var(--light-gray); overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-info { padding: 15px; flex-grow: 1; display: flex; flex-direction: column; }
.book-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--dark); line-height: 1.4; }
.book-author { color: var(--gray); font-size: 12px; margin-bottom: 10px; }
.book-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.book-tag { background-color: #e8f4ff; color: var(--primary); font-size: 11px; padding: 3px 8px; border-radius: 10px; }
.book-tag.theme { background-color: #fff0e6; color: var(--accent); }
.borrow-badge { position: absolute; top: 18px; left: -35px; background: rgba(220, 53, 69, 0.95); color: white; font-size: 12px; font-weight: bold; padding: 4px 40px; transform: rotate(-45deg); box-shadow: 0 2px 8px rgba(0,0,0,0.3); z-index: 2; pointer-events: none; letter-spacing: 1px; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }

/* =============================================
   分页控件
   ============================================= */
.pagination { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 40px; }
.page-btn { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--light-gray); background: white; color: var(--dark); cursor: pointer; font-size: 14px; transition: all 0.2s; }
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: #f8faff; }
.page-btn:disabled { background: var(--light-gray); color: var(--gray); cursor: not-allowed; border-color: var(--light-gray); opacity: 0.7; }

.page-select-wrapper { position: relative; display: inline-block; margin: 0 2px; cursor: pointer; }
.page-select-text { padding: 8px 16px; border-radius: 6px; background: var(--light); color: var(--primary); font-size: 14px; font-weight: bold; border: 1px solid var(--light-gray); display: flex; align-items: center; gap: 8px; transition: all 0.2s; pointer-events: none; }
.page-select-wrapper:hover .page-select-text { border-color: var(--primary); background: white; }
.page-select { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; appearance: none; -webkit-appearance: none; }

/* =============================================
   留言笔记区域
   ============================================= */
.recent-notes-section { margin-top: 50px; padding: 30px; background-color: var(--bg-section); border-radius: 12px; box-shadow: 0 5px 15px var(--shadow-soft); }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.note-card { background: var(--bg-card); border: 1px solid var(--border-light); padding: 20px; border-radius: 10px; box-shadow: 0 4px 10px var(--shadow-soft); display: flex; flex-direction: column; transition: transform 0.3s; position: relative; }
.note-card:hover { transform: translateY(-4px); box-shadow: 0 8px 15px rgba(0,0,0,0.06); }
.note-tape { position: absolute; top: -8px; left: 50%; transform: translateX(-50%) rotate(-2deg); width: 60px; height: 16px; background: rgba(74, 111, 165, 0.2); backdrop-filter: blur(2px); border-radius: 2px; }
.note-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; margin-top: 5px; }
.note-author { font-weight: bold; color: var(--secondary); font-size: 14px; }
.note-time { font-size: 12px; color: var(--gray); }
.note-content { font-size: 14px; color: var(--text-secondary); line-height: 1.6; font-style: italic; margin-bottom: 15px; flex-grow: 1; }
.note-book-ref { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px dashed #e9ecef; cursor: pointer; transition: 0.2s; }
.note-book-ref:hover { opacity: 0.8; }
.note-book-ref img { width: 32px; height: 45px; object-fit: cover; border-radius: 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.note-book-info { flex: 1; overflow: hidden; }
.note-book-title { font-size: 12px; font-weight: bold; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-book-tag { font-size: 10px; color: var(--primary); background: #e8f4ff; padding: 2px 6px; border-radius: 6px; display: inline-block; margin-top: 3px; }

/* =============================================
   弹窗 Modal
   ============================================= */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); display: none; justify-content: center; align-items: center; z-index: 1000; padding: 20px; }
.modal-content { background: var(--bg-section); width: 100%; max-width: 850px; max-height: 90vh; border-radius: 16px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.2); border-bottom: 1px solid var(--light-gray); display: flex; flex-direction: column; }
.modal-scroll-wrapper { flex: 1; overflow-y: auto; width: 100%; height: 100%; -ms-overflow-style: none; scrollbar-width: none; border-radius: 16px; }
.modal-scroll-wrapper::-webkit-scrollbar { display: none; }

.detail-header-gallery { position: relative; width: 100%; background: var(--bg-card); overflow: hidden; height: 320px; border-top-left-radius: 16px; border-top-right-radius: 16px; border-bottom: 1px solid var(--light-gray); }
.gallery-scroller { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; background: var(--bg-card); gap: 0; height: 100%; align-items: center; -ms-overflow-style: none; scrollbar-width: none; }
.gallery-scroller::-webkit-scrollbar { display: none; }
.gallery-scroller.single-item { justify-content: center; padding: 30px 0; }
.gallery-scroller.multi-item { padding: 30px calc(50% - 90px); }
.gallery-item { position: relative; flex: 0 0 auto; height: 260px; width: auto; aspect-ratio: auto; margin: 0 10px; scroll-snap-align: center; cursor: pointer; box-shadow: 0 8px 25px rgba(0,0,0,0.1); border-radius: 8px; overflow: hidden; transition: transform 0.3s; }
.gallery-item img { height: 100%; width: auto; object-fit: contain; }
.detail-borrow-badge { position: absolute; top: 20px; left: -25px; background: rgba(220, 53, 69, 0.95); color: white; font-size: 11px; font-weight: bold; padding: 3px 30px; transform: rotate(-45deg); box-shadow: 0 2px 8px rgba(0,0,0,0.3); z-index: 2; pointer-events: none; }

#close-modal-x { position: absolute; top: 15px; right: 15px; width: 40px; height: 40px; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; z-index: 100; transition: all 0.2s; border: 2px solid rgba(255,255,255,0.8); }
#close-modal-x:hover { background: rgba(255, 126, 95, 0.8); transform: rotate(90deg); }

.modal-body { padding: 0; }
.detail-text-content { padding: 25px 30px 30px 30px; }
.detail-info { flex: 1; min-width: 250px; }
.detail-title { font-size: 24px; font-weight: bold; color: var(--dark); margin-bottom: 8px; }
.detail-rating { color: #ffc107; font-size: 16px; margin-bottom: 15px; letter-spacing: 2px; }
.detail-meta-grid { display: grid; grid-template-columns: 1fr; gap: 8px; background: var(--light); padding: 15px; border-radius: 8px; margin-bottom: 15px; font-size: 13px; color: var(--text-main); border: 1px solid var(--border-light); }
.meta-label { color: var(--gray); display: inline-block; width: 60px; }
.detail-section-title { font-size: 16px; font-weight: bold; color: var(--primary); margin: 25px 0 10px; display: flex; align-items: center; gap: 8px; }
.detail-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.8; background: var(--light); padding: 15px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; }

/* =============================================
   借阅区域
   ============================================= */
.borrow-section { margin-top: 25px; background: var(--bg-card); padding: 20px; border-radius: 10px; border: 1px solid var(--border-light); box-shadow: 0 4px 15px var(--shadow-soft); }
.borrow-status-banner { padding: 12px 15px; border-radius: 8px; margin-bottom: 15px; font-size: 14px; font-weight: bold; display: flex; align-items: center; gap: 8px; }
.borrow-status-banner.available { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.borrow-status-banner.borrowed { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* =============================================
   留言墙
   ============================================= */
.message-wall { margin-top: 30px; border-top: 1px solid var(--light-gray); padding-top: 25px; }
.message-item { background: var(--light); padding: 15px 20px; border-radius: 10px; margin-bottom: 12px; border: 1px solid var(--light-gray); }
.message-header { display: flex; justify-content: space-between; margin-bottom: 8px; align-items: center; }
.message-name { font-weight: bold; font-size: 14px; color: var(--secondary); display: flex; align-items: center; gap: 6px; }
.message-time { font-size: 12px; color: var(--gray); font-family: monospace; }
.message-body { font-size: 14px; color: var(--text-secondary); line-height: 1.6; padding-left: 24px; }

/* =============================================
   交互表单
   ============================================= */
.interaction-form { margin-top: 25px; background: var(--bg-card); padding: 20px; border-radius: 10px; border: 1px solid var(--border-light); box-shadow: 0 4px 15px var(--shadow-soft); }
.form-group { margin-bottom: 15px; }
.form-control { width: 100%; padding: 10px 15px; border: 1px solid var(--border-light); border-radius: 8px; font-size: 14px; outline: none; transition: border 0.3s; background-color: var(--bg-section); color: var(--text-main); }
.form-control:focus { border-color: var(--primary); }
.captcha-group { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; background: #fff9e6; padding: 10px 15px; border-radius: 8px; border: 1px solid #ffe8a1; }
.captcha-text { font-size: 14px; font-weight: bold; color: #d39e00; }
.captcha-input { width: 80px; padding: 6px; text-align: center; border: 1px solid #ffe8a1; border-radius: 6px; outline: none; font-size: 14px; font-weight: bold; }
.captcha-input:focus { border-color: #d39e00; }
.submit-btn { width: 100%; padding: 12px; background-color: var(--primary); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: bold; transition: all 0.3s; }
.submit-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.submit-btn:disabled { background-color: var(--light-gray); color: var(--gray); cursor: not-allowed; transform: none; box-shadow: none; }
.submit-btn.success { background-color: #28a745; }

/* =============================================
   Footer 页脚
   ============================================= */
footer { background-color: var(--dark); color: white; padding: 30px 0 20px; margin-top: 40px; text-align: center; }
.footer-content { color: rgba(255, 255, 255, 0.7); font-size: 0.9rem; margin-bottom: 10px; }
.copyright { padding-top: 15px; border-top: 1px solid rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.5); font-size: 0.8rem; }
#status-msg { text-align: center; padding: 60px 20px; color: var(--gray); font-size: 1.1rem; grid-column: 1 / -1; }

/* =============================================
   PhotoSwipe 硬件加速
   ============================================= */
.pswp__img { -webkit-backface-visibility: hidden; transform: translateZ(0); }

/* =============================================
   管理员弹窗
   ============================================= */
#admin-modal-overlay { z-index: 2000; }
#admin-modal-overlay .modal-content { max-width: 350px; padding: 30px; text-align: center; height: auto; }

/* =============================================
   主题选择器
   ============================================= */
.theme-selector { position: relative; display: inline-block; width: 160px; }
.theme-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 15px; background-color: var(--bg-card); border: 1px solid var(--border-light); border-radius: 8px; color: var(--text-main); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.3s ease; box-shadow: var(--shadow-soft); }
.theme-trigger:hover { background-color: var(--bg-section); border-color: var(--accent); box-shadow: 0 4px 12px var(--shadow-soft); }
.current-color { display: inline-block; width: 16px; height: 16px; border-radius: 50%; margin-right: 8px; background-color: var(--primary); transition: all 0.3s ease; }
.theme-trigger-text { flex: 1; text-align: left; }
.theme-chevron { font-size: 12px; transition: transform 0.3s ease; margin-left: 8px; }
.theme-selector.expanded .theme-chevron { transform: rotate(180deg); }
.theme-options { position: absolute; top: calc(100% + 5px); left: 0; right: 0; background-color: var(--bg-card); border: 1px solid var(--border-light); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.3s ease; z-index: 1000; overflow: hidden; }
.theme-selector.expanded .theme-options { opacity: 1; visibility: visible; transform: translateY(0); }
.theme-option { display: flex; align-items: center; width: 100%; padding: 12px 15px; background: none; border: none; border-bottom: 1px solid var(--border-light); color: var(--text-main); font-size: 14px; cursor: pointer; transition: all 0.2s ease; text-align: left; }
.theme-option:last-child { border-bottom: none; }
.theme-option:hover { background-color: var(--bg-section); }
.theme-option.active { background-color: var(--bg-section); font-weight: 600; }
.theme-option.active .color-block { transform: scale(1.1); box-shadow: 0 0 0 2px var(--accent); }
.color-block { width: 20px; height: 20px; border-radius: 4px; margin-right: 10px; transition: all 0.2s ease; }
.theme-name { flex: 1; }

#theme-modal-overlay { z-index: 1999; display: none; }
#theme-modal-overlay .modal-content { max-width: 350px; padding: 25px; text-align: center; height: auto; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }

/* 主题色点对应 */
html[data-theme="light"] .current-color { background-color: #f8f9fa; box-shadow: 0 0 0 1px #dee2e6; }
html[data-theme="dark"] .current-color { background-color: #21262d; box-shadow: 0 0 0 1px #6b8cbc; }
html[data-theme="cyan-mountain"] .current-color { background-color: #2E5C6E; box-shadow: 0 0 0 1px #4A7C8C; }

/* =============================================
   响应式布局
   ============================================= */
@media (max-width: 768px) {
    .theme-selector { width: 140px; }
    .theme-trigger { padding: 8px 12px; font-size: 13px; }
    .theme-option { padding: 10px 12px; font-size: 13px; }
    .current-color { width: 14px; height: 14px; }
    .color-block { width: 16px; height: 16px; }
    .detail-header-gallery { height: 260px; }
    .gallery-scroller.multi-item { padding-left: calc(50% - 70px); padding-right: calc(50% - 70px); }
    .gallery-item { height: 220px; }
    .header-content { flex-direction: column; gap: 15px; }
    nav ul { gap: 15px; flex-wrap: wrap; justify-content: center; }
    .hero h2 { font-size: 1.8rem; }
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .book-cover { height: 200px; }
    .search-box { flex-direction: column; }
    .search-box .result-count { width: 100%; justify-content: center; padding: 10px; }
    .captcha-group { flex-direction: column; align-items: flex-start; }
    .captcha-input { width: 100%; }
    .detail-text-content { padding: 20px; }
}
