/* ==========================================================================
   3D FLIPBOOK VIEWER - CSS STYLES (BULLETPROOF CENTERING & NO CUTOFF)
   Program Studi D4 Teknologi Rekayasa Konstruksi Perkapalan - SV UNDIP
   ========================================================================== */

/* --------------------------------------------------------------------------
   StPageFlip Core CSS Rules (Essential for 3D Engine!)
   -------------------------------------------------------------------------- */
.stf__parent {
  position: relative !important;
  display: block !important;
  box-sizing: border-box !important;
  transform: translateZ(0) !important;
  margin: 0 auto !important;
  -ms-touch-action: pan-y;
  touch-action: pan-y;
}

.sft__wrapper,
.stf__wrapper {
  position: relative !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
}

.stf__parent canvas {
  position: absolute !important;
  width: 100% !important;
  height: 100% !important;
  left: 0 !important;
  top: 0 !important;
}

.stf__block {
  position: absolute !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
  perspective: 2000px !important;
}

.stf__item {
  display: none;
  position: absolute;
  transform-style: preserve-3d;
  background-color: #ffffff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
}

.stf__item.--left {
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

.stf__item.--right {
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
}

.stf__outerShadow,
.stf__innerShadow,
.stf__hardShadow,
.stf__hardInnerShadow {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  pointer-events: none !important;
}

/* Page DOM styling inside PageFlip (Dimensions managed by PageFlip engine!) */
.page {
  background-color: #ffffff;
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
  width: 100%;
  height: 100%;
}

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

.page-content img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Center spine 3D depth shadow (Realistic glossy magazine binding) */
.page::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  z-index: 10;
}

.page.--left::after,
.stf__item.--left::after {
  right: 0;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.06) 60%, transparent 100%);
}

.page.--right::after,
.stf__item.--right::after {
  left: 0;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.06) 60%, transparent 100%);
}

/* --------------------------------------------------------------------------
   Modal Structure & Viewport (Guarantees Header NEVER Cuts Magazine!)
   -------------------------------------------------------------------------- */
.flipbook-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background-color: rgba(9, 14, 23, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none;
  flex-direction: column;
  justify-content: space-between;
  user-select: none;
  overflow: hidden;
}

.flipbook-modal.active {
  display: flex !important;
}

body.flipbook-standalone-body {
  background-color: #0b111a;
  color: #fff;
  height: 100vh;
  overflow: hidden;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.flipbook-standalone-body .flipbook-modal {
  position: relative;
  display: flex !important;
  height: 100vh;
  background: transparent;
}

/* Top Control Bar */
.flipbook-topbar {
  height: 56px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(16, 24, 38, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.flipbook-btn-back,
.flipbook-btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: all 0.2s ease;
}

.flipbook-btn-back:hover,
.flipbook-btn-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.flipbook-btn-back svg,
.flipbook-btn-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

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

.topbar-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #38bdf8;
  text-transform: uppercase;
}

.topbar-magazine-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.05);
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.page-indicator-text {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0284c7;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.topbar-download-btn:hover {
  background: #0369a1;
}

.topbar-download-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* --------------------------------------------------------------------------
   FLIPBOOK MAIN VIEWPORT - Perfectly Centered & Spaced!
   -------------------------------------------------------------------------- */
.flipbook-viewport {
  position: relative;
  width: 100%;
  height: calc(100vh - 108px);
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
  box-sizing: border-box;
}

.flipbook-container-wrap {
  position: relative;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease-out;
  transform-origin: center center;
}

#flipbook-book {
  position: relative;
  margin: 0 auto;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  background-color: #1a2230;
}

/* Navigational Floating Chevrons on sides - Bening Kaca Elegant (Glassmorphism) */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 60px;
  background: rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.05) 100%);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  z-index: 30;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.5);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-arrow:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.14) 100%);
  border-color: rgba(255, 255, 255, 0.7);
  color: #ffffff;
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.7), 0 0 22px rgba(56, 189, 248, 0.35);
}

.nav-arrow:active {
  transform: translateY(-50%) scale(0.96);
}

.nav-arrow:disabled,
.nav-arrow.disabled {
  opacity: 0.18;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(1);
}

.nav-arrow-left {
  left: 20px;
}

.nav-arrow-right {
  right: 20px;
}

.nav-arrow svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* --------------------------------------------------------------------------
   BOTTOM TOOLBAR
   -------------------------------------------------------------------------- */
.flipbook-toolbar {
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  background: rgba(16, 24, 38, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 50;
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.toolbar-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.toolbar-btn.active {
  background: #0284c7;
  color: #ffffff;
}

.toolbar-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.page-jump-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 0.82rem;
  color: #94a3b8;
}

.page-jump-input {
  width: 40px;
  height: 28px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #ffffff;
  text-align: center;
  font-weight: 700;
  font-size: 0.84rem;
  outline: none;
}

.page-jump-input:focus {
  border-color: #38bdf8;
}

/* --------------------------------------------------------------------------
   DRAWER: TABLE OF CONTENTS (DAFTAR ISI)
   -------------------------------------------------------------------------- */
.flipbook-drawer {
  position: absolute;
  top: 14px;
  bottom: 14px;
  width: 320px;
  max-width: 85vw;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  z-index: 60;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  transform: translateX(-125%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.flipbook-drawer.left {
  left: 14px;
}

.flipbook-drawer.open {
  transform: translateX(0);
}

.drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-heading {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-heading svg {
  width: 18px;
  height: 18px;
  color: #38bdf8;
}

.drawer-close-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.drawer-close-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.drawer-content-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toc-item-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
  text-align: left;
  font-size: 0.82rem;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
}

.toc-item-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.toc-item-btn.active {
  background: rgba(2, 132, 199, 0.2);
  border-color: #0284c7;
  color: #38bdf8;
}

.toc-page-num {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  flex-shrink: 0;
  margin-left: 8px;
}

/* --------------------------------------------------------------------------
   DRAWER: THUMBNAILS CAROUSEL (BOTTOM OVERLAY TRAY)
   -------------------------------------------------------------------------- */
.thumbnails-tray {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: 12px;
  max-width: 900px;
  margin: 0 auto;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transform: translateY(130%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5);
}

.thumbnails-tray.open {
  transform: translateY(0);
}

.thumbnails-tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.thumbnails-tray-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
}

.thumbnails-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-behavior: smooth;
}

.thumbnails-scroll::-webkit-scrollbar {
  height: 5px;
}
.thumbnails-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.thumb-item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.thumb-item:hover {
  transform: translateY(-2px);
}

.thumb-img-wrapper {
  width: 64px;
  height: 90px;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: #000;
  transition: border-color 0.2s ease;
}

.thumb-item.active .thumb-img-wrapper {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.thumb-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-num {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 600;
}

.thumb-item.active .thumb-num {
  color: #38bdf8;
}

/* Loading Overlay */
.flipbook-loading-overlay {
  position: absolute;
  inset: 0;
  background: #0b111a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
}

.flipbook-spinner {
  width: 42px;
  height: 42px;
  border: 3.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: fb-spin 0.8s linear infinite;
}

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

.flipbook-loading-text {
  font-size: 0.88rem;
  color: #cbd5e1;
  font-weight: 600;
}

/* Mobile Adjustments */
@media (max-width: 767px) {
  .flipbook-topbar {
    padding: 0 12px;
    height: 52px;
    min-height: 52px;
  }

  .topbar-magazine-title {
    max-width: 130px;
    font-size: 0.82rem;
  }

  .topbar-center {
    display: none;
  }

  .topbar-download-btn span {
    display: none;
  }

  .topbar-download-btn {
    padding: 7px;
  }

  /* On mobile (< 768px), hide floating side arrows so they NEVER enter or cover flipbook pages */
  .nav-arrow {
    display: none !important;
  }

  .flipbook-toolbar {
    padding: 0 10px;
    gap: 6px;
    height: 48px;
    min-height: 48px;
  }

  .toolbar-btn {
    width: 32px;
    height: 32px;
  }

  .toolbar-btn svg {
    width: 16px;
    height: 16px;
  }

  .hide-on-mobile {
    display: none !important;
  }
}
