/* 全局重置与基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f4f4f4;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 头部与导航 */
header {
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo a {
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: bold;
  color: #333;
}

.nav-links {
  display: flex;
  list-style: none;
}

.nav-links li {
  margin-left: 20px;
}

.nav-links a {
  text-decoration: none;
  color: #555;
  font-weight: 500;
  transition: color 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: #007bff;
}

.hamburger {
  display: none;
  cursor: pointer;
  background: none;
  border: none;
}

.hamburger span {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px 0;
  background: #333;
  transition: all 0.3s ease-in-out;
}

/* 主体内容 */
main {
  padding: 2rem 0;
}

section {
  margin-bottom: 2rem;
}

h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 2rem;
  color: #333;
}

/* 英雄区域 */
.hero {
  background: linear-gradient(to right, #007bff, #0056b3);
  color: #fff;
  text-align: center;
  padding: 4rem 0;
  border-radius: 8px;
  margin-bottom: 2rem;
}

.hero h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: #fff;
}

/* 图书列表 */
.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  text-decoration: none;
  color: inherit;
}

.book-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.book-card figure {
  margin: 0;
}

.book-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.book-card figcaption {
  padding: 1rem;
}

.book-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.book-card p {
  font-size: 0.9rem;
  color: #666;
}

/* 分类 */
.category-list {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.category-card {
  background: #007bff;
  color: #fff;
  padding: 1rem 2rem;
  border-radius: 25px;
  text-decoration: none;
  transition: background 0.3s ease;
}

.category-card:hover {
  background: #0056b3;
}

/* 侧边栏 */
aside details {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1rem;
}

aside summary {
  cursor: pointer;
  font-weight: bold;
}

/* 底部 */
footer {
  background: #333;
  color: #fff;
  text-align: center;
  padding: 2rem 0;
  margin-top: 2rem;
}

#back-to-top {
  background: #007bff;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 1rem;
  transition: background 0.3s ease;
}

#back-to-top:hover {
  background: #0056b3;
}

/* 表单样式 */
form {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.form-group input.error {
  border-color: red;
}

.error-message {
  color: red;
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

form button {
  background: #007bff;
  color: #fff;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.3s ease;
}

form button:hover {
  background: #0056b3;
}

/* 图书详情页 */
#book-detail {
  display: flex;
  gap: 2rem;
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
}

#book-detail figure {
  flex: 1;
}

#book-detail img {
  width: 100%;
  border-radius: 8px;
}

#book-detail .book-info {
  flex: 2;
}

/* 加载动画 */
.loader-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loader-animation {
  border: 8px solid #f3f3f3;
  border-top: 8px solid #007bff;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* 伪元素装饰 */
h2::after {
  content: "";
  display: block;
  width: 50px;
  height: 3px;
  background: #007bff;
  margin: 0.5rem auto 0;
}

/* 响应式设计 */
/* 平板 */
@media (max-width: 1200px) and (min-width: 769px) {
  .container {
    width: 90%;
  }
}

/* 移动端 */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    background: #fff;
    position: absolute;
    top: 60px;
    left: 0;
    padding: 1rem 0;
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links li {
    margin: 10px 20px;
  }

  .hamburger {
    display: block;
  }

  #book-detail {
    flex-direction: column;
  }
}
