/**
 * RALENA PUBLISHER — SECURE PDF PREVIEW READER STYLES
 * Mendukung Tema Cream, Light, Dark dan Responsi Penuh (Desktop & Mobile)
 */

/* ==========================================================================
   MODAL CONTAINER & BASE LAYOUT
   ========================================================================== */

.ebook-reader-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(15, 12, 10, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ebook-reader-modal.active {
  opacity: 1;
  visibility: visible;
}

.reader-container {
  width: 95vw;
  max-width: 1180px;
  height: 92vh;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.45);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   THEMES (WARM EDITORIAL)
   ========================================================================== */

.reader-container.theme-cream {
  background-color: #FFFAEE;
  color: #2B2118;
}

.reader-container.theme-light {
  background-color: #FFFFFF;
  color: #1F1E1D;
}

.reader-container.theme-dark {
  background-color: #161413;
  color: #ECE7DF;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.reader-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid rgba(185, 83, 56, 0.12);
  background-color: inherit;
  z-index: 10;
  flex-shrink: 0;
}

.theme-dark .reader-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.reader-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
}

.reader-btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  border: 1px solid rgba(185, 83, 56, 0.2);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reader-btn-icon:hover {
  background-color: #B95338;
  color: #FFFFFF;
  border-color: #B95338;
  transform: rotate(90deg);
}

.reader-title-box {
  display: flex;
  flex-direction: column;
}

.reader-book-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.reader-book-author {
  font-size: 0.8rem;
  opacity: 0.75;
}

/* Center Badge */
.reader-badge-wrap {
  display: flex;
  align-items: center;
}

.reader-format-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #B95338;
  background-color: rgba(185, 83, 56, 0.08);
  border: 1px solid rgba(185, 83, 56, 0.16);
  letter-spacing: 0.2px;
}

.theme-dark .reader-format-badge {
  color: #E28D75;
  background-color: rgba(226, 141, 117, 0.12);
  border-color: rgba(226, 141, 117, 0.24);
}

/* Right Tools */
.reader-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.reader-tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-picker {
  display: flex;
  gap: 6px;
}

.theme-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.theme-dot:hover {
  transform: scale(1.15);
}

.theme-dot.active {
  border-color: #B95338;
}

.dot-cream {
  background-color: #FFFAEE;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2) inset;
}

.dot-light {
  background-color: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2) inset;
}

.dot-dark {
  background-color: #1A1715;
}

/* ==========================================================================
   BODY & VIEWER STAGE
   ========================================================================== */

.reader-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

.reader-viewer-stage {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* PDF Desktop Viewer Frame (Continuous Scroll) */
.pdf-viewer-frame {
  width: 100%;
  height: 100%;
  border: none;
  background-color: transparent;
}

.theme-cream .pdf-viewer-frame {
  background-color: #F7EFE1;
}

.theme-light .pdf-viewer-frame {
  background-color: #F4F4F6;
}

.theme-dark .pdf-viewer-frame {
  background-color: #12100E;
}

/* PDF Mobile Viewer Canvas Container */
.pdf-viewer-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  box-sizing: border-box;
  overflow: hidden;
}

.theme-cream .pdf-viewer-container {
  background-color: #F8EFE3;
}

.theme-light .pdf-viewer-container {
  background-color: #EFEFEF;
}

.theme-dark .pdf-viewer-container {
  background-color: #12100F;
}

.pdf-single-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #FFFFFF;
  border-radius: 6px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: transform 0.2s ease;
  animation: fadeInPage 0.25s ease-out;
}

@keyframes fadeInPage {
  from {
    opacity: 0.7;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.pdf-single-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.pdf-single-page-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 3px 9px;
  background: rgba(30, 24, 20, 0.72);
  color: #FFF;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 12px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 5;
}

.theme-dark .pdf-single-page-badge {
  background: rgba(0, 0, 0, 0.78);
  color: #ECE7DF;
}

/* ==========================================================================
   NAVIGATION ARROWS
   ========================================================================== */

.reader-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 52px;
  border-radius: 8px;
  border: none;
  background-color: rgba(185, 83, 56, 0.12);
  color: #B95338;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.reader-nav-arrow:hover {
  background-color: #B95338;
  color: #FFFFFF;
  transform: translateY(-50%) scale(1.06);
}

.arrow-prev {
  left: 12px;
}

.arrow-next {
  right: 12px;
}

.theme-dark .reader-nav-arrow {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ECE7DF;
}

.theme-dark .reader-nav-arrow:hover {
  background-color: #B95338;
  color: #FFFFFF;
}

/* ==========================================================================
   WATERMARK (ANTI-LEAK PROTECTION)
   ========================================================================== */

.reader-watermark {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
  overflow: hidden;
  opacity: 0.055;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-dark .reader-watermark {
  opacity: 0.08;
}

.watermark-pattern {
  display: flex;
  flex-direction: column;
  gap: 100px;
  transform: rotate(-24deg);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: currentColor;
  white-space: nowrap;
}

/* ==========================================================================
   LOADING SPINNER
   ========================================================================== */

.reader-spinner-box {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background-color: inherit;
  z-index: 25;
}

.reader-spinner {
  width: 42px;
  height: 42px;
  border: 3.5px solid rgba(185, 83, 56, 0.2);
  border-top-color: #B95338;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.reader-loading-text {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.8;
}

/* ==========================================================================
   END OF PREVIEW CTA MODAL OVERLAY
   ========================================================================== */

.reader-end-banner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 14, 12, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  animation: fadeInBanner 0.3s ease-out;
}

@keyframes fadeInBanner {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.end-banner-card {
  max-width: 500px;
  background-color: #FFFAEE;
  color: #2B2118;
  border-radius: 20px;
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(185, 83, 56, 0.2);
}

.end-banner-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: rgba(185, 83, 56, 0.12);
  color: #B95338;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.end-banner-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}

.end-banner-desc {
  font-size: 0.92rem;
  line-height: 1.65;
  color: #635043;
  margin-bottom: 26px;
}

.end-banner-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-end-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: 30px;
  background-color: #B95338;
  color: #FFFFFF !important;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 18px rgba(185, 83, 56, 0.35);
}

.btn-end-buy:hover {
  background-color: #9C3F27;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(185, 83, 56, 0.45);
}

.btn-end-close {
  background: transparent;
  border: 1px solid rgba(185, 83, 56, 0.25);
  color: #7D6B5D;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-end-close:hover {
  background-color: rgba(185, 83, 56, 0.08);
  color: #2B2118;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.reader-footer {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-top: 1px solid rgba(185, 83, 56, 0.12);
  background-color: inherit;
  z-index: 10;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.theme-dark .reader-footer {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.reader-progress-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reader-badge-secure {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 10px;
  background-color: rgba(185, 83, 56, 0.12);
  color: #B95338;
}

.theme-dark .reader-badge-secure {
  background-color: rgba(226, 141, 117, 0.15);
  color: #E28D75;
}

.reader-progress-label {
  opacity: 0.85;
}

.reader-buy-mini-link {
  color: #B95338;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.reader-buy-mini-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ========================================================================== */

@media (max-width: 768px) {
  .reader-container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .reader-header {
    height: 56px;
    padding: 0 14px;
  }

  .reader-header-left {
    min-width: unset;
    gap: 8px;
  }

  .reader-book-title {
    max-width: 140px;
    font-size: 0.95rem;
  }

  .reader-book-author {
    display: none;
  }

  .reader-badge-wrap {
    display: none;
  }

  .reader-nav-arrow {
    width: 36px;
    height: 44px;
  }

  .arrow-prev { left: 6px; }
  .arrow-next { right: 6px; }

  .watermark-pattern {
    font-size: 0.9rem;
    gap: 60px;
  }

  .pdf-viewer-container {
    padding: 8px 4px;
  }

  .pdf-single-card {
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  }

  .pdf-single-page-badge {
    top: 6px;
    right: 8px;
    font-size: 0.65rem;
    padding: 2px 7px;
  }
}
