* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

.container {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.background-image {
  position: absolute;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.background-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.download-pdf {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 999;
}

.download-button {
  font-size: 16px;
  font-weight: bold;
  background-color: #ffb923;
  color: white;
  border: none;
  padding: 16px 36px;
  cursor: pointer;
  border-radius: 5px;
}

.download-button:hover {
  cursor: pointer;
  background-color: #303035;
}

.back {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 999;
}

.back-button {
  font-size: 16px;
  font-weight: bold;
  background-color: #ffb923;
  color: white;
  border: none;
  padding: 16px 36px;
  cursor: pointer;
  border-radius: 5px;
}

.back-button:hover {
  cursor: pointer;
  background-color: #303035;
}

.top-part {
  width: 100%;
  position: relative;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.top-part.single-page {
  justify-content: center;
}

.left-arrow-navigation {
  height: 15%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  background-color: #ffb923;
}

.left-arrow-navigation img {
  pointer-events: auto;
  cursor: pointer;
}

.book-area {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
}

.top-part.single-page .book-area {
  width: 100%;
  max-width: 640px;
}

.book-spine {
  position: absolute;
  top: 0px;
  left: 50%;
  width: 1px;
  height: 80%;
  transform: translateX(-50%);
  background: linear-gradient(to right,
      rgba(0, 0, 0, 0.1),
      rgba(0, 0, 0, 0.35),
      rgba(0, 0, 0, 0.1));
  box-shadow:
    -3px 0 8px rgba(0, 0, 0, 0.5),
    3px 0 8px rgba(0, 0, 0, 0.5);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.book-depth {
  position: absolute;
  top: 0px;
  left: 50%;
  width: 40px;
  height: 100%;
  transform: translateX(-50%);
  pointer-events: none;
  background: radial-gradient(ellipse at center,
      rgba(0, 0, 0, 0.35) 0%,
      rgba(0, 0, 0, 0.15) 35%,
      rgba(0, 0, 0, 0.05) 60%,
      rgba(0, 0, 0, 0) 75%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 99;
}

.stage {
  width: 100%;
  height: 100%;
  /* overflow: hidden; */
  object-fit: contain;
}

#flipbook.single {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  text-align: center;
}

#flipbook.single .page {
  margin: 0 auto !important;
}

.stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.right-arrow-navigation {
  height: 15%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  background-color: #ffb923;
}

.right-arrow-navigation img {
  pointer-events: auto;
  cursor: pointer;
}

.middle-part {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: 16px;
  padding-inline: 12px;
  position: absolute;
  left: 0px;
  bottom: 48px;
}

.bottom-part {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding-block: 12px;
  padding-inline: 36px;
  position: absolute;
  left: 0px;
  bottom: 0px;
  border-radius: 10px;
  background-color: #ffb923;
}

.slider {
  width: 75%;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
}

.slider-line {
  width: 100%;
  height: 6px;
  background-color: white;
  border-radius: 4px;
  cursor: pointer;
  pointer-events: auto;
}

.slider-progress-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background-color: whitesmoke;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
}

#flipbook .page img {
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
}

@media (max-width: 765px) {
  #flipbook .page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}

#flipbook .page {
  will-change: auto;
}

/* .turn-page-wrapper {
  perspective: 2000px;
} */

.zoom-button {
  color: white;
  cursor: pointer;
  transition: color 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
}

.zoom-button:hover {
  color: #000;
}

.zoom-button.hidden-button {
  display: none !important;
}

.close-zoom-button.visible {
  display: flex !important;
}

.pageflip-sound {
  cursor: pointer;
  transition: color 0.3s ease;
  color: whitesmoke;
  display: flex;
}

.pageflip-sound:hover {
  color: #000;
}

.pageflip-sound.hidden-button {
  display: none;
}

.pageflip-sound-off {
  cursor: pointer;
  transition: color 0.3s ease;
  color: whitesmoke;
  display: none;
}

.pageflip-sound-off:hover {
  color: #000;
}

.pageflip-sound-off.visible {
  display: flex;
}

.close-zoom-button {
  color: white;
  cursor: pointer;
  transition: color 0.3s ease;
  display: none !important;
  justify-content: center;
  align-items: center;
}

.close-zoom-button:hover {
  color: #000;
}

.close-zoom-button.hide {
  display: none;
}

.search-panel {
  position: fixed;
  top: 30px;
  left: -300px;
  width: 300px;
  height: calc(100% - 100px);
  background: #ffb923;
  z-index: 999;
  transition: left 0.3s ease;
  padding: 10px;
  pointer-events: auto;
}

.search-panel.open {
  left: 0;
}

.search-panel.open~.top-part .book-area {
  transform: translateX(150px);
}

.search-header {
  display: flex;
  gap: 6px;
  align-items: center;
}

.search-header input {
  flex: 1;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid #ccc;
  pointer-events: auto;
  cursor: text;
  outline: none;
  box-shadow: none;
  background: white;
  color: #000 !important;
  -webkit-text-fill-color: #000 !important;
  font-size: 14px !important;
  font-family: Arial, sans-serif;
  line-height: 1.5;
  letter-spacing: normal;
  -webkit-autofill: none;
}

.search-header input:focus {
  border-color: #c78b0b;
  box-shadow: 0 0 4px #000;
}

.search-header input::placeholder {
  color: #999 !important;
  -webkit-text-fill-color: #999 !important;
  opacity: 0.7;
}

.search-header input::-webkit-outer-spin-button,
.search-header input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.search-header button {
  padding: 6px 12px;
  background: #000;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.search-close {
  color: white;
  cursor: pointer;
  font-size: 18px;
}

.search-results {
  margin-top: 10px;
  max-height: 300px;
  overflow-y: auto;
  border-top: 1px solid #c78b0b;
  padding-top: 10px;
}

.search-result-item {
  padding: 8px 10px;
  margin: 4px 0;
  background: #ffb923;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 13px;
  color: white;
}

.search-result-item:hover {
  background: #c78b0b;
}

.search-no-results {
  padding: 8px 10px;
  text-align: center;
  color: #999;
  font-size: 13px;
}

.search-results::-webkit-scrollbar {
  width: 6px;
}

.search-results::-webkit-scrollbar-track {
  background: #c78b0b;
  border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb {
  background: #ffb923;
  border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: #fff;
}

.pages-range {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: white;
  font-size: 12px;
}

.search-button {
  color: white;
  cursor: pointer;
  transition: color 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
}

.search-button:hover {
  color: #303035;
}

.autoplay-button {
  color: whitesmoke;
  cursor: pointer;
  transition: color 0.3s ease;
  display: flex;
}

.autoplay-button:hover {
  color: #303035;
}

.autoplay-button.hidden-button {
  display: none;
}

.pause-button {
  color: whitesmoke;
  cursor: pointer;
  transition: color 0.3s ease;
  display: none;
}

.pause-button:hover {
  color: #303035;
}

.pause-button.visible {
  display: flex;
}

.thumbnail-bar {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  max-width: 90%;
  width: 90%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  opacity: 0;
  z-index: 999;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
  pointer-events: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.thumbnail-bar::-webkit-scrollbar {
  display: none;
}

.thumbnail-bar.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.thumbnail {
  height: 100%;
  width: 120px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border 0.2s;
  flex-shrink: 0;
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail.active {
  border-color: #c78b0b;
}

.thumbnail-button {
  color: whitesmoke;
}

.thumbnail-button:hover {
  color: #303035;
  cursor: pointer;
}

#left-arrow {
  opacity: 1;

  &:hover {
    cursor: pointer;
  }
}

#right-arrow {
  opacity: 1;

  &:hover {
    cursor: pointer;
  }
}

.extreme-left-arrow-navigation {
  background: #ffb923;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;

  &:hover {
    cursor: pointer;
  }
}

.extreme-right-arrow-navigation {
  background: #ffb923;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;

  &:hover {
    cursor: pointer;
  }
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #131316;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease-in-out;
  pointer-events: auto;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader {
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top: 5px solid #ffb923;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.loading-overlay p {
  color: #ffb923;
  font-size: 16px;
  margin-top: 10px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.toc-panel {
  position: fixed;
  top: 30px;
  right: -350px;
  width: 350px;
  height: calc(100% - 100px);
  background: #000;
  z-index: 998;
  transition: right 0.3s ease;
  padding: 10px;
  color: white;
  border-radius: 4px;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
}

.toc-panel.open {
  right: 0;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 2px solid #c78b0b;
  margin-bottom: 10px;
}

.toc-header h3 {
  margin: 0;
  font-size: 16px;
}

.toc-close {
  cursor: pointer;
  font-size: 20px;
  color: white;
}

.toc-close:hover {
  color: whitesmoke;
}

.toc-list {
  height: calc(100% - 60px);
  overflow-y: auto;
  padding-right: 8px;
}

.toc-item {
  padding: 8px 10px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toc-item:hover {
  background: #999;
}

.toc-page-num {
  display: block;
  font-size: 14px;
}

.toc-list::-webkit-scrollbar {
  width: 6px;
}

.toc-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.toc-list::-webkit-scrollbar-thumb {
  background: #c78b0b;
  border-radius: 3px;
}

.toc-list::-webkit-scrollbar-thumb:hover {
  background: #fff;
}

.table-of-content {
  color: white;
  cursor: pointer;
  transition: color 0.3s ease;
}

.table-of-content:hover {
  color: #c78b0b;
}

#flipbook {
  display: block;
  margin-bottom: 30px;
}

.page.blank {
  background: transparent;
}

/* Performance optimizations for responsive design */
.book-area {
  will-change: width, height;
  transition: width 0.3s ease, height 0.3s ease;
  contain: layout style paint;
}

.stage {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

#flipbook .page {
  will-change: auto;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Ensure book area properly responds to viewport changes */
@supports (width: 100dvw) {
  .container {
    height: 100dvh;
  }
}

/* Improve scroll performance */
.thumbnail-bar {
  will-change: auto;
}

.bottom-part {
  will-change: auto;
}

@media (max-width: 768px) {
  .book-area {
    will-change: width, height;
    transition: width 0.2s ease, height 0.2s ease;
  }
}

@media (max-width: 768px) {
  #flipbook {
    display: block;
  }

  .thumbnail-button,
  .zoom-button,
  .more-button {
    display: none !important;
  }

  .container {
    width: 100vw;
    height: 100dvh;
    padding-bottom: 90px;
    overflow: hidden;
  }

  .top-part {
    width: 100%;
    height: calc(100dvh - 130px);
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    /* top: 0; */
    top: 8px;
  }

  .download-pdf {
    position: absolute;
    top: 8px;
    right: 8px;
    margin-bottom: 12px;
  }

  .download-button {
    font-size: 12px;
    font-weight: bold;
    background-color: #ffb923;
    color: white;
    border: none;
    padding: 12px 18px;
    cursor: pointer;
    border-radius: 5px;
  }

  .download-button:hover {
    background-color: #303035;
  }

  .back {
    position: absolute;
    top: 8px;
    right: 8px;
    margin-bottom: 12px;
  }

  .back-button {
    font-size: 12px;
    font-weight: bold;
    background-color: #ffb923;
    color: white;
    border: none;
    padding: 12px 18px;
    cursor: pointer;
    border-radius: 5px;
  }

  .back-button:hover {
    background-color: #303035;
  }

  .left-arrow-navigation {
    display: none;
  }

  .right-arrow-navigation {
    display: none;
  }

  .book-area {
    width: 100%;
    max-width: 100%;
    /* aspect-ratio: auto; */
    transform: none;
    margin-top: 90px;
    padding-left: 10px;
    padding: 32px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  }

  .bottom-part {
    position: fixed;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
    bottom: max(4px, calc(4px + env(safe-area-inset-bottom)));
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    z-index: 100;
  }

  .slider {
    width: 100%;
    order: 10;
    margin-top: 4px;
  }

  .bottom-part>div {
    min-height: 32px;
    display: flex;
    align-items: center;
  }

  .thumbnail-bar {
    bottom: 130px;
    width: calc(100% - 20px);
  }

  .thumbnail {
    width: 70px;
    height: 80px;
  }

  .pages-range {
    font-size: 12px;
    flex-shrink: 0;
  }

  .search-panel {
    width: 100vw;
    height: 90dvh;
    left: -100vw;
    top: 0;
    z-index: 999;
  }

  .search-panel.open {
    left: 0;
  }

  .toc-panel {
    width: 100vw;
    height: 90dvh;
    right: -100vw;
    top: 0;
    z-index: 999;
  }

  .toc-panel.open {
    right: 0;
  }

  .middle-part {
    display: flex;
    position: fixed;
    bottom: calc(35px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    width: 100vw;
    height: auto;
    padding: 0;
    gap: 0;
    z-index: 50;
    justify-content: space-between;
    transform: none;
  }

  .extreme-left-arrow-navigation {
    position: relative;
    /* left: 8px; */
    top: -24px;
    background: #ffb923;
    border-radius: 10px;
    transform: none;
    width: auto;
    height: auto;
    z-index: 50;
  }

  .extreme-right-arrow-navigation {
    position: relative;
    /* right: 8px; */
    top: -24px;
    background: #ffb923;
    border-radius: 10px;
    transform: none;
    width: auto;
    height: auto;
    z-index: 50;
  }

  .extreme-left-arrow-navigation img,
  .extreme-right-arrow-navigation img {
    width: 44px;
    height: 44px;
    opacity: 1;
  }

  .more-button,
  .table-of-content,
  .slider {
    display: none !important;
  }

  .autoplay-button {
    display: flex;
  }

  .autoplay-button.hidden-button {
    display: none !important;
    flex: 0 !important;
  }

  .pageflip-sound {
    display: flex;
  }

  .pageflip-sound.hidden-button {
    display: none !important;
    flex: 0 !important;
  }

  .pause-button {
    display: none !important;
  }

  .pause-button.visible {
    display: flex !important;
    flex: 1;
    justify-content: center;
  }

  .pageflip-sound-off {
    display: none !important;
  }

  .pageflip-sound-off.visible {
    display: flex !important;
    flex: 1;
    justify-content: center;
  }

  .thumbnail-button,
  .zoom-button,
  .search-button,
  .pages-range,
  .menu-button {
    flex: 1;
    justify-content: center;
  }

  .autoplay-button {
    flex: 1;
    justify-content: center;
  }

  .autoplay-button.hidden-button {
    flex: 0;
  }

  .pause-button.visible {
    flex: 1;
    justify-content: center;
  }

  .pageflip-sound {
    flex: 1;
    justify-content: center;
  }

  .pageflip-sound.hidden-button {
    flex: 0;
  }

  .pageflip-sound-off.visible {
    flex: 1;
    justify-content: center;
  }

  .zoom-button {
    display: flex;
  }

  .zoom-button.hidden-button {
    display: none !important;
    flex: 0 !important;
  }

  .close-zoom-button {
    display: none;
  }

  .close-zoom-button.visible {
    display: flex !important;
    flex: 1;
    justify-content: center;
  }

  .menu-button {
    display: block;
    color: whitesmoke;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.3s ease;
  }

  .menu-button:hover {
    color: #303035;
  }

  .bottom-part svg {
    transform: translateZ(0);
    backface-visibility: hidden;
  }

  .bottom-part svg {
    width: 24px;
    height: 24px;
    min-width: 20px;
    min-height: 20px;
  }
}

@media (max-width: 425px) {
  .book-area {
    padding: 0px;
    padding-left: 10px;
  }
}

.mobile-menu {
  position: absolute;
  bottom: 50px;
  right: 12px;
  width: 180px;
  background: #ffb923;
  border-radius: 8px;
  padding: 8px 0;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 999;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.mobile-menu.open {
  display: flex;
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #ffb923;
  cursor: pointer;
  color: white;
  transition: background 0.2s ease;
  font-size: 13px;
  white-space: nowrap;
}

.mobile-menu-item:hover {
  background: #303035;
}

.mobile-menu-item i {
  font-size: 16px;
  min-width: 16px;
}

@media (min-width: 769px) {

  .zoom-button,
  .search-button,
  .thumbnail-button,
  .pages-range,
  .slider,
  .table-of-content,
  .more-button {
    display: flex !important;
  }

  .zoom-button.hidden-button {
    display: none !important;
  }

  .zoom-button.hidden-button {
    display: none !important;
  }

  .autoplay-button {
    display: flex;
  }

  .pageflip-sound {
    display: flex;
  }

  .pause-button {
    display: none;
  }

  .pageflip-sound-off {
    display: none;
  }

  .pause-button.visible {
    display: flex;
  }

  .pageflip-sound-off.visible {
    display: flex;
  }

  .autoplay-button.hidden-button {
    display: none;
  }

  .pageflip-sound.hidden-button {
    display: none;
  }

  .menu-button {
    display: none !important;
  }

  .mobile-menu {
    display: none !important;
  }
}