/* Specific styles for reader page */
body {
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  font-family: "Poppins", sans-serif;
  background-color: var(--bg-color, #f5f5f5);
}

.reader-header {
  background-color: var(--primary-color, #6483b1);
  padding: 0.7rem 0;
  color: white;
  box-shadow: 0 2px 5px var(--shadow-color, rgba(0, 0, 0, 0.2));
  z-index: 100;
}

.container {
  width: 100%;
  max-width: 1200px;
  padding: 0 1rem;
  margin: 0 auto;
}

.reader-container {
  display: flex;
  align-items: center;
}

.home-title {
  display: flex;
  align-items: center;
}

.logo {
  flex: 0.8;
}

.reader-title {
  font-family: "Cinzel", serif;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  flex: 1;
  padding: 0 10px;
}

.home-button {
  background-color: white;
  color: var(--primary-color, #6483b1);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: 0.2s ease;
}

.home-button:hover {
  background-color: rgba(255, 255, 255, 0.4);
  color: white;
}

.reader-content {
  flex: 1;
  overflow: auto;
  position: relative;
  background-color: var(--bg-color, #f5f5f5);
}

.fullscreen-button {
  position: fixed;
  top: 70px;
  right: 15px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  opacity: 0.7;
  transition: opacity 0.2s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.fullscreen-button:hover {
  opacity: 1;
}

.fullscreen-mode .fullscreen-button {
  display: none;
}

.fullscreen-mode .reader-header {
  display: none;
}

.fullscreen-mode .reader-content {
  height: 100vh;
}

/* Image container with drag functionality */
#pageContainer {
  width: 100%;
  height: 100%;
  overflow: hidden; /* Changed from auto to hidden */
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  cursor: grab;
  position: relative;
  background-color: #f5f5f5;
}

#pageContainer.grabbing {
  cursor: grabbing !important;
}

/* Image styling */
#currentPageImage {
  box-shadow: 0 2px 10px var(--shadow-color, rgba(0, 0, 0, 0.3));
  background-color: white;
  max-height: calc(
    100vh - 160px
  ); /* Fit to viewport height minus header and controls */
  width: auto;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  transform: translate(0px, 0px) scale(1); /* Initial transform */
}

.fullscreen-mode #currentPageImage {
  max-height: calc(100vh - 100px); /* More space in fullscreen mode */
}

.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 20px;
  border-radius: var(--border-radius-md, 10px);
  box-shadow: 0 5px 15px var(--shadow-color, rgba(0, 0, 0, 0.2));
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary-color, #6483b1);
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Bottom Controls */
.bottom-controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 30px;
  padding: 5px 15px;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.bottom-controls button {
  background-color: transparent;
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin: 0;
}

.bottom-controls button:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.bottom-controls button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bottom-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bottom-controls .page-nav {
  display: flex;
  align-items: center;
  color: white;
  padding: 0 5px;
}

.bottom-controls input {
  width: 35px;
  text-align: center;
  padding: 3px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  margin: 0 5px;
}

.bottom-controls input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.3);
}

.bottom-controls span {
  font-weight: 500;
  font-size: 0.9rem;
}

/* Exit fullscreen button */
.exit-fullscreen {
  position: fixed;
  top: 15px;
  right: 15px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  opacity: 0.7;
  transition: opacity 0.2s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.exit-fullscreen:hover {
  opacity: 1;
}

.fullscreen-mode .exit-fullscreen {
  display: flex;
}

.fullscreen-mode .bottom-controls {
  background-color: rgba(0, 0, 0, 0.7);
}

/* Hide bottom controls when not hovering over page on desktop */
@media (min-width: 769px) {
  .bottom-controls {
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .reader-content:hover ~ .bottom-controls,
  .bottom-controls:hover {
    opacity: 1;
  }
}

/* Responsive styles */
@media screen and (max-width: 768px) {
  .reader-title {
    font-size: 0.9rem;
    max-width: 350px;
    text-align: left;
  }

  .home-button {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }

  .bottom-controls {
    bottom: 15px;
    padding: 4px 12px;
  }

  .bottom-controls button {
    width: 32px;
    height: 32px;
  }
}

@media screen and (min-width: 601px) {
  .reader-container {
    flex-direction: row !important;
  }
}

@media screen and (max-width: 600px) {
  .reader-container {
    flex-direction: column;
  }
  .logo .logo-text {
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
    margin-bottom: 8px;
  }
  .logo-text .logo-part1,
  .logo-text .logo-part2 {
    font-size: 1.25rem;
    font-weight: 500;
    text-transform: none;
    color: #ffffff;
  }
}

@media screen and (max-width: 480px) {
  #currentPageImage {
    width: 100%;
    height: auto;
  }
  .reader-title {
    font-size: 0.9rem;
    text-align: center;
  }

  .home-button {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .bottom-controls {
    bottom: 10px;
    padding: 3px 10px;
    gap: 5px;
  }

  .bottom-controls button {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
  }

  .bottom-controls .page-nav {
    padding: 0 3px;
  }

  .bottom-controls input {
    width: 30px;
    padding: 2px;
    font-size: 0.8rem;
  }

  .bottom-controls span {
    font-size: 0.8rem;
  }

  .fullscreen-button,
  .exit-fullscreen {
    width: 35px;
    height: 35px;
    top: 70px;
    right: 10px;
  }
}

@media screen and (max-width: 360px) {
  .reader-title {
    font-size: 0.8rem;
  }

  .home-button {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
  }

  .bottom-controls {
    padding: 2px 8px;
    gap: 3px;
  }

  .bottom-controls button {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .bottom-controls input {
    width: 25px;
    margin: 0 2px;
  }
}

#currentPage::-webkit-inner-spin-button,
#currentPage::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
