* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #ebedf0;
}

.heyzine-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #f6f8fa 0%, #ebeef2 55%, #dde1e7 100%);
}

.heyzine-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    130deg,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.45) 45%,
    rgba(255, 255, 255, 0.1) 55%,
    rgba(255, 255, 255, 0) 70%
  );
  pointer-events: none;
  z-index: 1;
}

/* Barra Superior de Controles */
.top-nav-bar {
  position: fixed;
  top: 16px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 100;
}

.top-icon-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heyzine-btn {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #1a1a1a;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.heyzine-btn:hover {
  background: #ffffff;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.heyzine-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Palco Central */
.heyzine-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 72px 42px 72px;
  z-index: 5;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.flipbook-center-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-container-shadow {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-viewport-target {
  position: relative;
  border-radius: 3px;
  background-color: transparent;
  box-shadow: none;
  min-width: 0 !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
}

.stf__parent,
.stf__wrapper,
.stf__block {
  background: transparent !important;
  background-color: transparent !important;
}

.book-container-shadow.is-open .book-viewport-target {
  box-shadow: 
    0 18px 45px -8px rgba(0, 0, 0, 0.32),
    0 6px 18px -3px rgba(0, 0, 0, 0.18);
}

/* Pilhas laterais de folhas (Stack effect) */
.page-stack {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 10px;
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.page-stack-right {
  right: -8px;
  background: repeating-linear-gradient(to right, #ffffff, #ffffff 1px, #e2e4e8 2px, #d1d5db 3px);
  box-shadow: 3px 2px 8px rgba(0, 0, 0, 0.22);
  border-radius: 0 3px 3px 0;
}

.page-stack-left {
  left: -8px;
  background: repeating-linear-gradient(to left, #ffffff, #ffffff 1px, #e2e4e8 2px, #d1d5db 3px);
  box-shadow: -3px 2px 8px rgba(0, 0, 0, 0.22);
  border-radius: 3px 0 0 3px;
}

.book-container-shadow.is-cover .page-stack-right { opacity: 1; }
.book-container-shadow.is-back-cover .page-stack-left { opacity: 1; }
.book-container-shadow.is-open .page-stack-right,
.book-container-shadow.is-open .page-stack-left { opacity: 0.6; width: 6px; }

/* Setas Curvas */
.nav-arrow {
  position: absolute;
  bottom: 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #1a1a1a;
  cursor: pointer;
  z-index: 50;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.nav-arrow:hover {
  background: #ffffff;
  transform: scale(1.15);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.nav-arrow:disabled {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

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

/* Logo Inferior Esquerdo */
.heyzine-footer-logo {
  position: fixed;
  bottom: 20px;
  left: 28px;
  z-index: 100;
  display: flex;
  align-items: center;
}

.abisa-logo {
  height: 44px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.15));
  transition: transform 0.2s ease;
}

.abisa-logo:hover {
  transform: scale(1.05);
}

/* Scrubber / Barra de Progresso */
.heyzine-bottom-scrubber {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 440px;
  max-width: 55vw;
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
  z-index: 100;
  padding: 4px 0;
}

.scrubber-track {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  transition: height 0.15s ease, background 0.15s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.heyzine-bottom-scrubber:hover .scrubber-track {
  height: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.scrubber-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #374151, #1f2937);
  border-radius: 6px;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.scrubber-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.heyzine-bottom-scrubber:hover .scrubber-tooltip {
  opacity: 1;
}

/* Páginas do Flipbook */
.flipbook-page {
  background-color: #ffffff;
  overflow: hidden;
  box-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.35), 0 4px 14px -2px rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.page-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.page-inner img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  transform: translateZ(0);
}

.page-spine-shadow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
  z-index: 10;
  mix-blend-mode: multiply;
}

.page-spine-shadow.spine-left {
  left: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.12) 35%, rgba(0,0,0,0) 100%);
}

.page-spine-shadow.spine-right {
  right: 0;
  background: linear-gradient(to left, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.12) 35%, rgba(0,0,0,0) 100%);
}

.stf__wrapper {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 769px) {
  .book-container-shadow.shift-center-cover:not(.is-portrait-mode) { transform: translateX(-25%); }
  .book-container-shadow.shift-center-back:not(.is-portrait-mode) { transform: translateX(25%); }
  .book-container-shadow.shift-center-spread { transform: translateX(0); }
}

.book-container-shadow.is-portrait-mode {
  transform: none !important;
}

@media (max-width: 768px) {
  .top-nav-bar { top: 10px; left: 12px; right: 12px; justify-content: flex-end; gap: 8px; }
  .heyzine-stage { padding: 56px 12px 64px 12px !important; box-sizing: border-box !important; }
  .heyzine-footer-logo { bottom: 10px; left: 12px; }
  .abisa-logo { height: 26px; }
  .heyzine-bottom-scrubber { bottom: 12px; width: 200px; max-width: 50vw; }
  .page-stack { display: none !important; }
  .book-container-shadow,
  .book-container-shadow.shift-center-cover,
  .book-container-shadow.shift-center-back,
  .book-container-shadow.shift-center-spread {
    transform: none !important;
  }
  .nav-arrow { 
    position: fixed;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    z-index: 60;
  }
  .nav-arrow:hover {
    background: #ffffff;
    transform: translateY(-50%) scale(1.1);
  }
  .nav-arrow-prev { left: 6px; }
  .nav-arrow-next { right: 6px; }
}

/* ==========================================================================
   HD Zoom & Pan Viewer (Visualização de Alta Definição)
   ========================================================================== */
.hd-zoom-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 18, 24, 0.96);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  animation: zoomFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.zoom-toolbar {
  height: 54px;
  background: rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 20;
}

.zoom-info {
  color: #f3f4f6;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.zoom-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.zoom-tool-btn {
  background: transparent;
  border: none;
  color: #e5e7eb;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.zoom-tool-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  transform: scale(1.1);
}

.zoom-level-badge {
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 48px;
  text-align: center;
}

.zoom-close-btn {
  background: rgba(239, 68, 68, 0.22);
  border: 1px solid rgba(239, 68, 68, 0.38);
  color: #fca5a5;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.zoom-close-btn:hover {
  background: rgba(239, 68, 68, 0.85);
  color: #ffffff;
  transform: scale(1.08);
}

.zoom-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}

.zoom-viewport.is-dragging {
  cursor: grabbing;
}

.zoom-canvas {
  position: absolute;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-spread-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  box-shadow: 0 30px 70px -15px rgba(0, 0, 0, 0.8);
  background: #ffffff;
  border-radius: 2px;
  overflow: hidden;
}

.zoom-page-img {
  max-height: 85vh;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  pointer-events: none;
}

.zoom-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(17, 24, 39, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  cursor: pointer;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  z-index: 30;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.zoom-nav-arrow:hover {
  background: rgba(17, 24, 39, 0.95);
  transform: translateY(-50%) scale(1.12);
}

.zoom-nav-arrow:disabled {
  opacity: 0.2;
  pointer-events: none;
}

.zoom-nav-prev { left: 24px; }
.zoom-nav-next { right: 24px; }
