/* ============================================
   电子书宝库 - 与 AutoClaw 主页统一风格
   主题: 蓝紫渐变 (#1890ff → #722ed1) 亮色风格
   ============================================ */

:root {
  --primary: #1890ff;
  --primary-dark: #096dd9;
  --secondary: #722ed1;
  --accent: #13c2c2;
  --text: #333;
  --text-light: #666;
  --text-muted: #999;
  --bg-light: #f5f7fa;
  --bg-card: #ffffff;
  --bg-hover: #f0f5ff;
  --white: #ffffff;
  --border: #e8e8e8;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --font-mono: "SF Mono", "Monaco", "Consolas", "Microsoft YaHei", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--font-sans);
  line-height: 1.8;
  color: var(--text);
  background: var(--bg-light);
}

a { text-decoration: none; color: inherit; }

/* ===== 导航栏 (与主页一致) ===== */
.navbar {
  background: var(--white);
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: var(--primary);
}

.logo span {
  color: var(--secondary);
}

.nav-links {
  display: flex;
  gap: 30px;
  align-items: center;
}

.nav-links a {
  color: var(--text);
  font-weight: 500;
  transition: color 0.3s;
}

.nav-links a:hover {
  color: var(--primary);
}

.nav-links a.active {
  color: var(--primary);
  font-weight: 600;
}

.nav-cta {
  background: var(--gradient);
  color: var(--white) !important;
  padding: 8px 16px;
  border-radius: 6px;
}

/* 移动端菜单按钮 */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
}

/* ===== Hero 区域 (主页风格) ===== */
.hero {
  background: var(--gradient);
  color: var(--white);
  padding: 80px 20px 60px;
  text-align: center;
}

.hero h1 {
  font-size: 42px;
  margin-bottom: 16px;
  font-weight: 700;
  animation: fadeInUp 0.8s ease;
}

.hero .subtitle {
  font-size: 18px;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 32px;
  animation: fadeInUp 0.8s ease 0.2s both;
}

.hero-stats {
  display: flex;
  gap: 40px;
  justify-content: center;
  flex-wrap: wrap;
  animation: fadeInUp 0.8s ease 0.4s both;
}

.hero-stat {
  text-align: center;
}

.hero-stat .num {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--font-mono);
  display: block;
}

.hero-stat .label {
  font-size: 14px;
  opacity: 0.85;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 搜索区域 ===== */
.search-section {
  max-width: 800px;
  margin: -40px auto 0;
  padding: 0 20px;
  position: relative;
  z-index: 10;
}

.search-box {
  position: relative;
  background: var(--white);
  border-radius: 50px;
  box-shadow: var(--shadow-hover);
  padding: 6px;
  display: flex;
  align-items: center;
}

.search-box input {
  flex: 1;
  padding: 16px 24px 16px 56px;
  font-size: 16px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear {
  background: var(--bg-light);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  transition: all 0.2s;
}

.search-clear:hover {
  background: #ff4d4f;
  color: white;
}

.search-clear.visible {
  display: flex;
}

/* ===== 热门分类标签 ===== */
.hot-categories {
  max-width: 1200px;
  margin: 24px auto 0;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.cat-tag:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.cat-tag.active {
  background: var(--gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
}

.cat-tag .count {
  font-size: 12px;
  opacity: 0.7;
  font-family: var(--font-mono);
}

/* ===== 主内容区 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.results-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-count {
  font-family: var(--font-mono);
  color: var(--primary);
  font-weight: 700;
}

.results-meta {
  font-size: 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ===== 书籍卡片网格 ===== */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.book-card {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.book-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.book-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
}

.book-card:hover::before {
  opacity: 1;
}

.book-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.book-author {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.book-author .icon {
  color: var(--secondary);
}

.book-category {
  display: inline-block;
  font-size: 12px;
  color: var(--primary);
  background: var(--bg-hover);
  padding: 4px 12px;
  border-radius: 50px;
  margin-bottom: 16px;
  font-weight: 500;
  align-self: flex-start;
}

.book-formats {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.format-badge {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg-light);
  color: var(--text-light);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  text-transform: uppercase;
}

.book-download {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--gradient);
  color: white;
  text-decoration: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
}

.book-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(24, 144, 255, 0.4);
}

/* ===== 高亮匹配 ===== */
mark {
  background: #fffacd;
  color: var(--text);
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
}

/* ===== 空状态 / 加载中 ===== */
.empty-state,
.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state .icon,
.loading-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.empty-state .title {
  font-size: 20px;
  color: var(--text-light);
  margin-bottom: 8px;
  font-weight: 600;
}

.loading-state .spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 默认视图（推荐书籍） ===== */
.default-view {
  margin-top: 24px;
}

.section-title-bar {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.section-title-bar .icon {
  color: var(--primary);
}

/* ===== 加载更多 ===== */
.load-more {
  text-align: center;
  margin-top: 40px;
}

.load-more button {
  padding: 12px 40px;
  background: var(--white);
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 50px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: all 0.3s;
}

.load-more button:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(24, 144, 255, 0.3);
}

/* ===== Footer (与主页一致) ===== */
.footer {
  background: #1a1a2e;
  color: rgba(255,255,255,0.7);
  padding: 60px 20px 30px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}

.footer-section h4 {
  color: white;
  margin-bottom: 16px;
  font-size: 16px;
}

.footer-section p {
  margin-bottom: 8px;
  font-size: 14px;
}

.footer-section a {
  color: rgba(255,255,255,0.7);
  transition: color 0.3s;
}

.footer-section a:hover {
  color: var(--primary);
}

.footer-bottom {
  text-align: center;
  padding-top: 30px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
  font-family: var(--font-mono);
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  }

  .nav-links.show {
    display: flex;
  }

  .hero {
    padding: 60px 20px 50px;
  }

  .hero h1 {
    font-size: 28px;
  }

  .hero .subtitle {
    font-size: 16px;
  }

  .hero-stats {
    gap: 24px;
  }

  .hero-stat .num {
    font-size: 24px;
  }

  .container {
    padding: 30px 16px 60px;
  }

  .results-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .search-box input {
    padding: 14px 20px 14px 50px;
    font-size: 15px;
  }

  .search-icon {
    left: 20px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1025px) {
  .results-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1400px) {
  .results-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

::selection {
  background: var(--primary);
  color: white;
}
