/* Base styles */
body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
}

/* Index page styles */
body:not(.flipbook-page) {
    background: #f5f5f5;
}

/* Flipbook page styles */
body.flipbook-page {
    background: #333;
}

/* Book selector styles */
.book-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    padding: 40px 20px;
    min-height: 100vh;
    align-items: flex-start;
    padding-top: 80px;
}

.book-item {
    width: 200px;
    cursor: pointer;
    transition: transform 0.3s ease;
    text-align: center;
}

.book-item:hover {
    transform: translateY(-10px);
}

.book-cover {
    width: 200px;
    height: 260px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    margin-bottom: 15px;
    position: relative;
    background: #ddd;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
}

.book-format {
    font-size: 12px;
    color: #666;
}

/* Reader container base styles */
#reader-container {
    width: 80%;
    max-width: 1200px;
    height: auto;
    background: transparent;
    z-index: 2;
}

/* Index page reader (hidden by default) */
body:not(.flipbook-page) #reader-container {
    display: none;
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    margin: auto;
    z-index: 1000;
}

/* Flipbook page reader */
body.flipbook-page #reader-container {
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    margin: auto;
}

/* Reader container variants */
#reader-container.vertical {
    height: 85%;
    min-height: 500px;
    width: 60%;
    max-width: 800px;
}

#reader-container.square {
    aspect-ratio: 2 / 1;
}

#reader-container.square .main-loader .cover-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    width: 300px;
    height: 300px;
    transition: inherit;
}

#reader-container .main-loader.hidden {
    transition-delay: 1s;
    opacity: 0;
    pointer-events: none;
}

#reader-container .main-loader.hidden .cover-loader {
    transform: translate(0, 100%);
    opacity: 0;
}

/* Overlay styles (for index page modal - legacy support) */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 999;
}

/* Button styles */
.back-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 1001;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
}

.back-btn:hover {
    background: #0056b3;
}

.close-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    background: #333;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 1001;
    font-size: 14px;
    display: none;
}

.close-btn:hover {
    background: #555;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  #reader-container {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed;
    top: 0;
    left: 0;
  }
  
#reader-container .controls .left,
  #reader-container .controls .right {
    top: 15%; /* Instead of default 25% */
    bottom: 35%; /* Adjust accordingly */
  }

  #reader-container .content .pages .page {
    max-width: 95vw;
    max-height: 90vh;
  }
  
  /* Force small controls on mobile */
  #reader-container .controls {
    font-size: 0.8em;
  }
  
  #reader-container .overviews {
    width: 80vw;
  }
  
  #reader-container .overviews .thumb {
    margin: 4px;
  }
#reader-container .controls .bottom {
    bottom: 80px; /* Instead of default 0 */
  }
  
  /* Ensure top controls are more accessible */
  #reader-container .controls .top {
    top: 80px; /* Add some padding from very top */
  }
  
  /* Make corner controls more accessible */
  #reader-container .controls .bottomleft,
  #reader-container .controls .bottomright {
    bottom: 80px; /* Lift them up from bottom edge */
  }
  
  #reader-container .controls .topleft,
  #reader-container .controls .topright {
    top: 60px; /* Lower them from top edge */
  }

}

@media (max-width: 480px) {
  #reader-container .controls .btn {
    margin: 4px;
    width: 36px;
    height: 36px;
  }
  
  #reader-container .controls .icon {
    font-size: 18px;
    line-height: 36px;
  }
 #reader-container .controls .bottom {
    bottom: 90px;
  }
  
  #reader-container .controls .left,
  #reader-container .controls .right {
    top: 20%;
    bottom: 45%;
  }
}