/* Basic PDF Viewer - Complete Styles */

/* Reset and base styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.4;
}

/* Main container */
#pdf-container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

/* State containers */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 2rem;
  text-align: center;
}

/* Loading state */
#loading-state {
  background: #fafafa;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-left: 4px solid #007ace;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

#loading-state p {
  font-size: 16px;
  color: #666;
  margin: 0;
}

/* Error state */
#error-state {
  background: #fff;
  border: 1px solid #ff4444;
  border-radius: 8px;
  max-width: 500px;
  margin: 2rem auto;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 1rem;
}

#error-state p {
  font-size: 16px;
  color: #666;
  margin: 0 0 1rem 0;
}

#error-state a {
  color: #007ace;
  text-decoration: none;
}

#error-state a:hover {
  text-decoration: underline;
}

.retry-btn {
  background: #007ace;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.retry-btn:hover {
  background: #005fa3;
}

/* Viewer wrapper */
#viewer-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* PDF Controls */
.pdf-controls {
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 100;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
}

/* Control groups */
.pdf-nav-group,
.pdf-zoom-group,
.pdf-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #007ace;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-height: 36px;
}

.pdf-btn:hover:not(:disabled) {
  background: #005fa3;
  transform: translateY(-1px);
}

.pdf-btn:active:not(:disabled) {
  transform: translateY(0);
}

.pdf-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
  transform: none;
}

.pdf-btn-icon {
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
}

.pdf-btn-text {
  font-size: 14px;
}

/* Download button variant */
.pdf-download-btn {
  background: #28a745;
}

.pdf-download-btn:hover {
  background: #218838;
}

/* Page input group */
.pdf-page-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: #666;
}

#pageInput {
  width: 60px;
  height: 36px;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  padding: 0 8px;
  transition: border-color 0.2s;
}

#pageInput:focus {
  outline: none;
  border-color: #007ace;
  box-shadow: 0 0 0 2px rgba(0, 122, 206, 0.2);
}

.pdf-page-total {
  font-weight: 500;
  color: #333;
  white-space: nowrap;
}

/* Select dropdown */
.pdf-select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.pdf-select:focus {
  outline: none;
  border-color: #007ace;
  box-shadow: 0 0 0 2px rgba(0, 122, 206, 0.2);
}

/* Canvas container */
.pdf-canvas-container {
  flex: 1;
  padding: 20px;
  background: #f5f5f5;
  position: relative;
  /* Remove overflow from here since parent will handle it */
}

/* Canvas wrapper */
.pdf-canvas-wrapper {
  display: block;
  text-align: center;
  position: relative;
  width: 100%;
  padding-bottom: 40px; /* Add bottom padding for better scrolling experience */
}

/* PDF Canvas */
.pdf-canvas {
  display: inline-block;
  margin: 20px auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  background: white;
  cursor: grab;
  /* Ensure visibility */
  opacity: 1;
  visibility: visible;
  vertical-align: top;
}

.pdf-canvas:active {
  cursor: grabbing;
}

/* Text layer for text selection */
.pdf-text-layer {
  position: absolute;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  overflow: hidden;
  opacity: 0;
  line-height: 1.0;
  pointer-events: none;
  z-index: 1;
}

.pdf-text-layer span.pdf-text-item {
  position: absolute;
  white-space: pre;
  color: transparent;
  user-select: text;
  pointer-events: auto;
}

.pdf-text-layer:hover {
  opacity: 0.3;
}

/* Responsive design */
@media (max-width: 768px) {
  .pdf-controls {
    padding: 8px 12px;
    gap: 12px;
  }
  
  .pdf-nav-group,
  .pdf-zoom-group,
  .pdf-action-group {
    gap: 6px;
  }
  
  .pdf-btn {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 32px;
  }
  
  .pdf-btn-text {
    display: none; /* Hide text labels on mobile, show icons only */
  }
  
  #pageInput {
    width: 50px;
    height: 32px;
    font-size: 13px;
  }
  
  .pdf-select {
    height: 32px;
    font-size: 13px;
    padding: 0 8px;
  }
  
  .pdf-canvas-container {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .pdf-controls {
    flex-direction: column;
    gap: 8px;
  }
  
  .pdf-nav-group {
    order: 1;
  }
  
  .pdf-zoom-group {
    order: 2;
  }
  
  .pdf-action-group {
    order: 3;
  }
  
  .pdf-canvas-container {
    padding: 5px;
  }
}

/* Print styles */
@media print {
  .pdf-controls {
    display: none;
  }
  
  .pdf-canvas-container {
    padding: 0;
    background: white;
  }
  
  .pdf-canvas {
    box-shadow: none;
    max-width: 100% !important;
    max-height: 100% !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .pdf-btn {
    border: 2px solid currentColor;
  }
  
  #pageInput,
  .pdf-select {
    border: 2px solid #333;
  }
  
  .pdf-canvas {
    border: 2px solid #333;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation: none;
  }
  
  .pdf-btn {
    transition: none;
  }
  
  #pageInput,
  .pdf-select {
    transition: none;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  body {
    background: #1a1a1a;
    color: #e0e0e0;
  }
  
  #pdf-container {
    background: #2a2a2a;
  }
  
  #loading-state {
    background: #2a2a2a;
  }
  
  #loading-state p {
    color: #b0b0b0;
  }
  
  .loading-spinner {
    border: 4px solid #444;
    border-left: 4px solid #007ace;
  }
  
  .pdf-controls {
    background: #2a2a2a;
    border-bottom-color: #444;
  }
  
  #pageInput,
  .pdf-select {
    background: #1a1a1a;
    border-color: #444;
    color: #e0e0e0;
  }
  
  #pageInput:focus,
  .pdf-select:focus {
    border-color: #007ace;
  }
  
  .pdf-page-total {
    color: #b0b0b0;
  }
  
  .pdf-canvas-container {
    background: #1a1a1a;
  }
}