/* ==========================================================================
   REALISTIC 3D FLIPBOOK / BOOK READER POPUP MODAL STYLES (CLEAN & PERFECT)
   ========================================================================== */

.real-book-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999999 !important;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.96) 0%, rgba(2, 6, 23, 0.99) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.25s ease;
  user-select: none;
  box-sizing: border-box;
}

.real-book-modal-overlay.active {
  display: flex !important;
  opacity: 1;
}

/* --- Top Header Bar --- */
.real-book-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 100;
  flex-shrink: 0;
  gap: 12px;
}

.real-book-title-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f8fafc;
  min-width: 0;
}

.real-book-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  flex-shrink: 0;
}

.real-book-text-meta h6 {
  margin: 0;
  font-weight: 700;
  font-size: 15px;
  color: #f1f5f9;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.real-book-text-meta small {
  color: #94a3b8;
  font-size: 12px;
  display: block;
}

/* --- Toolbar Controls --- */
.real-book-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.real-book-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 13px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.2;
}

.real-book-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.real-book-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.real-book-btn.active {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.real-book-btn-close {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 15px;
  padding: 6px 12px;
}

.real-book-btn-close:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* Page Counter Box */
.real-book-page-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 600;
}

.real-book-page-input {
  width: 44px;
  text-align: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 12px;
  font-weight: 700;
  outline: none;
}

/* --- Main Viewing Stage --- */
.real-book-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: auto;
  padding: 20px 40px;
  background: radial-gradient(ellipse at center, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.85) 100%);
}

/* --- 3D Physical Book Binder Shell --- */
.real-book-binder {
  position: relative;
  display: flex;
  background: linear-gradient(135deg, #24140e 0%, #120905 50%, #24140e 100%);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 
    0 25px 50px -10px rgba(0, 0, 0, 0.85),
    0 0 0 2px #442215,
    inset 0 0 15px rgba(0, 0, 0, 0.9);
  border: 3px solid #361a0f;
  transition: all 0.3s ease;
  max-width: 96vw;
  max-height: 85vh;
  box-sizing: border-box;
}

/* Layered Edge Thickness */
.real-book-binder::before {
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 4px;
  width: 8px;
  background: repeating-linear-gradient(to bottom, #dcd5ca 0px, #dcd5ca 2px, #b0a495 2px, #b0a495 4px);
  border-radius: 3px 0 0 3px;
  box-shadow: inset -2px 0 4px rgba(0,0,0,0.5);
}

.real-book-binder::after {
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  right: 4px;
  width: 8px;
  background: repeating-linear-gradient(to bottom, #dcd5ca 0px, #dcd5ca 2px, #b0a495 2px, #b0a495 4px);
  border-radius: 0 3px 3px 0;
  box-shadow: inset 2px 0 4px rgba(0,0,0,0.5);
}

/* --- The Open Spread Container --- */
.real-book-spread {
  display: flex;
  background: #ffffff;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  position: relative;
  align-items: stretch;
}

/* --- Left & Right Page Leaves --- */
.real-book-page {
  position: relative;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  overflow: hidden;
  box-sizing: border-box;
  padding: 8px;
}

/* 2-Page mode sizes */
.real-book-spread.spread-two-page .real-book-page {
  width: 440px;
  max-width: 42vw;
  height: 610px;
  max-height: 75vh;
}

/* Single-page mode size */
.real-book-spread.spread-single-page .real-book-page {
  width: 540px;
  max-width: 80vw;
  height: 650px;
  max-height: 77vh;
}

/* Left & Right Page inner seam borders */
.real-book-page-left {
  border-right: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset -15px 0 20px -8px rgba(0, 0, 0, 0.08);
}

.real-book-page-right {
  border-left: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 15px 0 20px -8px rgba(0, 0, 0, 0.08);
}

.real-book-spread.spread-single-page .real-book-page-right {
  border-left: none;
  box-shadow: none;
}

/* Spine Crease - Only between 2 pages */
.real-book-spine-crease {
  width: 2px;
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  z-index: 5;
  flex-shrink: 0;
}

/* Canvas Wrapper */
.real-book-canvas-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow: hidden;
}

.real-book-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #ffffff;
}

/* Page Footer Numbering */
.real-book-page-footer {
  position: absolute;
  bottom: 6px;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 8px;
  border-radius: 4px;
}
.real-book-page-left .real-book-page-footer { left: 14px; }
.real-book-page-right .real-book-page-footer { right: 14px; }

/* Decorative Cover Plate (When page is inside cover) */
.real-book-cover-plate {
  width: 85%;
  height: 85%;
  border: 2px dashed rgba(180, 83, 9, 0.3);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  background: rgba(254, 243, 199, 0.25);
  color: #78350f;
}

/* Floating Navigation Arrows */
.real-book-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
}

.real-book-nav-prev { left: 16px; }
.real-book-nav-next { right: 16px; }

.real-book-nav-arrow:hover:not(:disabled) {
  background: #10b981;
  border-color: #10b981;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
}

.real-book-nav-arrow:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  transform: translateY(-50%);
}

/* Fullscreen PDF Iframe Container */
.real-book-iframe-view {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
  display: none;
}

/* Loading Spinner */
.real-book-loader {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  color: #ffffff;
  gap: 16px;
  border-radius: 12px;
}

.real-book-spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(16, 185, 129, 0.2);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: realBookSpin 0.85s linear infinite;
}

@keyframes realBookSpin {
  to { transform: rotate(360deg); }
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 900px) {
  .real-book-spread.spread-two-page .real-book-page {
    width: 350px;
    height: 480px;
  }
}

@media (max-width: 767px) {
  .real-book-page-left { display: none !important; }
  .real-book-spine-crease { display: none !important; }
  .real-book-spread.spread-two-page .real-book-page-right,
  .real-book-spread.spread-single-page .real-book-page-right {
    width: 86vw !important;
    max-width: 100% !important;
    height: 68vh !important;
    border-left: none !important;
    box-shadow: none !important;
  }
  .real-book-binder { padding: 6px; }
  .real-book-nav-arrow {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
  .real-book-nav-prev { left: 6px; }
  .real-book-nav-next { right: 6px; }
  .real-book-controls .hide-on-mobile { display: none !important; }
}
