/**
 * PDF Flipbook 3D CSS
 * TVDTheme BuildWEB
 */

.tvd-fb-flipbook-container {
  position: relative;
  width: 100%;
  max-width: var(--tvd-fb-max-w, 1100px);
  height: var(--tvd-fb-h, 600px);
  background: var(--tvd-fb-bg, #0f172a);
  margin: 30px auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: all 0.3s ease;
}

.tvd-fb-flipbook-container:fullscreen,
.tvd-fb-flipbook-container:-webkit-full-screen {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

.tvd-fb-flipbook-frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Embed Iframe */
.tvd-fb-flipbook-embed-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
}

.tvd-fb-flipbook-iframe {
  width: 100%;
  height: 100%;
  min-height: 100%;
  border: 0;
  display: block;
}

/* 3D Realistic Turn Stage */
.tvd-fb-flipbook-stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: calc(100% - 50px);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2400px;
  perspective-origin: 50% 50%;
  overflow: hidden;
  padding: 20px 30px;
  box-sizing: border-box;
}

.tvd-fb-loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 50;
  color: #38bdf8;
  font-size: 13px;
  font-weight: 600;
}

.tvd-fb-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: tvd-fb-spin 0.8s linear infinite;
}

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

.tvd-fb-flipbook-book {
  position: relative;
  width: 86%;
  height: 90%;
  max-width: 900px;
  max-height: 520px;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Realistic 3D Spine Shadow */
.tvd-fb-book-spine {
  position: absolute;
  top: 5%;
  bottom: 5%;
  left: 50%;
  width: 14px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(0,0,0,0.3) 0%, rgba(255,255,255,0.15) 30%, rgba(0,0,0,0.4) 70%, rgba(0,0,0,0.2) 100%);
  pointer-events: none;
  z-index: 25;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}

/* Page Geometry */
.tvd-fb-flipbook-book:not(.stf__parent) .tvd-fb-page {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: #ffffff;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
  box-shadow: inset 2px 0 12px rgba(0,0,0,0.1), 0 4px 20px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 10;
  left: 50%;
  border-radius: 0 4px 4px 0;
}

.tvd-fb-page {
  background: #ffffff;
  box-sizing: border-box;
}

.stf__item.tvd-fb-page {
  box-shadow: inset 2px 0 10px rgba(0,0,0,0.1);
  overflow: hidden;
}

.tvd-fb-page.is-flipped {
  transform: rotateY(-180deg);
  z-index: 15;
  border-radius: 4px 0 0 4px;
}

.tvd-fb-page-front,
.tvd-fb-page-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background-size: cover;
  background-position: center;
  background-color: #ffffff;
  box-sizing: border-box;
  padding: 30px 24px;
  overflow: hidden;
}

.tvd-fb-page--pdf .tvd-fb-page-front {
  padding: 0 !important;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tvd-fb-page--pdf canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: fill !important;
}

.tvd-fb-page-back {
  transform: rotateY(180deg);
  border-radius: 4px 0 0 4px;
  background-color: #fdfdfd;
}

/* Cover Styling */
.tvd-fb-page--cover-front .tvd-fb-page-front {
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.1);
  border-left: none;
}

.tvd-fb-cover-badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
  padding: 5px 12px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.tvd-fb-cover-title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #ffffff 40%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tvd-fb-cover-sub {
  font-size: 12px;
  letter-spacing: 1.5px;
  color: #94a3b8;
  margin-bottom: 25px;
}

.tvd-fb-cover-logo {
  font-size: 13px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 30px;
}

.tvd-fb-cover-footer {
  font-size: 11px;
  color: #64748b;
  position: absolute;
  bottom: 20px;
}

/* Mockup Content inside page */
.tvd-fb-inner-page {
  color: #1e293b;
}

.tvd-fb-page-num {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
}

.tvd-fb-page-mockup-body h4 {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 10px;
  margin-bottom: 12px;
}

.tvd-fb-page-mockup-body p {
  font-size: 13px;
  line-height: 1.6;
  color: #475569;
}

.tvd-fb-page-box {
  margin-top: 20px;
  padding: 14px;
  background: #f8fafc;
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.8;
  color: #334155;
}

.tvd-fb-grid-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 15px;
}

.tvd-fb-grid-mini .tvd-fb-item {
  padding: 12px;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  color: #1e293b;
}

.tvd-fb-grid-mini .tvd-fb-item strong {
  color: #0284c7;
  font-size: 13px;
}

.tvd-fb-page--back-end {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  color: #ffffff !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Shadow Depths */
.tvd-fb-depth-strong .tvd-fb-page {
  box-shadow: 0 15px 35px rgba(0,0,0,0.35), 0 3px 10px rgba(0,0,0,0.2);
}
.tvd-fb-depth-medium .tvd-fb-page {
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.tvd-fb-depth-subtle .tvd-fb-page {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Hardcover Thickness Effect */
.tvd-fb-cover-hardcover .tvd-fb-page--cover-front,
.tvd-fb-cover-hardcover .tvd-fb-page--cover-back {
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5), inset 0 0 10px rgba(0,0,0,0.3);
}

/* Modern Glassmorphism Toolbar */
.tvd-fb-flipbook-toolbar {
  height: 52px;
  width: 100%;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  box-sizing: border-box;
  z-index: 100;
}

.tvd-fb-toolbar-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.tvd-fb-toolbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 14px;
  max-width: 100%;
}

.tvd-fb-toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.tvd-fb-toolbar-title {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-align: center;
  margin: 0;
  line-height: 1.2;
}

.tvd-fb-page-counter {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  padding: 0 6px;
  min-width: 48px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  line-height: 1 !important;
}

.tvd-fb-current-page-display {
  color: #38bdf8;
  font-weight: 700;
}

.tvd-fb-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  width: 34px;
  height: 34px;
  min-height: 34px !important;
  max-height: 34px !important;
  min-width: 34px !important;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  font-size: 14px !important;
  box-sizing: border-box;
  outline: none;
  text-decoration: none;
}

.tvd-fb-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-1px);
}

.tvd-fb-btn:active {
  transform: translateY(1px);
}

.tvd-fb-btn.is-active {
  color: #38bdf8;
}

/* Zoom Controls 10% - 500% */
.tvd-fb-zoom-controls {
  display: inline-flex;
  align-items: center;
  height: 34px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0 3px;
  margin: 0 !important;
  gap: 2px;
}

.tvd-fb-zoom-controls .tvd-fb-btn {
  width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  min-width: 28px !important;
  background: transparent !important;
  border: none !important;
  border-radius: 6px !important;
  margin: 0 !important;
  padding: 0 !important;
}

.tvd-fb-zoom-controls .tvd-fb-btn:hover {
  background: rgba(56, 189, 248, 0.2) !important;
  color: #38bdf8 !important;
  transform: none !important;
}

.tvd-fb-zoom-value {
  color: #38bdf8;
  font-size: 12px;
  font-weight: 700;
  min-width: 42px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  padding: 0 4px;
  margin: 0 !important;
  line-height: 1;
  transition: color 0.2s ease;
}

.tvd-fb-zoom-value:hover {
  color: #ffffff;
  text-decoration: underline;
}

.tvd-fb-flipbook-stage.is-panning {
  cursor: grab;
}

.tvd-fb-flipbook-stage.is-panning:active {
  cursor: grabbing;
}

/* Responsive */
@media (max-width: 768px) {
  .tvd-fb-flipbook-container {
    height: var(--tvd-fb-h, 480px);
    margin: 15px auto;
  }
  .tvd-fb-flipbook-toolbar {
    grid-template-columns: auto 1fr;
    padding: 0 10px;
  }
  .tvd-fb-toolbar-center {
    display: none;
  }
  .tvd-fb-toolbar-right {
    justify-content: flex-end;
  }
  .tvd-fb-flipbook-book {
    width: 96%;
    height: 94%;
  }
  .tvd-fb-cover-title {
    font-size: 18px;
  }
}
