/* ALS Insights Custom Styles - Enhanced PDF Print Version */

/* Color Variables */
:root {
  --als-blue: #004477;
  --als-blue-light: #1e7bb8;
  --als-blue-dark: #003366;
  --als-yellow: #f1c40f;
  --als-yellow-hover: #f39c12;
}

/* Typography */
body {
  font-family: 'Numans', sans-serif;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Days One', sans-serif;
  font-weight: 700;
}

/* 1. Article Content Width - Balance adjustment */
.prose {
  color: #374151;
  max-width: 90ch; /* Set wider */
  margin: 0 auto; /* Center alignment */
}

/* Article layout adjustment */
article.max-w-4xl {
  max-width: 55rem; /* Set wider */
}

/* Header section width - Make narrower */
.bg-gradient-to-r.from-\[#004477\].to-\[#1e7bb8\] .max-w-4xl {
  max-width: 50rem; /* Make header section narrower */
}

/* Tags and other sections width - Make narrower */
.max-w-4xl.mx-auto.mt-12 {
  max-width: 50rem; /* Make tags and other sections narrower */
}

/* 2. Published date styling - Display darker */
.text-gray-200 {
  --tw-text-opacity: 1;
  color: rgb(209 213 219 / var(--tw-text-opacity)) !important; /* Darker gray */
}

/* Article header meta information */
.flex.flex-wrap.items-center.gap-4.text-gray-200 {
  color: #d1d5db !important; /* Darker gray */
  font-weight: 500; /* Slightly bolder */
}

.flex.flex-wrap.items-center.gap-4.text-gray-200 span {
  color: #d1d5db !important;
  opacity: 0.9;
}

/* 3. Table of Contents styling improvement */
.toc {
  position: sticky;
  top: 2rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

/* Parent element for positioning TOC as sidebar */
.article-with-toc {
  display: grid;
  grid-template-columns: 1fr 280px; /* Make sidebar slightly narrower */
  gap: 2.5rem; /* Make gap slightly wider */
  max-width: 85rem; /* Set wider */
  margin: 0 auto;
}

/* Normal layout for mobile */
@media (max-width: 1024px) {
  .article-with-toc {
    grid-template-columns: 1fr;
    max-width: 55rem; /* Make article section wide even on mobile */
  }
  
  .toc {
    position: static;
    margin-bottom: 2rem;
  }
}

/* 4. Remove underline from tag links */
.tag-list a,
.flex.flex-wrap.gap-2 a {
  text-decoration: none !important;
}

.flex.flex-wrap.gap-2 a:hover {
  text-decoration: none !important;
}

/* Tags hover effect improvement */
.flex.flex-wrap.gap-2 a {
  display: inline-block;
  background: #f1f5f9;
  color: var(--als-blue);
  padding: 0.5rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0.25rem 0.25rem 0.25rem 0;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.flex.flex-wrap.gap-2 a:hover {
  background: var(--als-yellow);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 5. Share buttons spacing and bottom margin */
.share-buttons .flex {
  gap: 1rem !important; /* Increase space between buttons */
}

.share-buttons {
  margin-bottom: 3rem !important; /* Add space below */
  padding-bottom: 2rem;
}

/* Share buttons styling improvement */
.share-buttons .btn {
  min-width: 100px;
  justify-content: center;
  transition: all 0.3s ease;
}

.share-buttons .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Prose Styling for Article Content */
.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--als-blue);
  font-family: 'Days One', sans-serif;
}

.prose h2 {
  border-bottom: 2px solid var(--als-yellow);
  padding-bottom: 0.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.prose h3 {
  color: var(--als-blue-light);
  margin-top: 1.5rem;
}

.prose a {
  color: var(--als-blue);
  text-decoration: underline;
  transition: color 0.3s ease;
}

.prose a:hover {
  color: var(--als-blue-light);
}

.prose blockquote {
  border-left: 4px solid var(--als-yellow);
  background: #f8f9fa;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  font-style: italic;
}

.prose code {
  background: #f1f5f9;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  color: var(--als-blue);
}

.prose pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
}

.prose table th {
  background: var(--als-blue);
  color: white;
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
}

.prose table td {
  padding: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.prose table tr:nth-child(even) {
  background: #f9fafb;
}

/* Table of Contents styling */
.toc ul {
  list-style: none;
  padding-left: 1rem;
}

.toc a {
  color: var(--als-blue);
  text-decoration: none;
  transition: color 0.3s ease;
  display: block;
  padding: 0.25rem 0;
}

.toc a:hover {
  color: var(--als-blue-light);
  background: #f8f9fa;
  padding-left: 0.5rem;
  border-radius: 0.25rem;
}

/* Navigation Breadcrumbs */
.breadcrumbs a {
  transition: color 0.3s ease;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

/* Related articles grid improvement */
.grid.grid-cols-1.md\\:grid-cols-3.gap-6 {
  max-width: 100%;
}

/* Custom Alert Boxes */
.alert-info {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-left: 4px solid var(--als-blue);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0.5rem;
}

.alert-warning {
  background: linear-gradient(135deg, #fff3e0 0%, #ffcc02 100%);
  border-left: 4px solid #ff9800;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0.5rem;
}

.alert-success {
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
  border-left: 4px solid #4caf50;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0.5rem;
}

/* Button Enhancements */
.btn {
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Card Hover Effects */
.content-card {
  transition: all 0.3s ease;
}

.content-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Footer Links */
footer a {
  transition: color 0.3s ease;
}

/* Responsive Improvements */
@media (max-width: 768px) {
  .prose {
    max-width: 100%;
    padding: 0 1rem;
  }
  
  .prose table {
    font-size: 0.875rem;
  }
  
  .prose table th,
  .prose table td {
    padding: 0.5rem;
  }
  
  .hero-text {
    font-size: 1.5rem;
  }
  
  .share-buttons .flex {
    flex-direction: column;
    gap: 0.5rem !important;
  }
  
  .share-buttons .btn {
    width: 100%;
  }
}

/* Loading States */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Search Highlighting */
.search-highlight {
  background: var(--als-yellow);
  padding: 0.1rem 0.2rem;
  border-radius: 0.25rem;
}

/* Enhanced Print Styles for PDF */
@media print {
  /* Page Setup */
  @page {
    size: A4;
    margin: 2.5cm 2cm 2cm 2cm;
    @top-center {
      content: "ALS Insights";
      font-family: 'Days One', sans-serif;
      font-size: 10pt;
      color: #004477;
      border-bottom: 1px solid #004477;
      padding-bottom: 0.5cm;
      margin-bottom: 1cm;
    }
    @bottom-center {
      content: "Page " counter(page) " of " counter(pages);
      font-size: 9pt;
      color: #666;
    }
  }

  /* Hide unnecessary elements */
  .navbar, 
  nav, 
  footer, 
  .btn, 
  .share-buttons, 
  .toc,
  .breadcrumbs,
  .sidebar,
  .comment-section,
  .related-articles,
  .back-to-top,
  .social-share,
  .print-btn,
  .search-box,
  .menu-toggle,
  .pagination {
    display: none !important;
  }

  /* Body and Layout */
  body {
    font-family: 'Numans', Georgia, serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #000;
    background: white;
    margin: 0;
    padding: 0;
  }

  /* Grid layout override for print */
  .article-with-toc {
    display: block !important;
    grid-template-columns: none !important;
    max-width: none !important;
  }

  /* Article content */
  .prose, 
  article {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #000 !important;
  }

  /* Article Header */
  .article-header,
  .bg-gradient-to-r {
    background: none !important;
    color: #000 !important;
    padding: 0 0 1cm 0 !important;
    margin-bottom: 1cm !important;
    border-bottom: 2px solid #004477 !important;
  }

  .article-header h1 {
    color: #004477 !important;
    font-size: 18pt !important;
    font-family: 'Days One', sans-serif !important;
    font-weight: bold !important;
    margin-bottom: 0.5cm !important;
    line-height: 1.3 !important;
  }

  /* Article meta information */
  .article-meta,
  .text-gray-200,
  .flex.flex-wrap.items-center.gap-4 {
    color: #666 !important;
    font-size: 10pt !important;
    margin-bottom: 1cm !important;
  }

  /* Typography for Print */
  .prose h1 {
    color: #004477 !important;
    font-size: 16pt !important;
    font-weight: bold !important;
    margin-top: 1cm !important;
    margin-bottom: 0.5cm !important;
    page-break-after: avoid !important;
    line-height: 1.3 !important;
  }

  .prose h2 {
    color: #004477 !important;
    font-size: 14pt !important;
    font-weight: bold !important;
    margin-top: 0.8cm !important;
    margin-bottom: 0.4cm !important;
    page-break-after: avoid !important;
    border-bottom: 1px solid #004477 !important;
    padding-bottom: 0.2cm !important;
  }

  .prose h3 {
    color: #1e7bb8 !important;
    font-size: 12pt !important;
    font-weight: bold !important;
    margin-top: 0.6cm !important;
    margin-bottom: 0.3cm !important;
    page-break-after: avoid !important;
  }

  .prose h4, .prose h5, .prose h6 {
    color: #000 !important;
    font-size: 11pt !important;
    font-weight: bold !important;
    margin-top: 0.5cm !important;
    margin-bottom: 0.3cm !important;
    page-break-after: avoid !important;
  }

  .prose p {
    margin-bottom: 0.4cm !important;
    orphans: 3 !important;
    widows: 3 !important;
    text-align: justify !important;
  }

  /* Lists */
  .prose ul, .prose ol {
    margin: 0.5cm 0 !important;
    padding-left: 1cm !important;
  }

  .prose li {
    margin-bottom: 0.2cm !important;
    page-break-inside: avoid !important;
  }

  /* Links - show URL in print */
  .prose a {
    color: #004477 !important;
    text-decoration: underline !important;
    word-wrap: break-word !important;
  }

  .prose a::after {
    content: " (" attr(href) ")" !important;
    font-size: 8pt !important;
    color: #666 !important;
    word-wrap: break-word !important;
  }

  /* Code blocks */
  .prose code {
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    padding: 0.1cm 0.2cm !important;
    font-family: 'Courier New', monospace !important;
    font-size: 9pt !important;
    color: #000 !important;
    page-break-inside: avoid !important;
  }

  .prose pre {
    background: #f8f8f8 !important;
    border: 1px solid #ddd !important;
    padding: 0.5cm !important;
    font-family: 'Courier New', monospace !important;
    font-size: 9pt !important;
    color: #000 !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
  }

  /* Tables */
  .prose table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 0.5cm 0 !important;
    font-size: 9pt !important;
    page-break-inside: avoid !important;
  }

  .prose table th {
    background: #f0f0f0 !important;
    color: #000 !important;
    border: 1px solid #333 !important;
    padding: 0.3cm !important;
    font-weight: bold !important;
    text-align: left !important;
  }

  .prose table td {
    border: 1px solid #666 !important;
    padding: 0.3cm !important;
    background: white !important;
  }

  .prose table tr:nth-child(even) {
    background: #f9f9f9 !important;
  }

  /* Blockquotes */
  .prose blockquote {
    border-left: 3pt solid #004477 !important;
    background: #f8f8f8 !important;
    margin: 0.5cm 0 !important;
    padding: 0.4cm 0.6cm !important;
    font-style: italic !important;
    page-break-inside: avoid !important;
  }

  /* Images */
  .prose img {
    max-width: 100% !important;
    height: auto !important;
    margin: 0.5cm 0 !important;
    page-break-inside: avoid !important;
    border: 1px solid #ddd !important;
  }

  /* Alert boxes for print */
  .alert-info, .alert-warning, .alert-success {
    border: 1px solid #ddd !important;
    background: #f8f8f8 !important;
    padding: 0.4cm !important;
    margin: 0.5cm 0 !important;
    page-break-inside: avoid !important;
  }

  .alert-info {
    border-left: 3pt solid #004477 !important;
  }

  .alert-warning {
    border-left: 3pt solid #ff9800 !important;
  }

  .alert-success {
    border-left: 3pt solid #4caf50 !important;
  }

  /* Tags section - simplified for print */
  .flex.flex-wrap.gap-2 {
    margin-top: 1cm !important;
    padding-top: 0.5cm !important;
    border-top: 1px solid #ddd !important;
  }

  .flex.flex-wrap.gap-2 a {
    background: none !important;
    color: #004477 !important;
    border: 1px solid #004477 !important;
    padding: 0.2cm 0.4cm !important;
    margin: 0.1cm !important;
    font-size: 9pt !important;
    text-decoration: none !important;
  }

  .flex.flex-wrap.gap-2 a::after {
    content: none !important;
  }

  /* Page breaks */
  .page-break {
    page-break-before: always !important;
  }

  .page-break-after {
    page-break-after: always !important;
  }

  /* Avoid page breaks */
  .avoid-break {
    page-break-inside: avoid !important;
  }

  /* Force page breaks before major sections */
  .prose h1 {
    page-break-before: auto !important;
  }

  /* Print-specific utilities */
  .print-only {
    display: block !important;
  }

  .no-print {
    display: none !important;
  }

  /* Ensure proper spacing for the last elements */
  .prose > *:last-child {
    margin-bottom: 0 !important;
  }
}