/* ==================== FLIPBOOK CORE STYLES ==================== */
/* FIXED VERSION - Proper mobile scaling with dimension sync */

/* Clean white background */
body {
  margin: 0;
  padding: 0;
  background-color: #f5f5f7;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
  width: 100%;
}

/* ========== BOOK WRAPPER - PERFECT CENTER ========== */
.book-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 100vh;
  padding: 30px 20px;
  box-sizing: border-box;
}

/* Main flipbook container - 480×680 (Desktop) */
#flipbook {
  width: 480px !important;
  height: 680px !important;
  margin: 0 auto !important;
  position: relative !important;
  background: white;
  box-shadow: 0 15px 35px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  flex-shrink: 0;
  left: 0 !important;
  right: 0 !important;
  border-radius: 4px;
}

/* Individual pages - 480×680 - NO SCROLL */
.page {
  width: 480px !important;
  height: 680px !important;
  background: white;
  border: none;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden !important;
  backface-visibility: hidden;
  transform-origin: left center;
  box-sizing: border-box;
  padding: 0 !important;
}

/* First page */
.first_page {
  background: white;
}

/* ========== BOTTOM PAGE NUMBER ========== */
.page-number {
  position: absolute;
  bottom: 15px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: #8e8e98;
  font-weight: 500;
  letter-spacing: 1.5px;
  z-index: 30;
  pointer-events: none;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  padding: 5px 0;
  background: transparent;
  text-transform: uppercase;
}

.page-number.current {
  color: #FF6B4A;
  font-weight: 700;
}

/* ========== REMOVE ALL BUTTONS ========== */
#prevBtn, 
#nextBtn, 
button, 
.nav-button, 
.nav-left, 
.nav-right, 
.nav-controls,
.page-indicator, 
.page-indicator-modern,
[class*="nav"], 
[class*="btn"] {
  display: none !important;
}

/* Turn.js overrides - 480×680 */
.turn-page {
  background-color: white !important;
  border: none !important;
  width: 480px !important;
  height: 680px !important;
  box-shadow: none !important;
}

/* Ensure book stays centered */
#flipbook.centered {
  margin-left: auto !important;
  margin-right: auto !important;
  left: 0 !important;
  right: 0 !important;
  position: relative !important;
}

/* Disable text selection */
.page {
  user-select: none;
}

/* Images fit properly */
img {
  max-width: 100%;
  height: auto;
}

/* ========== COMPLETELY DISABLE ALL SCROLLBARS ========== */
.page::-webkit-scrollbar,
#flipbook::-webkit-scrollbar,
.turn-page::-webkit-scrollbar,
.book-wrapper::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

/* ========== PREVENT BOTTOM HOVER PAGE CHANGE ========== */
#flipbook {
  pointer-events: auto;
}

.page {
  pointer-events: none;
}

#flipbook {
  pointer-events: auto !important;
  cursor: pointer;
}

.page img,
.page .bnx-top-label,
.page .ui-header-label {
  pointer-events: none;
}

.turn-page-wrapper,
.turn-page {
  pointer-events: none;
}

#flipbook {
  pointer-events: auto;
}

/* ========== DESKTOP LARGE SCREENS (1200px+) ========== */
@media (min-width: 1200px) {
  .book-wrapper {
    padding: 40px 30px;
  }
  
  #flipbook {
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    transition: box-shadow 0.3s ease;
  }
  
  #flipbook:hover {
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
  }
}

/* ========== DESKTOP SMALL / LAPTOP (992px - 1199px) ========== */
@media (min-width: 992px) and (max-width: 1199px) {
  .book-wrapper {
    padding: 30px 25px;
  }
  
  #flipbook {
    width: 480px !important;
    height: 680px !important;
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
  }
  
  .page {
    width: 480px !important;
    height: 680px !important;
  }
  
  .turn-page {
    width: 480px !important;
    height: 680px !important;
  }
  
  .page-number {
    bottom: 12px;
    font-size: 10px;
  }
}

/* ========== TABLET LANDSCAPE (768px - 991px) - Scale: 0.917 ========== */
@media (min-width: 768px) and (max-width: 991px) {
  .book-wrapper {
    padding: 25px 20px;
  }
  
  #flipbook {
    width: 440px !important;
    height: 624px !important;
    box-shadow: 0 12px 25px rgba(0,0,0,0.18);
  }
  
  .page {
    width: 440px !important;
    height: 624px !important;
  }
  
  .turn-page {
    width: 440px !important;
    height: 624px !important;
  }
  
  .page-number {
    bottom: 12px;
    font-size: 10px;
    letter-spacing: 1.2px;
  }
}

/* ========== TABLET PORTRAIT (576px - 767px) - Scale: 0.833 ========== */
@media (min-width: 576px) and (max-width: 767px) {
  .book-wrapper {
    padding: 20px 15px;
  }
  
  #flipbook {
    width: 400px !important;
    height: 567px !important;
    box-shadow: 0 10px 22px rgba(0,0,0,0.15);
    border-radius: 3px;
  }
  
  .page {
    width: 400px !important;
    height: 567px !important;
  }
  
  .turn-page {
    width: 400px !important;
    height: 567px !important;
  }
  
  .page-number {
    bottom: 10px;
    font-size: 9px;
    letter-spacing: 1px;
    padding: 3px 0;
  }
}

/* ========== MOBILE LARGE (425px - 575px) - Scale: 0.75 ========== */
@media (min-width: 425px) and (max-width: 575px) {
  body {
    background-color: #f5f5f7;
  }
  
  .book-wrapper {
    padding: 15px 12px;
    min-height: 100vh;
    background-color: #f5f5f7;
  }
  
  #flipbook {
    width: 360px !important;
    height: 510px !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    border-radius: 3px;
  }
  
  .page {
    width: 360px !important;
    height: 510px !important;
  }
  
  .turn-page {
    width: 360px !important;
    height: 510px !important;
  }
  
  .page-number {
    bottom: 8px;
    font-size: 9px;
    letter-spacing: 1px;
    padding: 3px 0;
  }
}

/* ========== MOBILE MEDIUM (375px - 424px) - Scale: 0.708 ========== */
@media (min-width: 375px) and (max-width: 424px) {
  body {
    background-color: #f5f5f7;
  }
  
  .book-wrapper {
    padding: 12px 10px;
    min-height: 100vh;
    background-color: #f5f5f7;
  }
  
  #flipbook {
    width: 340px !important;
    height: 482px !important;
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    border-radius: 3px;
  }
  
  .page {
    width: 340px !important;
    height: 482px !important;
  }
  
  .turn-page {
    width: 340px !important;
    height: 482px !important;
  }
  
  .page-number {
    bottom: 6px;
    font-size: 8px;
    letter-spacing: 0.8px;
    padding: 2px 0;
  }
}

/* ========== MOBILE SMALL (320px - 374px) - Scale: 0.667 ========== */
@media (min-width: 320px) and (max-width: 374px) {
  body {
    background-color: #f5f5f7;
  }
  
  .book-wrapper {
    padding: 10px 8px;
    min-height: 100vh;
    background-color: #f5f5f7;
  }
  
  #flipbook {
    width: 300px !important;
    height: 425px !important;
    box-shadow: 0 5px 12px rgba(0,0,0,0.08);
    border-radius: 2px;
  }
  
  .page {
    width: 300px !important;
    height: 425px !important;
  }
  
  .turn-page {
    width: 300px !important;
    height: 425px !important;
  }
  
  .page-number {
    bottom: 5px;
    font-size: 7px;
    letter-spacing: 0.6px;
    padding: 2px 0;
  }
}

/* ========== VERY SMALL DEVICES (below 320px) - Scale: 0.583 ========== */
@media (max-width: 319px) {
  body {
    background-color: #f5f5f7;
  }
  
  .book-wrapper {
    padding: 8px 5px;
    min-height: 100vh;
    background-color: #f5f5f7;
  }
  
  #flipbook {
    width: 280px !important;
    height: 397px !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    border-radius: 2px;
  }
  
  .page {
    width: 280px !important;
    height: 397px !important;
  }
  
  .turn-page {
    width: 280px !important;
    height: 397px !important;
  }
  
  .page-number {
    bottom: 4px;
    font-size: 6px;
    letter-spacing: 0.5px;
    padding: 1px 0;
  }
}

/* ========== LANDSCAPE ORIENTATION FOR MOBILE ========== */
@media (max-height: 500px) and (orientation: landscape) {
  .book-wrapper {
    padding: 10px 20px;
    min-height: 100vh;
  }
  
  #flipbook {
    width: auto !important;
    height: 85vh !important;
    max-height: 500px !important;
    aspect-ratio: 480 / 680 !important;
  }
  
  .page {
    width: auto !important;
    height: 85vh !important;
    max-height: 500px !important;
    aspect-ratio: 480 / 680 !important;
  }
  
  .turn-page {
    width: auto !important;
    height: 85vh !important;
    max-height: 500px !important;
    aspect-ratio: 480 / 680 !important;
  }
  
  .page-number {
    bottom: 5px;
    font-size: 8px;
  }
}

/* ========== HIGH DPI / RETINA DISPLAYS ========== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #flipbook {
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  }
  
  .page-number {
    font-weight: 400;
  }
}

/* ========== DARK MODE SUPPORT ========== */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
  }
  
  .book-wrapper {
    background-color: #1a1a1a;
  }
  
  #flipbook {
    background: #ffffff;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
  }
  
  .page {
    background: #ffffff;
  }
  
  .page-number {
    color: #a0a0a0;
  }
  
  .page-number.current {
    color: #FF8A5B;
  }
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {
  #flipbook {
    cursor: default;
  }
  
  .page-number {
    bottom: 12px;
    font-size: 10px;
  }
}

/* ========== PRINT STYLES ========== */
@media print {
  body {
    background: none;
    padding: 0;
  }
  
  .book-wrapper {
    padding: 0;
    background: none;
  }
  
  #flipbook {
    box-shadow: none;
    border-radius: 0;
  }
  
  .page-number {
    display: none;
  }
}

/* ========== LOADING ANIMATION ========== */
#flipbook {
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========== SAFARI SPECIFIC FIXES ========== */
@supports (-webkit-touch-callout: none) {
  .page {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  #flipbook {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
}

/* ========== FIREFOX SPECIFIC FIXES ========== */
@-moz-document url-prefix() {
  .page {
    scrollbar-width: none;
  }
}