/* ============================================
   BOOK READER MODAL
   ============================================ */

/* Overlay */
.book-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.book-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Modal Container */
.book-modal {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 1400px;
  max-height: 100vh;
  padding: 15px;
}

/* Header */
.book-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  margin-bottom: 15px;
  flex-shrink: 0;
}

.book-modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: white;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: white;
  flex-shrink: 0;
  margin-left: 15px;
}

.book-modal-close:hover {
  background: var(--coral);
  transform: scale(1.1);
}

/* Reader Container */
.book-reader {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  gap: 20px;
}

/* Navigation Buttons */
.book-nav-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: white;
  flex-shrink: 0;
}

.book-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.book-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Page Container */
.book-page-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  position: relative;
}

.book-page-wrapper {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-page {
  max-width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 0.3s ease;
}

.book-page.loading {
  opacity: 0.5;
}

/* Prevent image download */
.book-page-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
}

/* Loading Spinner */
.book-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 2rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Footer / Progress */
.book-modal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
  gap: 20px;
  flex-shrink: 0;
}

.book-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.book-progress-dots {
  display: flex;
  gap: 6px;
  max-width: 300px;
  overflow: hidden;
}

.book-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.book-progress-dot:hover {
  background: rgba(255, 255, 255, 0.6);
  transform: scale(1.3);
}

.book-progress-dot.active {
  background: var(--yellow);
  transform: scale(1.2);
}

.book-page-counter {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Swipe hint for mobile */
.book-swipe-hint {
  display: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  text-align: center;
}

/* Buy Button */
.book-buy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #FF9900 0%, #FF6600 100%);
  color: white;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 25px;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(255, 153, 0, 0.3);
}

.book-buy-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 153, 0, 0.4);
}

/* ============================================
   DESKTOP STYLES
   ============================================ */
@media (min-width: 768px) {
  .book-modal {
    padding: 20px;
  }
  
  .book-modal-header {
    padding: 15px 25px;
  }
  
  .book-modal-title {
    font-size: 1.4rem;
  }
  
  .book-page {
    max-height: calc(100vh - 200px);
  }
  
  .book-nav-btn {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
  }
}

/* ============================================
   MOBILE STYLES
   ============================================ */
@media (max-width: 767px) {
  .book-modal {
    padding: 10px;
  }
  
  .book-modal-header {
    padding: 8px 12px;
    margin-bottom: 10px;
  }
  
  .book-modal-title {
    font-size: 1rem;
  }
  
  .book-modal-close {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
  
  /* Hide side nav buttons on mobile - use swipe */
  .book-nav-btn {
    display: none;
  }
  
  .book-reader {
    gap: 0;
  }
  
  .book-page {
    max-height: calc(100vh - 140px);
    border-radius: var(--radius-sm);
  }
  
  .book-modal-footer {
    padding: 10px;
    gap: 15px;
  }
  
  .book-swipe-hint {
    display: block;
  }
  
  /* Hide dots on mobile if too many pages */
  .book-progress-dots {
    display: none;
  }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media (max-width: 900px) and (orientation: landscape) {
  .book-modal {
    padding: 8px;
  }
  
  .book-modal-header {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.7);
    margin-bottom: 0;
  }
  
  .book-reader {
    height: 100%;
  }
  
  .book-page {
    max-height: calc(100vh - 80px);
  }
  
  .book-modal-footer {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    padding: 8px 20px;
  }
}

/* ============================================
   ZOOM FUNCTIONALITY
   ============================================ */
.book-page-container.zoomed {
  cursor: grab;
  overflow: auto;
}

.book-page-container.zoomed:active {
  cursor: grabbing;
}

.book-page-container.zoomed .book-page {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.book-page:not(.zoomed-img) {
  cursor: zoom-in;
}

/* Zoom button */
.book-zoom-btn {
  position: absolute;
  bottom: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: white;
  z-index: 5;
}

.book-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

@media (max-width: 767px) {
  .book-zoom-btn {
    bottom: 70px;
    right: 10px;
    width: 40px;
    height: 40px;
  }
}
