/* PDF Viewer Container */
.pdf-viewer-container {
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 24px;
  margin-bottom: 40px;
  border: 1px solid #e1e8ed;
  width: 100%;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.pdf-viewer-header {
  margin-bottom: 20px;
  border-bottom: 2px solid #3498db;
  padding-bottom: 15px;
}

.pdf-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: #2c3e50;
  text-align: center;
}

/* Controls */
.pdf-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid #dee2e6;
}

.pdf-nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pdf-zoom-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Buttons */
.pdf-controls button {
  background: white;
  color: #2c3e50;
  border: 2px solid #3498db;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-controls button:hover {
  background: #3498db;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.pdf-controls button:active {
  transform: translateY(0);
}

.pdf-controls button:disabled {
  background: #bdc3c7;
  border-color: #95a5a6;
  color: #7f8c8d;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Zoom-specific buttons */
.pdf-zoom-out-btn,
.pdf-zoom-in-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
}

.pdf-fit-width-btn,
.pdf-fit-auto-btn {
  font-size: 12px;
  padding: 8px 12px;
}

/* Page info */
.page-info {
  font-weight: 600;
  color: #2c3e50;
  background: white;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

.zoom-level {
  font-weight: 600;
  color: #2c3e50;
  background: white;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  min-width: 60px;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

/* Download button */
.pdf-download-btn {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: white;
  padding: 10px 20px;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.pdf-download-btn:hover {
  background: linear-gradient(135deg, #219653, #27ae60);
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

/* Viewport Container */
.pdf-viewport-container {
  position: relative;
  border: 1px solid #e1e8ed;
  border-radius: 8px;
  overflow: auto;
  background: 
    linear-gradient(45deg, #f8f9fa 25%, transparent 25%), 
    linear-gradient(-45deg, #f8f9fa 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #f8f9fa 75%), 
    linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.pdf-canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px;
  min-height: 100%;
}

/* Canvas - Proper aspect ratio handling */
.pdf-canvas {
  display: block;
  margin: 0 auto;
  background: white;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 1px solid #e1e8ed;
  border-radius: 4px;
  /* Remove all constraints that cause distortion */
  max-width: none !important;
  max-height: none !important;
  width: auto !important;
  height: auto !important;
  /* High-quality rendering */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Loading and Error States */
.pdf-loading,
.pdf-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  padding: 40px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid #e1e8ed;
  z-index: 10;
  min-width: 300px;
}

.pdf-loading {
  color: #7f8c8d;
}

.pdf-error {
  color: #e74c3c;
}

.loading-spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

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

/* Responsive Design */
@media (max-width: 1200px) {
  .pdf-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .pdf-nav-controls,
  .pdf-zoom-controls {
    justify-content: center;
    width: 100%;
  }
  
  .pdf-canvas-wrapper {
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .pdf-viewer-container {
    padding: 16px;
    margin-bottom: 30px;
    border-radius: 8px;
  }
  
  .pdf-title {
    font-size: 1.3rem;
  }
  
  .pdf-controls {
    padding: 12px;
    gap: 10px;
  }
  
  .pdf-nav-controls,
  .pdf-zoom-controls {
    gap: 8px;
  }
  
  .pdf-controls button {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .page-info,
  .zoom-level {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .pdf-canvas-wrapper {
    padding: 15px;
  }
  
  .pdf-zoom-out-btn,
  .pdf-zoom-in-btn {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  .pdf-controls button {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }
  
  .pdf-fit-width-btn,
  .pdf-fit-auto-btn {
    font-size: 11px;
    padding: 6px 8px;
  }
  
  .pdf-download-btn {
    flex: 1;
    justify-content: center;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .pdf-canvas {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Print styles */
@media print {
  .pdf-controls {
    display: none;
  }
  
  .pdf-viewport-container {
    border: none;
    box-shadow: none;
    background: none;
  }
  
  .pdf-canvas-wrapper {
    padding: 0;
  }
  
  .pdf-canvas {
    box-shadow: none;
    border: none;
  }
}

/* Add to existing CSS - Active button state */
.pdf-controls button.active {
  background: #3498db;
  color: white;
  border-color: #2980b9;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.pdf-controls button.active:hover {
  background: #2980b9;
  color: white;
}