body {
  font-family: 'Poppins', sans-serif;
  background: #f9f9fc;
  color: #222;
  margin: 0;
  padding: 0;
}

header {
  text-align: center;
  background: linear-gradient(135deg, #673ab7, #512da8);
  color: white;
  padding: 2rem 1rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 2.2rem;
  margin-bottom: .5rem;
}

header input {
  width: 90%;
  max-width: 400px;
  padding: .8rem;
  margin-top: 1rem;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
}

.category {
  padding: 2rem 1rem;
}

.category h2 {
  margin-bottom: 1rem;
  border-left: 5px solid #673ab7;
  padding-left: .6rem;
}

.books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

.book {
  background: white;
  border-radius: 15px;
  padding: 1rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
  transition: transform 0.2s ease;
}

.book:hover {
  transform: scale(1.03);
}

.book img {
  width: 100%;
  border-radius: 10px;
}

.book h3 {
  margin: 0.7rem 0 0.3rem;
  font-size: 1.1rem;
}

.book p {
  color: #555;
  font-size: 0.9rem;
  margin-bottom: .6rem;
}

.button {
  display: inline-block;
  padding: .4rem .8rem;
  border-radius: 8px;
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
}

.free {
  background-color: #4CAF50;
}

.buy {
  background-color: #ff9800;
}

.show-more {
  display: block;
  margin: 1rem auto;
  background: #673ab7;
  color: white;
  border: none;
  border-radius: 8px;
  padding: .6rem 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.3s ease;
}

.show-more:hover {
  background: #512da8;
}
/* 🔄 Button loading animation */
.button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}

.button.loading::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid white;
  border-top: 2px solid transparent;
  border-radius: 50%;
  transform: translateY(-50%);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}
/* 🎬 Header & Button Animations */
@keyframes slideDownFade {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* ✨ Apply to header text */
header h1,
header p,
header input {
  animation: slideDownFade 0.8s ease forwards;
}

/* ⬅️ Back to Home button animation */
#backHome {
  opacity: 0;
  transform: translateY(15px);
  animation: slideUpFade 0.8s ease forwards;
  animation-delay: 0.3s; /* slides in just after header text */
}
/* 📚 Book card reveal animation */
@keyframes fadeUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 💫 Animate all book cards when they appear */
.book {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.6s ease forwards;
}

/* ⏱️ Make them stagger in nicely */
.books .book:nth-child(1) { animation-delay: 0.1s; }
.books .book:nth-child(2) { animation-delay: 0.2s; }
.books .book:nth-child(3) { animation-delay: 0.3s; }
.books .book:nth-child(4) { animation-delay: 0.4s; }
.books .book:nth-child(5) { animation-delay: 0.5s; }
.books .book:nth-child(6) { animation-delay: 0.6s; }
.books .book:nth-child(7) { animation-delay: 0.7s; }
.books .book:nth-child(8) { animation-delay: 0.8s
/* 🔄 Search loading spinner */
.search-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.search-loading div {
  width: 25px;
  height: 25px;
  border: 3px solid #ccc;
  border-top-color: #673ab7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
#newBooksBadge {
  position: fixed;
  top: 15px;
  right: 15px;
  background-color: #4caf50;
  color: white;
  padding: 8px 14px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  animation: popIn 1.5s ease forwards, pulse 2s infinite 2s;
  opacity: 0;
}

/* Smooth pop-in animation */
@keyframes popIn {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Gentle pulsing to grab attention */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
/* --- Header --- */
header {
  text-align: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #6a11cb, #2575fc);
  color: white;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

/* Animated gradient flow */
header::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(120deg, rgba(255,255,255,0.2), transparent, rgba(255,255,255,0.1));
  animation: shine 5s linear infinite;
}

@keyframes shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Title */
header h1 {
  font-family: "Poppins", sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
}

/* Subtitle */
header p {
  font-family: "Inter", sans-serif;
  font-size: 1rem;
  color: #e0e0e0;
  margin-bottom: 1rem;
}

/* Search Bar */
#searchBar {
  width: 80%;
  max-width: 400px;
  padding: 0.8rem 1rem;
  border-radius: 50px;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: "Inter", sans-serif;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#searchBar:focus {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.3);
}

/* New Books Badge */
#newBooksBadge {
  position: absolute;
  top: 15px;
  right: 15px;
  background-color: #4caf50;
  color: white;
  padding: 8px 14px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  animation: popIn 1.5s ease forwards, pulse 2s infinite 2s;
  opacity: 0;
}

/* Animations */
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.icon {
  width: 1.4rem;
  height: 1.4rem;
  vertical-align: middle;
  margin-right: 6px;
}

/* Search Bar + Icon */
.search-bar-container {
  position: relative;
  display: inline-block;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
  width: 1.2rem;
  height: 1.2rem;
}

#searchBar {
  width: 80%;
  max-width: 400px;
  padding: 0.8rem 1rem 0.8rem 2.5rem; /* more padding for icon */
  border-radius: 50px;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: "Inter", sans-serif;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#searchBar:focus {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.3);
}
header {
  text-align: center;
  padding: 2rem 1rem;
  position: relative;
  color: #fff;
  background: linear-gradient(135deg, #5b86e5, #36d1dc);
  border-radius: 0 0 1.5rem 1.5rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  font-family: "Poppins", sans-serif;
}

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

#newBooksBadge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background-color: #00c853;
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  animation: pulse 2.5s infinite;
  box-shadow: 0 0 10px rgba(0,200,83,0.5);
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 5px rgba(0,200,83,0.4); }
  50% { transform: scale(1.07); box-shadow: 0 0 20px rgba(0,200,83,0.7); }
  100% { transform: scale(1); box-shadow: 0 0 5px rgba(0,200,83,0.4); }
}

/* Search bar with colorful icon */
.search-bar-container {
  position: relative;
  display: inline-block;
  margin-top: 1.2rem;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #555;
}

#searchBar {
  width: 80%;
  max-width: 400px;
  padding: 0.8rem 1rem 0.8rem 2.7rem;
  border-radius: 50px;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: "Inter", sans-serif;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

#searchBar:focus {
  box-shadow: 0 0 15px rgba(91,134,229,0.6);
  transform: scale(1.05);
}