/* Black-Libary Luxury Dark & Gold Styles */
.status-tab.active {
  background: rgba(212, 175, 55, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.book-card {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(212, 175, 55, 0.3);
}

.book-cover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* 3D Book Cover Effect for Modal */
.modal-book-3d {
  box-shadow: 
    -8px 8px 25px rgba(0, 0, 0, 0.7),
    0 25px 50px -12px rgba(0, 0, 0, 0.9),
    inset 3px 0 6px rgba(255, 255, 255, 0.15),
    inset -3px 0 6px rgba(0, 0, 0, 0.6);
  border-left: 2px solid rgba(255, 255, 255, 0.12);
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* ====================================================
   BOOKSHELF VIEW STYLING
   ==================================================== */
.shelf-unit {
  position: relative;
  margin-bottom: 2.25rem;
  padding: 1.5rem 1.5rem 0 1.5rem;
  background: radial-gradient(circle at 50% 10%, rgba(30, 41, 59, 0.35) 0%, rgba(15, 23, 42, 0.6) 100%);
  border-radius: 1.25rem 1.25rem 0 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: none;
}

.shelf-books-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: flex-end;
  padding-bottom: 0.25rem;
}

@media (min-width: 640px) {
  .shelf-books-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 768px) {
  .shelf-books-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (min-width: 1024px) {
  .shelf-books-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
@media (min-width: 1280px) {
  .shelf-books-row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.shelf-book-item {
  position: relative;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), filter 0.28s ease;
  transform-origin: bottom center;
}

.shelf-book-item:hover {
  transform: translateY(-12px) scale(1.05) rotate(-1deg);
  z-index: 25;
}

.shelf-book-cover {
  position: relative;
  border-radius: 4px 10px 10px 4px;
  overflow: hidden;
  box-shadow: 
    -4px 2px 10px rgba(0, 0, 0, 0.7),
    0 12px 20px -4px rgba(0, 0, 0, 0.8),
    inset 4px 0 6px -2px rgba(255, 255, 255, 0.25),
    inset -3px 0 5px rgba(0, 0, 0, 0.5);
  border-left: 3px solid rgba(255, 255, 255, 0.15);
}

.shelf-plank {
  position: relative;
  height: 22px;
  margin: 0 -1.5rem;
  background: linear-gradient(180deg, #4a2615 0%, #30180d 45%, #1f0f07 100%);
  border-radius: 0 0 0.5rem 0.5rem;
  box-shadow: 
    inset 0 2px 1px rgba(255, 255, 255, 0.25),
    inset 0 -2px 3px rgba(0, 0, 0, 0.7),
    0 14px 25px -3px rgba(0, 0, 0, 0.9),
    0 4px 6px -2px rgba(0, 0, 0, 0.5);
  border-top: 1px solid rgba(245, 158, 11, 0.25);
  z-index: 10;
}

.shelf-plank::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 100%);
  pointer-events-none;
}

/* ====================================================
   3D COVER FLOW VIEW STYLING
   ==================================================== */
.coverflow-stage-wrapper {
  position: relative;
  width: 100%;
  min-height: 480px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, rgba(30, 41, 59, 0.45) 0%, rgba(10, 15, 29, 0.98) 75%);
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.8), 0 25px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  user-select: none;
}

.coverflow-viewport {
  position: relative;
  width: 100%;
  height: 310px;
  perspective: 1000px;
  perspective-origin: 50% 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.coverflow-card {
  position: absolute;
  width: 170px;
  aspect-ratio: 2/3;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.45s ease, filter 0.45s ease;
  will-change: transform, opacity;
  border-radius: 12px;
}

.coverflow-card-inner {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.12);
  -webkit-box-reflect: below 3px linear-gradient(to bottom, rgba(255, 255, 255, 0.22) 0%, transparent 35%);
}

.coverflow-card.active .coverflow-card-inner {
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.85),
    0 0 35px rgba(212, 175, 55, 0.4),
    0 0 0 2px rgba(245, 158, 11, 0.6);
}

#coverflow-hud {
  position: relative;
  z-index: 30;
}

@media (max-width: 768px) {
  .coverflow-stage-wrapper {
    min-height: 420px;
    border-radius: 1rem;
  }
  .coverflow-viewport {
    height: 250px;
    perspective: 800px;
  }
  .coverflow-card {
    width: 130px;
    border-radius: 8px;
  }
  .coverflow-card-inner {
    border-radius: 8px;
    -webkit-box-reflect: below 2px linear-gradient(to bottom, rgba(255, 255, 255, 0.18) 0%, transparent 28%);
  }
}

@media (max-width: 480px) {
  .coverflow-stage-wrapper {
    min-height: 370px;
  }
  .coverflow-viewport {
    height: 195px;
    perspective: 600px;
  }
  .coverflow-card {
    width: 105px;
  }
}

/* ====================================================
   LIST VIEW STYLING
   ==================================================== */
.list-view-row {
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.list-view-row:hover {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(212, 175, 55, 0.3);
  transform: translateX(3px);
}

/* ====================================================
   IN-BROWSER READER & IMMERSIVE ZEN MODE
   ==================================================== */
#reader-overlay {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#reader-topbar, #reader-bottombar {
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  will-change: transform, opacity;
}

/* Reader Mobile Responsive Guards: Back button must NEVER shrink or overflow */
#reader-back-btn {
  flex-shrink: 0 !important;
}

/* When Zen mode is active, smoothly slide bars out */
#reader-overlay.reader-zen-mode #reader-topbar {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

#reader-overlay.reader-zen-mode #reader-bottombar {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#reader-overlay.reader-zen-mode #reader-floating-prev,
#reader-overlay.reader-zen-mode #reader-floating-next {
  opacity: 0 !important;
  pointer-events: none;
}

#epub-render-area {
  width: 100%;
  height: 100%;
  position: relative;
}

#epub-render-area iframe {
  border: none !important;
  width: 100% !important;
  height: 100% !important;
}

#pdf-viewer-box iframe {
  border: none !important;
  width: 100% !important;
  height: 100% !important;
  background-color: #080c14;
}

/* Touch & Mouse Drag-to-Scroll for horizontal bars */
.touch-scroll-row {
  display: flex !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x !important;
  overscroll-behavior-x: contain !important;
  scrollbar-width: thin !important;
  scrollbar-color: rgba(212, 175, 55, 0.45) rgba(255, 255, 255, 0.05) !important;
  cursor: grab;
  user-select: none;
}

.touch-scroll-row::-webkit-scrollbar {
  height: 4px !important;
  display: block !important;
}

.touch-scroll-row::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04) !important;
  border-radius: 9999px !important;
}

.touch-scroll-row::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.45) !important;
  border-radius: 9999px !important;
}

.touch-scroll-row::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.85) !important;
}

.touch-scroll-row.is-dragging {
  cursor: grabbing !important;
}

.touch-scroll-row > * {
  flex-shrink: 0 !important;
}

/* Edge fade cues for scrollable strips on mobile */
.scroll-fade-x {
  position: relative;
}
.scroll-fade-x::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 24px;
  background: linear-gradient(to right, transparent, rgba(6, 6, 8, 0.9));
  pointer-events: none;
  border-top-right-radius: inherit;
  border-bottom-right-radius: inherit;
}

/* Touch-friendly Reader & Comic Progress Sliders (Easy to grab and drag) */
#reader-progress-slider,
#comic-page-slider {
  height: 8px;
  touch-action: pan-x;
  cursor: pointer;
}

#reader-progress-slider::-webkit-slider-thumb,
#comic-page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d4af37;
  cursor: grab;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.8), 0 2px 5px rgba(0,0,0,0.6);
  border: 2px solid #ffffff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#reader-progress-slider::-webkit-slider-thumb:active,
#comic-page-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.25);
  box-shadow: 0 0 15px rgba(212, 175, 55, 1), 0 3px 8px rgba(0,0,0,0.8);
}

#reader-progress-slider::-moz-range-thumb,
#comic-page-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d4af37;
  cursor: grab;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.8);
}

/* --- Solid, High-Contrast Reader Popups & Menus (Guarantee 100% Opacity in all themes) --- */
#reader-layout-backdrop {
  background: rgba(0, 0, 0, 0.75) !important;
  backdrop-filter: blur(2px) !important;
  -webkit-backdrop-filter: blur(2px) !important;
  z-index: 99998 !important;
}

#reader-layout-popup,
#reader-warmth-popup {
  background-color: #0b1120 !important;
  background: #0b1120 !important;
  border: 1px solid rgba(245, 158, 11, 0.45) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.95), 0 0 25px rgba(0, 0, 0, 0.8) !important;
  color: #f8fafc !important;
  opacity: 1 !important;
  z-index: 99999 !important;
}

#reader-layout-popup label,
#reader-layout-popup .reader-popup-title {
  color: #fbbf24 !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
  text-transform: uppercase !important;
}

#reader-layout-popup span,
#reader-layout-popup p {
  color: #f8fafc !important;
}

#reader-layout-popup .text-amber-400 {
  color: #fbbf24 !important;
}

#reader-layout-popup select {
  background-color: #020617 !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#reader-layout-popup button {
  background-color: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#reader-layout-popup button:hover {
  background-color: #334155;
  color: #ffffff;
}

#reader-layout-popup button.active,
#reader-layout-popup button[data-active="true"] {
  background-color: #f59e0b !important;
  color: #000000 !important;
  font-weight: 700 !important;
  border-color: #f59e0b !important;
}

/* Mobile: Elegant Bottom-Sheet (Kindle / Apple Books Style) */
@media (max-width: 640px) {
  #reader-layout-popup {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 74vh !important;
    border-radius: 24px 24px 0 0 !important;
    border: none !important;
    border-top: 2px solid rgba(245, 158, 11, 0.6) !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.95) !important;
    padding: 16px 18px 24px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #reader-topbar {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  #reader-topbar #reader-book-title {
    font-size: 12px !important;
    max-width: 140px !important;
  }

  #reader-topbar #reader-chapter-title {
    font-size: 10px !important;
    max-width: 140px !important;
  }

  #reader-back-btn span {
    display: inline !important;
    font-size: 11px !important;
  }
}

/* Ensure mobile header never displays inline font controls */
@media (max-width: 767px) {
  #reader-font-controls {
    display: none !important;
  }
}
