/**
 * Print Stylesheet for SundK Academic Reports
 * Optimized for professional academic printing
 */

@media print {

  /* =================== RESET & BASE =================== */

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt;
    line-height: 1.6;
    color: #000;
    background: white;
    margin: 0;
    padding: 0;
  }

  /* =================== HIDE INTERACTIVE ELEMENTS =================== */

  /* Hide all screen-only UI elements */
  .report-header,
  .report-footer,
  .floating-buttons,
  .fab-btn,
  .toc-sidebar,
  .d-print-none,
  .gallery-nav,
  .gallery-nav-btn,
  .gallery-counter,
  .gallery-topbar,
  .gallery-topbar-btn,
  .gallery-overview,
  .gallery-overview-header,
  .gallery-overview-toggle,
  .gallery-overview-content,
  .gallery-search,
  .gallery-toolbar,
  .gallery-mobile-message,
  .header-btn,
  .data-card-btn,
  .data-card-btn-label {
    display: none !important;
  }

  /* =================== SHOW ALL CONTENT =================== */

  /* Override mobile restrictions - show galleries on print */
  .media-gallery {
    display: block !important;
    page-break-inside: avoid;
    margin: 1.5rem 0;
    border: none !important;
    background: white !important;
    box-shadow: none !important;
  }

  /* Show ALL gallery slides, not just active ones */
  .gallery-slide {
    display: block !important;
    page-break-inside: avoid;
    margin: 0;
    padding: 1rem 0;
    border: none !important;
    border-bottom: 1px solid #ddd;
    box-shadow: none !important;
  }

  .gallery-slide:last-child {
    border-bottom: none !important;
  }

  /* Remove inline styles that hide slides */
  .gallery-slide[style*="display: none"] {
    display: block !important;
  }

  /* =================== HERO SECTION AS COVER PAGE =================== */

  .report-hero {
    background: white !important;
    color: #000 !important;
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    page-break-after: always;
    border-bottom: 3px solid #162e59;
    text-align: center;
  }

  /* Remove decorative elements */
  .hero-glow,
  .hero-glow-3,
  .hero-logo-bg,
  .hero-logo-top-right {
    display: none !important;
  }

  .hero-glass-card {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 2rem 1rem;
  }

  .hero-glass-card h1 {
    font-size: 28pt;
    font-weight: bold;
    color: #162e59 !important;
    margin-bottom: 1rem;
  }

  .hero-glass-card h2 {
    font-size: 20pt;
    font-weight: normal;
    color: #000 !important;
    margin-bottom: 0.75rem;
  }

  .hero-glass-card h3 {
    font-size: 16pt;
    font-weight: normal;
    color: #000 !important;
    margin-bottom: 0.5rem;
  }

  .hero-date {
    font-size: 11pt;
    color: #333 !important;
  }

  /* =================== TYPOGRAPHY =================== */

  .report-section h1 {
    font-size: 24pt;
    font-weight: bold;
    color: #000;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    page-break-after: avoid;
  }

  .report-section h2 {
    font-size: 18pt;
    font-weight: bold;
    color: #000;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    page-break-after: avoid;
  }

  .report-section h3 {
    font-size: 16pt;
    font-weight: bold;
    color: #000;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    page-break-after: avoid;
  }

  .report-section h4 {
    font-size: 14pt;
    font-weight: bold;
    color: #000;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    page-break-after: avoid;
  }

  .report-section h5 {
    font-size: 12pt;
    font-weight: bold;
    color: #000;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    page-break-after: avoid;
  }

  .report-section h6 {
    font-size: 11pt;
    font-weight: bold;
    color: #000;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    page-break-after: avoid;
  }

  p {
    margin: 0 0 0.75rem 0;
    text-align: justify;
    orphans: 3;
    widows: 3;
  }

  /* =================== LAYOUT & STRUCTURE =================== */

  .report-wrapper {
    display: block;
    width: 100%;
  }

  .report-main {
    background: white;
  }

  .report-content {
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: white;
  }

  .report-section {
    padding: 1rem 1.5rem;
    background: white !important;
    page-break-inside: avoid;
  }

  /* Allow sections to break if they're very long */
  .report-section:has(> .media-gallery),
  .report-section:has(> .data-card-grid) {
    page-break-inside: auto;
  }

  /* =================== GALLERIES =================== */

  .gallery-header {
    display: none !important;
  }

  .gallery-title {
    display: none !important;
  }

  .gallery-slides,
  .tables-gallery-slides {
    background: white !important;
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    min-height: 0;
    overflow: visible;
  }

  /* Gallery slide labels and captions */
  .gallery-slide::before {
    content: attr(data-label) " - " attr(data-title);
    display: block;
    font-size: 11pt;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #000;
  }

  .slide-caption {
    margin: 0.75rem 0;
    font-size: 10pt;
    color: #333;
    font-style: italic;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    padding: 0.5rem 0;
  }

  /* =================== TABLES =================== */

  /* Remove borders from gallery containers only, not tables themselves */
  .gallery-table-container {
    max-height: none !important;
    overflow: visible !important;
    padding: 0.5rem 0;
    border: none !important;
    box-shadow: none !important;
  }

  .gallery-img-container,
  .gallery-download-container {
    border: none !important;
    box-shadow: none !important;
  }

  /* Let tables keep their original styling from table-data.js */
  .gallery-table,
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
    page-break-inside: auto;
    margin: 0.5rem 0;
  }

  /* Hide sort icons */
  .sort-icon {
    display: none !important;
  }

  /* Remove hover effects */
  .gallery-table tbody tr:hover td {
    background-color: transparent !important;
  }

  /* Ensure tables break properly */
  .gallery-table tr,
  table tr {
    page-break-inside: avoid;
  }

  /* Ensure first row after thead doesn't break */
  .gallery-table tbody tr:first-child,
  table tbody tr:first-child {
    page-break-before: avoid;
  }

  /* =================== IMAGES =================== */

  .gallery-img-container {
    max-height: none !important;
    overflow: visible !important;
    padding: 0.5rem 0;
    text-align: center;
  }

  .gallery-slide img,
  img {
    max-width: 100%;
    height: auto;
    page-break-inside: avoid;
    display: block;
    margin: 0 auto;
  }

  /* =================== DATA CARDS =================== */

  .data-card-grid {
    display: block;
    margin: 1rem 0;
  }

  /* Style data cards as simple headings in print */
  .data-card,
  a.data-card {
    background: none !important;
    color: #000 !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0.5rem 0 0 0 !important;
    page-break-inside: avoid;
    display: block;
    text-decoration: none;
  }

  /* Hide the icon in print */
  .data-card-icon {
    display: none !important;
  }

  /* Make content look like normal text flow */
  .data-card-content {
    display: block;
    margin: 0;
  }

  /* Style h4 as a subheading */
  .data-card-content h4 {
    font-size: 11pt !important;
    font-weight: bold !important;
    color: #000 !important;
    margin: 0.5rem 0 0.25rem 0 !important;
  }

  /* Style description as normal paragraph */
  .data-card-content p {
    font-size: 10pt;
    color: #333 !important;
    margin: 0 0 0.5rem 0 !important;
    font-style: italic;
  }

  /* =================== DOWNLOADS =================== */

  .gallery-download-container {
    padding: 1rem 0;
  }

  .gallery-slide-download {
    min-height: 0;
    padding: 1rem;
    border: 1px dashed #333;
    text-align: center;
  }

  .gallery-download-icon {
    font-size: 24pt;
    color: #000 !important;
    margin-bottom: 0.5rem;
  }

  .gallery-download-message {
    font-size: 10pt;
    color: #333 !important;
    margin-bottom: 0.5rem;
  }

  .gallery-download-filename {
    font-size: 11pt;
    font-weight: bold;
    color: #000 !important;
    margin-bottom: 0.5rem;
  }

  .gallery-download-btn {
    display: none !important;
  }

  /* Show download URL */
  .gallery-download-btn::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666;
  }

  /* =================== LINKS =================== */

  a {
    color: #000;
    text-decoration: underline;
  }

  /* Show URLs for external links */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666;
    font-weight: normal;
  }

  /* Don't show URLs for internal links */
  a[href^="#"]::after {
    content: "";
  }

  .cross-ref-link {
    color: #000;
    border-bottom: none;
  }

  /* =================== PAGE BREAKS =================== */

  /* Avoid breaks inside these elements */
  .media-gallery,
  .data-card,
  .gallery-slide,
  figure,
  img,
  table,
  .gallery-table {
    page-break-inside: avoid;
  }

  /* Ensure sections can start on new pages */
  .report-section {
    page-break-before: auto;
  }

  /* First section shouldn't break from hero */
  .report-section:first-of-type {
    page-break-before: avoid;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  /* Keep heading with at least 2 lines of following content */
  h1::after, h2::after, h3::after,
  h4::after, h5::after, h6::after {
    content: "";
    display: block;
    height: 0;
    page-break-inside: avoid;
  }

  /* =================== PAGE MARGINS & SIZE =================== */

  @page {
    size: A4;
    margin: 2cm 2cm 2cm 2cm;
  }

  @page :first {
    margin-top: 3cm;
  }

  /* =================== ANIMATIONS & EFFECTS =================== */

  /* Remove all animations, transitions, shadows, and borders */
  * {
    animation: none !important;
    transition: none !important;
    box-shadow: none !important;
  }

  .hash-target {
    animation: none !important;
  }

  /* Remove any remaining borders and shadows from specific elements */
  .gallery-header,
  .gallery-slides,
  .tables-gallery-slides,
  .gallery-slide,
  .media-gallery {
    box-shadow: none !important;
  }

  /* Remove borders from ALL gallery-related classes */
  [class*="gallery-"],
  [class*="gallery"] {
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    box-shadow: none !important;
  }

  /* Only allow specific bottom borders where needed */
  .gallery-header {
    border-bottom: 2px solid #162e59 !important;
  }

  .gallery-slide {
    border-bottom: 1px solid #ddd !important;
  }

  .gallery-slide:last-child {
    border-bottom: none !important;
  }


  /* =================== UTILITIES =================== */

  /* Force black text */
  .text-white,
  [class*="text-"] {
    color: #000 !important;
  }

  /* Remove Bootstrap print utilities conflicts */
  .d-print-block {
    display: block !important;
  }

  .d-print-inline {
    display: inline !important;
  }

  .d-print-inline-block {
    display: inline-block !important;
  }

  /* =================== DATA CARD PRINT CONTENT =================== */

  /* Hide injected content on screen */
  @media screen {
    .datacard-print-content {
      display: none !important;
    }
  }

  /* Show injected data card content styled like gallery slides */
  .datacard-print-content {
    display: block !important;
    page-break-inside: avoid;
    margin: 0;
    padding: 1rem 0;
    border: none !important;
    border-bottom: 1px solid #ddd !important;
    box-shadow: none !important;
    background: white !important;
  }

  /* Style download filepath */
  .gallery-download-filepath {
    font-size: 9pt;
    color: #666;
    margin-top: 0.5rem;
    word-break: break-all;
  }

  /* Keep data card visible but ensure it doesn't break from its content */
  .data-card {
    page-break-after: avoid;
  }
}
