/* Policy Reader Styles */

/* PDF Viewer Styles */
.react-pdf__Page {
  margin: 0 auto;
  display: block;
}

.react-pdf__Page__canvas {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.react-pdf__Page__textContent {
  -webkit-user-select: text;
     -moz-user-select: text;
          user-select: text;
}

.react-pdf__Page__annotations {
  pointer-events: auto;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  .react-pdf__Page {
    margin: 0;
  }
  
  .react-pdf__Page__canvas {
    width: 100% !important;
    height: auto !important;
  }
}

/* DOCX Preview Viewer Styles (docx-preview / renderAsync) */

/* The viewer body container */
.docx-viewer-body {
  background: white;
  padding: 0;
  overflow: hidden;
}

/* Each rendered page section */
.docx-viewer-body section.docx-page {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin: 0 auto;
  background: white;
  /* docx-preview sets explicit width/height — allow horizontal scroll on small screens */
  max-width: 100%;
  overflow-x: auto;
}

/* Wrap long content */
.docx-viewer-body section.docx-page * {
  max-width: 100%;
  word-break: break-word;
}

/* Images inside the document */
.docx-viewer-body section.docx-page img {
  max-width: 100%;
  height: auto;
}

/* Dark mode: invert the rendered document so it looks natural on dark backgrounds.
 * docx-preview uses inline styles (background:white, color:black) so we can't just
 * change colours — we have to invert the whole section and double-invert images. */
.dark .docx-viewer-body {
  background: transparent;
}

.dark .docx-viewer-body section.docx-page {
  /* Invert + hue-rotate: white → near-black, black → near-white, colours stay sane */
  filter: invert(93%) hue-rotate(180deg);
  border-radius: 6px;
  /* Prevent the bright white flash while the page loads */
  background: transparent !important;
}

/* Double-invert images so they remain true-to-original (not inverted) */
.dark .docx-viewer-body section.docx-page img,
.dark .docx-viewer-body section.docx-page svg {
  filter: invert(1) hue-rotate(180deg);
}

/*
 * Legacy .docx-content styles kept for any fallback paths
 * that still use the old mammoth renderer.
 */
.docx-content {
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.docx-content p { margin-bottom: 1rem; }
.docx-content h1,
.docx-content h2,
.docx-content h3,
.docx-content h4,
.docx-content h5,
.docx-content h6 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.3;
}
.docx-content h1 { font-size: 1.875rem; }
.docx-content h2 { font-size: 1.5rem; }
.docx-content h3 { font-size: 1.25rem; }
.docx-content h4 { font-size: 1.125rem; }
.docx-content ul,
.docx-content ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.docx-content li { margin-bottom: 0.25rem; }
.docx-content table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: 0.875rem; }
.docx-content td,
.docx-content th { border: 1px solid #e5e7eb; padding: 0.5rem; text-align: left; vertical-align: top; }
.docx-content th { background-color: #f9fafb; font-weight: 600; }

/* Quiz Modal Styles */
.quiz-question-card {
  transition: all 0.2s ease-in-out;
}

.quiz-question-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quiz-results-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.quiz-results-card.failed {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

/* Reading metrics animations */
.reading-stats {
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Progress bar enhancements */
.reading-progress {
  transition: width 0.3s ease-in-out;
}

/* Mobile-first responsive design */
@media (max-width: 640px) {
  .policy-reader-container {
    padding: 0.5rem;
  }
  
  .policy-reader-header {
    flex-direction: column;
    gap: 1rem;
  }
  
  .policy-reader-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  
  .policy-reader-navigation {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .policy-reader-navigation button {
    width: 100%;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .reading-stats,
  .quiz-question-card,
  .reading-progress {
    animation: none;
    transition: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .docx-content td, 
  .docx-content th {
    border-width: 2px;
  }
  
  .quiz-question-card {
    border-width: 2px;
  }
}
