/* ===== LEITOR PDF - Dark Theme Reader ===== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: 'Lato', sans-serif;
  color: #e0e0e0;
  -webkit-user-select: none;
  user-select: none;
}

/* ===== Top Toolbar ===== */
.readerToolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: rgba(16, 16, 32, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 1000;
  border-bottom: 1px solid rgba(197, 165, 114, 0.2);
  transition: transform 0.3s ease;
}

.readerToolbar.hidden {
  transform: translateY(-100%);
}

.toolbarLeft,
.toolbarRight {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbarCenter {
  flex: 1;
  text-align: center;
}

.toolbarTitle {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  color: #C5A572;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbarBtn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(197, 165, 114, 0.15);
  border-radius: 8px;
  color: #C5A572;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-size: 0.85rem;
}

.toolbarBtn:hover {
  background: rgba(197, 165, 114, 0.2);
  color: #fff;
}

.pageIndicator {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
}

.zoomLevel {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  min-width: 40px;
  text-align: center;
}

/* ===== Search Panel ===== */
.searchPanel {
  position: fixed;
  top: 52px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(16, 16, 32, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(197, 165, 114, 0.25);
  border-left: 1px solid rgba(197, 165, 114, 0.15);
  border-radius: 0 0 0 12px;
  z-index: 1001;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.searchPanel.active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.searchInputWrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(197, 165, 114, 0.2);
  border-radius: 8px;
  padding: 0 0.6rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 220px;
}

.searchInputWrapper:focus-within {
  border-color: rgba(197, 165, 114, 0.6);
  box-shadow: 0 0 0 2px rgba(197, 165, 114, 0.1);
}

.searchIcon {
  color: rgba(197, 165, 114, 0.5);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.searchInput {
  background: none;
  border: none;
  outline: none;
  color: #e0e0e0;
  font-family: 'Lato', sans-serif;
  font-size: 0.85rem;
  padding: 0.45rem 0.5rem;
  width: 100%;
  min-width: 0;
}

.searchInput::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.searchCounter {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: fit-content;
  padding-right: 0.2rem;
}

.searchCounter.has-results {
  color: #C5A572;
}

.searchCounter.no-results {
  color: #e05555;
}

.searchActions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.searchBtn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(197, 165, 114, 0.12);
  border-radius: 6px;
  color: #C5A572;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.75rem;
}

.searchBtn:hover:not(:disabled) {
  background: rgba(197, 165, 114, 0.2);
  color: #fff;
}

.searchBtn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ===== Reader Container ===== */
.readerContainer {
  position: fixed;
  top: 52px;
  bottom: 44px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #1a1a2e;
}

/* ===== Loading ===== */
.readerLoading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: #C5A572;
}

.loadingSpinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(197, 165, 114, 0.2);
  border-top-color: #C5A572;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loadingProgress {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}

/* ===== Flipbook (StPageFlip) ===== */
.flipbookWrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  transition: transform 0.5s ease;
}

.flipbookWrapper.cover-mode {
  transform: translateX(calc(var(--page-width, 0) * -0.5));
}

.flipbook .page {
  background: #fff;
  overflow: hidden;
}

.flipbook .page canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.flipbook .page-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  color: #bbb;
  font-size: 14px;
}

/* ===== Single Page Mode ===== */
.singlePageWrapper {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  height: 100%;
  padding: 10px;
  overflow: auto;
}

#singlePageCanvas {
  display: block;
  flex-shrink: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  border-radius: 2px;
}

#highlightCanvas {
  position: absolute;
  pointer-events: none;
}

/* ===== Navigation Arrows ===== */
.navArrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 80px;
  background: rgba(16, 16, 32, 0.6);
  border: 1px solid rgba(197, 165, 114, 0.15);
  color: #C5A572;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 500;
  transition: all 0.2s ease;
  font-size: 1.2rem;
  border-radius: 8px;
  opacity: 0.6;
}

.navArrow:hover {
  background: rgba(197, 165, 114, 0.2);
  opacity: 1;
}

.navArrowLeft {
  left: 12px;
}

.navArrowRight {
  right: 12px;
}

/* ===== Bottom Bar ===== */
.readerBottomBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: rgba(16, 16, 32, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  z-index: 1000;
  border-top: 1px solid rgba(197, 165, 114, 0.2);
  transition: transform 0.3s ease;
}

.readerBottomBar.hidden {
  transform: translateY(100%);
}

.pageSlider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.pageSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #C5A572;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.pageSlider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #C5A572;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.pageNumbers {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  min-width: 70px;
  text-align: right;
  white-space: nowrap;
}

/* ===== Fullscreen adjustments ===== */
:fullscreen .readerContainer,
:-webkit-full-screen .readerContainer {
  top: 52px;
  bottom: 44px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .toolbarTitle {
    display: none;
  }

  .zoomLevel {
    display: none;
  }

  .navArrow {
    width: 36px;
    height: 60px;
    font-size: 1rem;
  }

  .navArrowLeft {
    left: 4px;
  }

  .navArrowRight {
    right: 4px;
  }

  .readerToolbar {
    padding: 0 0.5rem;
  }

  .toolbarBtn {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .readerBottomBar {
    padding: 0 1rem;
  }

  .searchPanel {
    left: 0;
    border-radius: 0;
    border-left: none;
  }

  .searchInputWrapper {
    min-width: 0;
    flex: 1;
  }
}

@media (max-width: 480px) {
  .navArrow {
    display: none;
  }

  #btnZoomIn,
  #btnZoomOut {
    display: none;
  }

  #btnViewMode {
    display: none;
  }
}
