/* PDF viewer styles */
#frame canvas {
    display: block;
    margin-left: auto;
    margin-right: auto;
    /* background: hsla(201, 100%, 10%, 1); */
}

#pdf-viewer {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#pdf-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

#pdf-canvas-container {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: hsla(248, 9%, 45%, 0.65);
}

#pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

:root {
  --pdf-page-margin-bottom: 12px;
}
.pdf-page {
    margin-bottom: var(--pdf-page-margin-bottom);
    display: block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#pdf-sidebar {
    width: 0;
    padding: 0;
    box-sizing: border-box;
    overflow-y: auto;
    background: hsla(201, 100%, 10%, 1);
    transition: width 0.3s ease-out, padding 0.3s ease-out;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#pdf-sidebar.open {
    width: 225px;
    padding: 10px 5px;
}

.pdf-thumb {
    width: 60%;
    border: 8px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}
.pdf-thumb.active {
    border-color: hsla(228,48%,60%,1);
}

#pdf-controls {
  font-size: 0.65rem;
  order: -1;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: hsla(201, 100%, 10%, 0.85);
  border-bottom: 1px solid hsla(0,0%,100%,0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Left section - Sidebar toggle */
.pdf-controls-left {
  display: flex;
  align-items: center;
}

/* Center section - Navigation and zoom controls */
.pdf-controls-center {
  display: flex;
  align-items: center;
  gap: 20px; /* Space between navigation and zoom groups */
position: absolute;
  left: 50%;
  transform: translateX(-50%);
  justify-content: center;
}

.pdf-nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-zoom-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-zoom-dropdown {
    position: relative;
    display: inline-block;
    min-width: 180px;
}

.dropdown-trigger {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
}

.dropdown-trigger:hover {
    background: #444;
}

.dropdown-icon {
    margin-left: 8px;
    font-size: 0.8em;
}

.dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: hsla(201, 100%, 10%, 1);
    border: 1px solid #555;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    list-style: none;
    padding: 0;
    margin: 4px 0 0 0;
    max-height: fit-content;
    overflow-y: auto;
    display: none;
    z-index: 1000;
}

.dropdown-options.show {
    display: block;
}

.dropdown-options li {
    padding: 8px 12px;
    cursor: pointer;
    color: #fff;
}

.dropdown-options li:hover {
    background: hsla(228, 48%, 70%, 1);
}

.dropdown-options li.selected {
    background: hsla(228, 48%, 60%, 1);
}

/* Ensure hidden options stay hidden in Safari */
.dropdown-options li[style*="display: none"] {
    display: none !important;
}

#pdf-zoom-select {
    display: none !important;
}

/* Right section - Download, print, expand/close */
.pdf-controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Base style for all toolbar elements */
#pdf-controls button,
#pdf-controls select,
#pdf-controls input {
  background: transparent;
  border: none;
  color: white;
  font-size: 0.75rem; /* Slightly larger than before */
  padding: 8px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  border-radius: 6px; /* More square-like */
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* Special styling for numbered text elements */
#pdf-controls input,
#pdf-page-num {
  font-size: 0.65rem; /* Keep original size for numbers */
  background: hsla(0,0%,100%,0.08);
  width: 40px;
  text-align: center;
  padding: 6px 4px;
}

/* Page count text */
.pdf-page-info {
  font-size: 0.65rem; /* Keep original size for numbers */
  color: white;
  display: flex;
  align-items: center;
  padding: 0 4px;
}

#pdf-page-count {
  margin-left: 6px;
}

/* Select dropdown styling */
#pdf-controls select {
  background: hsla(0,0%,100%,0.08);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.65rem; /* Keep smaller for dropdown */
  height: 32px;
  min-width: 120px;
}

/* Hover and active effects for buttons */
#pdf-controls button:hover {
  background: hsla(0,0%,100%,0.1);
}

#pdf-controls button:active {
  transform: scale(0.95);
}

#pdf-controls select:hover,
#pdf-controls input:hover {
  background: hsla(0,0%,100%,0.12);
}

/* Icon styling */
#pdf-controls button svg {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  fill: white;
}

/* Sidebar toggle button - slightly larger for better visibility */
#pdf-sidebar-toggle {
  font-size: 0.9rem;
  font-weight: bold;
}

#pdf-modal {
    position: fixed;
    pointer-events: auto;
    top: 1vh;
    left: 1vw;
    right: 1vw;
    bottom: 1vh;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    border-radius: 25px;
}

#pdf-modal #frame {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

body.no-scroll {
    overflow: hidden;
    pointer-events: none;
}

.pdf-thumb-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}

.pdf-thumb-label {
  font-size: 0.65rem;
  color: hsla(0,0%,80%,1);
  margin-top: 2px;
  text-align: center;
}

/* Mobile placeholder for PDF viewer */
.pdf-mobile-placeholder {
  display: none;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background: hsla(201, 100%, 10%, 1);
  overflow: hidden;
  position: relative;
}

.pdf-mobile-open-btn {
  background: linear-gradient(135deg, 
    hsla(0, 0%, 100%, 0.87) 0%, 
    hsla(0, 0%, 100%, 0.87) 100%);
  color: hsla(0, 0%, 45%, 1);
  border: 1px solid hsla(0, 0%, 100%, 0.15);
  /* Consistent proportional padding */
  padding: 4vmin 6vmin;
  font-size: 3vmin;
  font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  transition: all 300ms ease;
  box-shadow: 
    inset 0 1px 0 hsla(0, 0%, 100%, 0.2),
    0 8px 32px hsla(0, 0%, 0%, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2vmin;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0.025em;
  backdrop-filter: blur(10px);
  /* Maintain minimum dimensions */
  min-width: 60vmin;
  min-height: 20vmin;
  /* Maintain aspect ratio */
  aspect-ratio: 2/1;
}

.pdf-mobile-btn-text {
  font-size: 1em;
  font-weight: 500;
  margin: 0;
  line-height: 1.2;
  color: inherit;
  text-align: center;
}

.pdf-mobile-btn-icon {
  width: 8vmin;
  height: 8vmin;
  color: hsla(0, 0%, 60%, 1);
  transition: color 300ms ease;
}

/* ---- Custom Scrollbar Styles for PDF Viewer ---- */
/* Apply to all scrollable containers in PDF viewer */
#pdf-canvas-container::-webkit-scrollbar,
#pdf-sidebar::-webkit-scrollbar,
#pdf-modal #pdf-canvas-container::-webkit-scrollbar,
#pdf-modal #pdf-sidebar::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

#pdf-canvas-container::-webkit-scrollbar-track,
#pdf-sidebar::-webkit-scrollbar-track,
#pdf-modal #pdf-canvas-container::-webkit-scrollbar-track,
#pdf-modal #pdf-sidebar::-webkit-scrollbar-track {
    background: hsla(201, 100%, 10%, 1);
    border-radius: 5px;
}

#pdf-canvas-container::-webkit-scrollbar-thumb,
#pdf-sidebar::-webkit-scrollbar-thumb,
#pdf-modal #pdf-canvas-container::-webkit-scrollbar-thumb,
#pdf-modal #pdf-sidebar::-webkit-scrollbar-thumb {
    background: hsla(228, 48%, 60%, 1);
    border-radius: 5px;
    border: 2px solid hsla(201, 100%, 10%, 1);
}

#pdf-canvas-container::-webkit-scrollbar-thumb:hover,
#pdf-sidebar::-webkit-scrollbar-thumb:hover,
#pdf-modal #pdf-canvas-container::-webkit-scrollbar-thumb:hover,
#pdf-modal #pdf-sidebar::-webkit-scrollbar-thumb:hover {
    background: hsla(228, 48%, 70%, 1);
}

#pdf-canvas-container::-webkit-scrollbar-thumb:active,
#pdf-sidebar::-webkit-scrollbar-thumb:active,
#pdf-modal #pdf-canvas-container::-webkit-scrollbar-thumb:active,
#pdf-modal #pdf-sidebar::-webkit-scrollbar-thumb:active {
    background: hsla(228, 48%, 50%, 1);
}

/* Responsive Styles */

/* Large tablets and small desktops (1200px and down) */
@media (max-width: 1200px) {
  #pdf-controls {
    padding: 8px 12px;
  }
  
  #pdf-controls button,
  #pdf-controls select,
  #pdf-controls input {
    height: 30px;
    min-width: 30px;
    padding: 6px;
    font-size: 0.7rem;
  }
  
  #pdf-controls button svg {
    width: 16px;
    height: 16px;
  }
  
  #pdf-sidebar.open {
    width: 200px;
  }
}

/* Tablets (1020px and down) - Main mobile breakpoint */
@media (max-width: 1020px) {
  /* Hide regular PDF viewer components */
  #pdf-pages,
  #pdf-controls {
    display: none !important;
  }
  
  /* Show mobile placeholder */
  .pdf-mobile-placeholder {
    display: flex;
  }
  
  /* Show limited controls in modal */
  #pdf-modal #pdf-controls {
    display: flex !important;
    padding: 8px 12px;
  }
  
  /* Hide unwanted controls in modal */
  #pdf-modal .pdf-zoom-group select, #pdf-modal .custom-zoom-dropdown {
    display: none !important;
  }
  
  /* Keep only specific controls visible in modal */
  #pdf-modal .pdf-nav-group,
  #pdf-modal #pdf-zoom-in,
  #pdf-modal #pdf-zoom-out,
  #pdf-modal #pdf-download,
  #pdf-modal .pdf-controls-left,
  #pdf-modal #pdf-sidebar-toggle,
  #pdf-modal #pdf-print,
  #pdf-modal #pdf-expand {
    display: flex !important;
  }
  
  /* Make sure PDF pages and container show in modal */
  #pdf-modal #pdf-pages,
  #pdf-modal #pdf-canvas-container {
    display: flex !important;
  }
  
  /* Hide mobile placeholder in modal */
  #pdf-modal .pdf-mobile-placeholder {
    display: none !important;
  }
  
  /* Adjust button sizes for mobile modal */
  #pdf-modal #pdf-controls button,
  #pdf-modal #pdf-controls input {
    height: 36px;
    min-width: 36px;
    padding: 8px;
    font-size: 0.8rem;
  }
  
  #pdf-modal #pdf-controls button svg {
    width: 20px;
    height: 20px;
  }
  
  /* Adjust page input width for mobile */
  #pdf-modal #pdf-controls input,
  #pdf-modal #pdf-page-num {
    width: 50px;
  }
}

/* Small tablets and large phones (768px and down) */
@media (max-width: 768px) {
  #pdf-modal .pdf-controls-left,
  #pdf-modal #pdf-sidebar-toggle,
  #pdf-sidebar {
    display: none !important;
  }

  .pdf-mobile-placeholder {
    padding: 0;
  }
  
  .pdf-mobile-btn-text {
    font-size: 0.95rem;
  }
  
  .pdf-mobile-btn-icon {
    font-size: 1.8rem;
  }
  
  /* Further reduce modal controls */
  #pdf-modal #pdf-controls {
    padding: 6px 8px;
    flex-direction: row-reverse;
  }
  
  #pdf-modal #pdf-controls button,
  #pdf-modal #pdf-controls input {
    height: 32px;
    min-width: 32px;
    padding: 6px;
    font-size: 0.75rem;
  }
  
  #pdf-modal #pdf-controls button svg {
    width: 18px;
    height: 18px;
  }
  
  #pdf-modal .pdf-controls-center {
    gap: 15px;
  }
  
  #pdf-modal .pdf-nav-group,
  #pdf-modal .pdf-zoom-group,
  #pdf-modal .pdf-controls-right {
    gap: 4px;
  }
}

@media (max-width: 640px) {
  .pdf-mobile-placeholder {
    padding: 0;
  }
  
  .pdf-mobile-btn-text {
    font-size: 0.9rem;
  }
  
  .pdf-mobile-btn-icon {
    font-size: 1.7rem;
  }
  
  /* Compact modal controls */
  #pdf-modal #pdf-controls {
    padding: 5px 8px;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  #pdf-modal .pdf-controls-center {
    position: static;
    transform: none;
    gap: 12px;
    order: 2;
    width: auto;
    justify-content: center;
  }
  
  #pdf-modal .pdf-controls-right {
    order: 1;
  }
  
  #pdf-modal #pdf-controls button,
  #pdf-modal #pdf-controls input {
    height: 30px;
    min-width: 30px;
    padding: 5px;
    font-size: 0.7rem;
  }
  
  #pdf-modal #pdf-controls button svg {
    width: 16px;
    height: 16px;
  }
  
  #pdf-modal #pdf-controls input,
  #pdf-modal #pdf-page-num {
    width: 45px;
  }
}

/* Mobile phones (480px and down) */
@media (max-width: 480px) {
  .pdf-mobile-placeholder {
    padding: 0;
  }
  
  .pdf-mobile-btn-text {
    font-size: 0.85rem;
  }
  
  .pdf-mobile-btn-icon {
    font-size: 1.6rem;
  }
}

#pdf-modal-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: hsla(201, 100%, 10%, 0.95);
    border-bottom: 1px solid hsla(0,0%,100%,0.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

#pdf-modal-header.hidden {
    transform: translateY(-100%);
}

#pdf-modal-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
    padding-top: 50px; /* Height of header */
    box-sizing: border-box;
    transition: padding-top 0.3s ease;
}

#pdf-modal-header.hidden + #pdf-modal-content {
    padding-top: 0;
}