/* ========================================
   PDF Flipbook Viewer Styles
   ======================================== */

:root {
  --primary-color: #667eea;
  --primary-dark: #5a67d8;
  --secondary-color: #764ba2;
  --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --shadow-book: 0 0 50px rgba(102, 126, 234, 0.3);
  --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

/* ========================================
   Container
   ======================================== */
.viewer-container {
  position: relative;
  width: 100%;
  height: 100%;
}

/* ========================================
   Controls
   ======================================== */
.controls {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.nav-btn {
  width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition-base);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.nav-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.nav-btn:active:not(:disabled) {
  transform: translateY(0);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.btn-icon {
  width: 14px;
  height: 14px;
}

.page-indicator {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 70px;
  text-align: center;
}

.page-indicator .current {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 13px;
}

/* ========================================
   Flipbook Container
   ======================================== */
.flipbook-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Zoom Container - enables panning when zoomed */
.zoom-container {
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform 0.15s ease-out;
  cursor: default;
}

.zoom-container.dragging {
  cursor: grabbing;
  transition: none;
}

.zoom-container.zoom-active {
  cursor: grab;
}

.flipbook-container {
  position: relative;
  perspective: 2500px;
}

#flipbook {
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
  border-radius: 4px;
  margin-left: 0 !important
}

/* Turn.js page styling */
#flipbook .page {
  background: #fff;
  overflow: hidden;
}

#flipbook .page canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Page shadows for realism */
#flipbook .page.odd {
  background: linear-gradient(to right, #fafafa 0%, #ffffff 5%, #ffffff 100%);
  border-radius: 0 4px 4px 0;
}

#flipbook .page.even {
  background: linear-gradient(to left, #fafafa 0%, #ffffff 5%, #ffffff 100%);
  border-radius: 4px 0 0 4px;
}

/* Hard cover effect for first and last pages */
#flipbook .page:first-child {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

#flipbook .page:last-child {
  background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
}

/* Turn.js gradient overlays */
#flipbook .turn-page-wrapper {
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

/* ========================================
   Loading State
   ======================================== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-gradient);
  z-index: 100;
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--card-border);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: 20px;
  font-size: 16px;
  color: var(--text-secondary);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .controls {
    padding: 10px 20px;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 20px;
  }

  .nav-btn {
    padding: 10px 18px;
    font-size: 12px;
  }

  .nav-btn span {
    display: none;
  }

  .page-indicator {
    width: 100%;
    order: -1;
  }
}

/* ========================================
   Animations
   ======================================== */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   Zoom Controls
   ======================================== */
.zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-base);
}

.zoom-btn:hover {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-color: transparent;
  transform: scale(1.1);
}

.zoom-btn:active {
  transform: scale(0.95);
}

.zoom-btn .btn-icon {
  width: 18px;
  height: 18px;
}

.zoom-indicator {
  min-width: 50px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Zoom Hint Tooltip */
.zoom-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 99;
  white-space: nowrap;
}

.zoom-hint.visible {
  opacity: 1;
}

/* Zoom Info Tooltip (shown when zoomed to inform about disabled drag) */
.zoom-info {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: rgba(255, 152, 0, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 99;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
  cursor: pointer;
}

.zoom-info.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive zoom controls */
@media (max-width: 768px) {
  .zoom-controls {
    bottom: 15px;
    padding: 6px 12px;
    gap: 6px;
  }

  .zoom-btn {
    width: 32px;
    height: 32px;
  }

  .zoom-btn svg {
    width: 16px;
    height: 16px;
  }

  .zoom-indicator {
    min-width: 45px;
    font-size: 11px;
  }

  .zoom-hint {
    bottom: 70px;
    font-size: 10px;
  }
  
  .zoom-info {
    top: 60px;
    font-size: 10px;
    padding: 8px 16px;
  }
}
