/* Books by Genres Section */
.books-by-genres-section {
  padding: 4rem 2rem 1rem 2rem; /* Reduced bottom padding from 4rem to 1rem */
  background: #fff;
  position: relative;
}

.books-by-genres-section .container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Section Header */
.books-by-genres-section .section-header {
  text-align: center;
  margin-bottom: 2rem;
}

.books-by-genres-section .section-title {
  font-family: 'Roboto Slab', serif;
  font-size: 30px;
  font-weight: 600;
  color: #2C3E50;
  margin: 0;
  line-height: 100%;
}

/* Genre Tabs Wrapper */
.genre-tabs-wrapper {
  margin-bottom: 3rem;
  display: flex;
  justify-content: center;
}

/* Genre Tabs Container */
.genre-tabs {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

/* Individual Genre Tab */
.genre-tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: #E8F4F8;
  color: #2C3E50;
  font-family: 'Roboto Slab', serif;
  font-size: 16px;
  font-weight: 500;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.genre-tab:hover {
  background: #D0E8F2;
  transform: translateY(-2px);
}

.genre-tab.active {
  background: #4A90E2;
  color: #fff;
  box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3);
}

/* More Options Tab - Special Styling */
.genre-tab.more-options {
  background: #F5F5F5;
  color: #666;
  border: 2px dashed #ccc;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.genre-tab.more-options .dropdown-icon {
  transition: transform 0.3s ease;
}

.genre-tab.more-options.active .dropdown-icon {
  transform: rotate(180deg);
}

.genre-tab.more-options:hover {
  background: #E8E8E8;
  border-color: #999;
}

.genre-tab.more-options.active {
  background: #666;
  color: #fff;
  border-color: #666;
  border-style: solid;
}

/* More Options Wrapper */
.genre-more-options-wrapper {
  position: relative;
  display: inline-block;
}

/* Dropdown Menu */
.genre-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  background: #fff;
  border: 2px solid #E0E0E0;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  z-index: 1000;
  display: none;
  padding: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.genre-dropdown-menu.show {
  display: block;
}

.genre-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: #2C3E50;
  font-family: 'Roboto Slab', serif;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
}

.genre-dropdown-item:last-child {
  margin-bottom: 0;
}

.genre-dropdown-item:hover {
  background: #E8F4F8;
  color: #4A90E2;
}

.genre-dropdown-item.active {
  background: #4A90E2;
  color: #fff;
}

/* Books Grid Container */
.genre-books-container {
  position: relative;
  margin-top: 2rem;
  padding: 0 60px; /* Add horizontal padding for arrow spacing */
  max-width: 100%; /* Allow full width */
  margin-left: auto;
  margin-right: auto;
  min-height: 600px; /* Reserve space to prevent layout shift during loading */
}

/* Books Grid with Horizontal Scroll */
.genre-books-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, auto);
  grid-auto-columns: 200px; /* Auto-size columns for scrolling */
  gap: 1.5rem 1.5rem; /* Good spacing between books */
  overflow-x: auto;
  overflow-y: visible;
  padding: 1rem 0;
  scroll-behavior: smooth;
  justify-items: start; /* Align items to start, no stretching */
  max-width: 880px; /* Fit exactly 4 columns: (200px * 4) + (1.5rem * 3 gaps) = 880px */
  margin: 0 auto;
  
  /* Hide scrollbar but keep functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.genre-books-grid::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Book Card */
.genre-book-card {
  display: block;
  text-decoration: none;
  transition: transform 0.3s ease;
  width: 200px;
}

.genre-book-card:hover {
  transform: translateY(-8px);
}

/* Book Cover Wrapper */
.genre-book-cover-wrapper {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #E8F4F8 0%, #D0E8F2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Book Cover Image */
.genre-book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Book Cover Placeholder */
.genre-book-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Roboto Slab', serif;
  font-size: 16px;
  color: #999;
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
}

/* Book Title (Optional - if you want to show titles below covers) */
.genre-book-title {
  margin-top: 0.75rem;
  font-family: 'Roboto Slab', serif;
  font-size: 14px;
  font-weight: 500;
  color: #2C3E50;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
  max-width: 280px;
}

/* Scroll Arrow */
.scroll-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #4A90E2;
  color: #4A90E2;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  z-index: 10;
  opacity: 1;
  visibility: visible;
}

.scroll-arrow:hover {
  background: #4A90E2;
  color: #fff;
  transform: translateY(-50%) scale(1.1);
}

.scroll-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

.scroll-arrow.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Loading State */
.genre-loading {
  text-align: center;
  padding: 3rem 0;
  font-family: 'Roboto Slab', serif;
  font-size: 16px;
  color: #666;
  min-height: 500px; /* Match approximate grid height */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* No Books State */
.genre-no-books {
  text-align: center;
  padding: 3rem 0;
  font-family: 'Roboto Slab', serif;
  font-size: 16px;
  color: #999;
  min-height: 500px; /* Match approximate grid height */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive Design */
@media (max-width: 1400px) {
  .genre-books-container {
    max-width: 100%;
  }
  
  .genre-books-grid {
    grid-auto-columns: 190px;
    max-width: 830px; /* Fit exactly 4 columns: (190px * 4) + (1.5rem * 3 gaps) = 830px */
  }
  
  .genre-book-card {
    width: 190px;
  }
  
  .genre-book-cover-wrapper {
    width: 190px;
    height: 190px;
  }
  
  .genre-book-title {
    max-width: 190px;
  }
  
  .scroll-arrow {
    right: 10px;
  }
}

@media (max-width: 968px) {
  .books-by-genres-section {
    padding: 3rem 1.5rem;
  }
  
  .genre-tabs {
    gap: 0.75rem;
  }
  
  .genre-tab {
    padding: 0.6rem 1.2rem;
    font-size: 14px;
  }
  
  .genre-books-container {
    max-width: 100%;
    padding: 0 40px;
  }
  
  .genre-books-grid {
    grid-auto-columns: 160px;
    gap: 1rem;
    max-width: 660px; /* Fit exactly 4 columns: (160px * 4) + (1rem * 3 gaps) = 660px */
  }
  
  .genre-book-card {
    width: 160px;
  }
  
  .genre-book-cover-wrapper {
    width: 160px;
    height: 160px;
  }
  
  .genre-book-title {
    max-width: 160px;
    font-size: 13px;
  }
  
  .scroll-arrow {
    width: 40px;
    height: 40px;
    right: 5px;
  }
  
  .scroll-arrow svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 640px) {
  .books-by-genres-section {
    padding: 2rem 1rem;
  }
  
  .books-by-genres-section .section-title {
    font-size: 24px;
  }
  
  .genre-tabs {
    gap: 0.5rem;
  }
  
  .genre-tab {
    padding: 0.5rem 1rem;
    font-size: 13px;
  }
  
  .genre-books-container {
    max-width: 100%;
    padding: 0 30px;
  }
  
  .genre-books-grid {
    grid-auto-columns: 130px;
    gap: 0.75rem;
    max-width: 535px; /* Fit exactly 4 columns: (130px * 4) + (0.75rem * 3 gaps) = 535px */
  }
  
  .genre-book-card {
    width: 130px;
  }
  
  .genre-book-cover-wrapper {
    width: 130px;
    height: 130px;
    border-radius: 10px;
  }
  
  .genre-book-title {
    max-width: 130px;
    font-size: 12px;
    margin-top: 0.5rem;
  }
  
  .scroll-arrow {
    width: 36px;
    height: 36px;
    right: 0;
  }
  
  .scroll-arrow svg {
    width: 18px;
    height: 18px;
  }
  
  .genre-dropdown-menu {
    min-width: 160px;
    max-height: 200px;
  }
}
