/* ===== 电工机械网 - 电子书风格样式 ===== */
/* 主色调: #795548 (棕色) */

:root {
  --accent-color: #795548;
  --accent-light: #8d6e63;
  --accent-dark: #5d4037;
  --bg-primary: #faf8f5;
  --bg-secondary: #f5f0eb;
  --bg-card: #ffffff;
  --text-primary: #3e2723;
  --text-secondary: #6d4c41;
  --text-muted: #8d6e63;
  --border-color: #d7ccc8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --max-width: 1200px;
  --header-height: 64px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-primary);
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* ===== Header ===== */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo::before {
  content: "⚡";
  font-size: 24px;
}

.nav {
  display: flex;
  gap: 32px;
}

.nav a {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 15px;
}

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

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  gap: 8px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 180px;
  font-size: 14px;
  color: var(--text-primary);
}

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

.search-box button {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--accent-color);
  font-size: 16px;
}

/* ===== Main Content ===== */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px;
}

/* ===== Hero Section ===== */
.hero {
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 60px 40px;
  text-align: center;
  color: white;
  margin-bottom: 48px;
}

.hero h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 16px;
}

.hero p {
  font-size: 18px;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent-color);
  display: inline-block;
}

/* ===== Book Grid ===== */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.book-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

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

.book-cover {
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border-color) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--accent-light);
}

.book-info {
  padding: 16px;
}

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

.book-meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Category Grid ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  transition: all 0.2s;
}

.category-card:hover {
  border-color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.category-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.category-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.category-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Book List ===== */
.book-list {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 48px;
}

.book-list-item {
  display: flex;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.book-list-item:last-child {
  border-bottom: none;
}

.book-list-item:hover {
  background: var(--bg-secondary);
}

.book-list-cover {
  width: 80px;
  height: 100px;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border-color) 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--accent-light);
  flex-shrink: 0;
}

.book-list-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.book-list-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.book-list-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-list-meta {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Article Grid ===== */
.article-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 48px;
}

.article-column {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.article-column h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.article-list {
  list-style: none;
}

.article-list li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-color);
}

.article-list li:last-child {
  border-bottom: none;
}

.article-list a {
  color: var(--text-secondary);
  font-size: 14px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-list a:hover {
  color: var(--accent-color);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-secondary);
}

.breadcrumb a:hover {
  color: var(--accent-color);
}

.breadcrumb span {
  margin: 0 8px;
}

/* ===== Category Header ===== */
.category-header {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.category-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.category-header p {
  color: var(--text-muted);
  font-size: 15px;
}

/* ===== Filter Bar ===== */
.filter-bar {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.filter-options {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 32px 0;
}

.pagination a,
.pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.pagination a:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.pagination .current {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

/* ===== Article Page Layout ===== */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
}

.article-main {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-sm);
}

.article-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.sidebar-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

/* ===== Article Content ===== */
.article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.article-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 16px;
}

.article-meta {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.article-body {
  font-size: 16px;
  line-height: 1.9;
  color: var(--text-primary);
}

.article-body h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.article-body h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 24px 0 12px;
}

.article-body p {
  margin-bottom: 16px;
}

.article-body ul,
.article-body ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.article-body li {
  margin-bottom: 8px;
}

.article-body strong {
  color: var(--accent-dark);
}

/* ===== Table of Contents ===== */
.toc-list {
  list-style: none;
}

.toc-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.toc-list li:last-child {
  border-bottom: none;
}

.toc-list a {
  color: var(--text-secondary);
  font-size: 14px;
  display: block;
}

.toc-list a:hover {
  color: var(--accent-color);
}

.toc-list .toc-h2 {
  font-weight: 500;
}

.toc-list .toc-h3 {
  padding-left: 16px;
  font-size: 13px;
}

/* ===== Book Info Table ===== */
.info-table {
  width: 100%;
  font-size: 14px;
}

.info-table tr {
  border-bottom: 1px solid var(--border-color);
}

.info-table tr:last-child {
  border-bottom: none;
}

.info-table td {
  padding: 10px 0;
}

.info-table td:first-child {
  color: var(--text-muted);
  width: 80px;
}

.info-table td:last-child {
  color: var(--text-primary);
  font-weight: 500;
}

/* ===== Rating ===== */
.rating {
  color: #ffb300;
  font-size: 14px;
}

/* ===== 404 Page ===== */
.error-page {
  text-align: center;
  padding: 80px 20px;
}

.error-code {
  font-size: 120px;
  font-weight: 700;
  color: var(--accent-color);
  line-height: 1;
  margin-bottom: 24px;
  opacity: 0.8;
}

.error-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.error-desc {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.error-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-dark);
  color: white;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 48px 20px 24px;
  margin-top: 48px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
  margin-top: 12px;
}

.footer-column h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.footer-column ul {
  list-style: none;
}

.footer-column li {
  margin-bottom: 10px;
}

.footer-column a {
  color: var(--text-muted);
  font-size: 14px;
}

.footer-column a:hover {
  color: var(--accent-color);
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Related Articles ===== */
.related-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.related-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 16px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.related-item {
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.related-item:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  .article-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 12px;
  }

  .nav {
    order: 3;
    width: 100%;
    gap: 20px;
    justify-content: center;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
  }

  .search-box {
    flex: 1;
  }

  .hero {
    padding: 40px 24px;
  }

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

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

  .book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .article-grid {
    grid-template-columns: 1fr;
  }

  .article-sidebar {
    grid-template-columns: 1fr;
  }

  .article-main {
    padding: 24px;
  }

  .article-title {
    font-size: 22px;
  }

  .filter-bar {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .error-code {
    font-size: 80px;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .book-grid {
    grid-template-columns: 1fr;
  }

  .book-list-item {
    flex-direction: column;
  }

  .book-list-cover {
    width: 100%;
    height: 160px;
  }

  .error-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}
