/* ===========================
   Markdown Page Generator CSS
   Fresh, Clean Design with Bootstrap Components
========================== */

:root {
  --primary-color: #5e9ea4;
  --secondary-color: #45b061;
  --accent-color: #17a2b8;
  --text-primary: #2c3e50;
  --text-secondary: #6c757d;
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --border-color: #dee2e6;
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --border-radius: 0.375rem;
  --transition: all 0.3s ease;
}

/* ===========================
   Typography Enhancements
=========================== */
.content-section {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.7;
  color: var(--text-primary);
}

/*Content section background*/
.content-section {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Headings with TOC support */
.content-section h1.toc,
.content-section h2.toc,
.content-section h3.toc,
.content-section h4.toc,
.content-section h5.toc,
.content-section h6.toc {
  color: var(--primary-color);
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
  position: relative;
  scroll-margin-top: 100px; /* Account for fixed header */
}

.content-section h1.toc {
  font-size: 2.5rem;
  border-bottom: 3px solid var(--primary-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.content-section h2.toc {
  font-size: 2rem;
  border-left: 4px solid var(--secondary-color);
  padding-left: 1rem;
  background: linear-gradient(90deg, rgba(40, 167, 69, 0.1) 0%, transparent 100%);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.content-section h3.toc {
  font-size: 1.5rem;
  color: var(--accent-color);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.25rem;
}

.content-section h4.toc {
  font-size: 1.25rem;
  color: var(--text-primary);
  font-weight: 500;
}

.content-section h5.toc,
.content-section h6.toc {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===========================
   Paragraph and Text Styling
=========================== */
.content-section p {
  margin-bottom: 1.25rem;
  text-align: justify;
  text-justify: inter-word;
}

.content-section strong {
  color: var(--primary-color);
  font-weight: 600;
}

.content-section em {
  color: var(--text-secondary);
  font-style: italic;
}

/* ===========================
   Links
=========================== */
.content-section a {
  color: var(--accent-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.content-section a:hover {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  text-decoration: none;
}

/* ===========================
   Lists with Bootstrap Enhancement
=========================== */
.content-section ul,
.content-section ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.content-section ul {
  list-style: none;
}

.content-section ul li {
  position: relative;
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
}

.content-section ul li:before {
  content: "▶";
  color: var(--secondary-color);
  position: absolute;
  left: 0;
  top: 0;
  font-size: 0.8rem;
}

.content-section ol li {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.content-section ol li::marker {
  color: var(--primary-color);
  font-weight: 600;
}

/* Nested lists */
.content-section ul ul,
.content-section ol ol,
.content-section ul ol,
.content-section ol ul {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.content-section ul ul li:before {
  content: "◦";
  color: var(--accent-color);
}

/* ===========================
   Task Lists (Checkboxes)
=========================== */
.content-section ul li input[type="checkbox"] {
  margin-right: 0.5rem;
  transform: scale(1.2);
  accent-color: var(--secondary-color);
}

.content-section ul li:has(input[type="checkbox"]):before {
  display: none;
}

/* ===========================
   Code Blocks and Inline Code
=========================== */
.content-section code {
  background-color: #f1f3f4;
  color: #e91e63;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-family: 'Fira Code', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 0.875em;
  font-weight: 500;
}

.content-section pre {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.content-section pre code {
  background: none;
  color: var(--text-primary);
  padding: 0;
  border-radius: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ===========================
   Blockquotes with Bootstrap Card Style
=========================== */
.content-section blockquote {
  background: linear-gradient(135deg, rgba(23, 162, 184, 0.1) 0%, rgba(40, 167, 69, 0.05) 100%);
  border-left: 4px solid var(--accent-color);
  padding: 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  box-shadow: var(--shadow-sm);
  font-style: italic;
  color: var(--text-secondary);
  position: relative;
}

.content-section blockquote:before {
  content: "\201C";
  font-size: 3rem;
  color: var(--accent-color);
  opacity: 0.3;
  position: absolute;
  top: -0.5rem;
  left: 1rem;
  font-family: Georgia, serif;
}

.content-section blockquote p:last-child {
  margin-bottom: 0;
}

/* ===========================
   Tables with Bootstrap Table Classes
=========================== */
.content-section table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  background-color: var(--bg-white);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.content-section table thead {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  color: white;
}

.content-section table th,
.content-section table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.content-section table th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

.content-section table tbody tr {
  transition: var(--transition);
}

.content-section table tbody tr:hover {
  background-color: rgba(40, 167, 69, 0.05);
}

.content-section table tbody tr:nth-child(even) {
  background-color: rgba(248, 249, 250, 0.5);
}

/* ===========================
   Images with Bootstrap Card Style
=========================== */
.content-section img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  margin: 1rem 0;
  transition: var(--transition);
}

.content-section img:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);
}

/* Image with caption wrapper */
.content-section p:has(img) {
  text-align: center;
  background: var(--bg-light);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}

/* ===========================
   Horizontal Rules
=========================== */
.content-section hr {
  border: none;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--primary-color) 50%, transparent 100%);
  margin: 2rem 0;
}

/* ===========================
   Details/Summary (Expandable Sections)
=========================== */
.content-section details {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin: 1rem 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.content-section details summary {
  background: linear-gradient(135deg, var(--bg-light) 0%, #e9ecef 100%);
  padding: 1rem 1.5rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-color);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
  user-select: none;
}

.content-section details summary:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.content-section details[open] summary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  color: white;
}

.content-section details > *:not(summary) {
  padding: 1.5rem;
  margin: 0;
}

/* ===========================
   Responsive Design
=========================== */
@media (max-width: 768px) {
  .content-section h1.toc {
    font-size: 2rem;
  }
  
  .content-section h2.toc {
    font-size: 1.75rem;
  }
  
  .content-section h3.toc {
    font-size: 1.5rem;
  }
  
  .content-section table {
    font-size: 0.875rem;
  }
  
  .content-section table th,
  .content-section table td {
    padding: 0.75rem 0.5rem;
  }
  
  .content-section pre {
    padding: 1rem;
  }
  
  .content-section blockquote {
    padding: 1rem;
  }
}

/* ===========================
   Animation and Scroll Effects
=========================== */
.content-section {
  animation: fadeInUp 0.6s ease-out;
}

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

/* Smooth scrolling for TOC links */
html {
  scroll-behavior: smooth;
}

/* ===========================
   Print Styles
=========================== */
@media print {
  .content-section {
    box-shadow: none;
    background: white !important;
  }
  
  .content-section img {
    box-shadow: none;
  }
  
  .content-section table {
    box-shadow: none;
  }
  
  .content-section details summary {
    background: white !important;
    color: black !important;
  }
}

/* ===========================
   PageGen Custom Renderers
=========================== */

/* Common container styles for custom renderers */
.pagegen-image-container,
.pagegen-molecule-container,
.pagegen-pdf-container,
.pagegen-chart-container {
  margin: 20px 0;
  border: 1px solid #ddd;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.pagegen-image-container:hover,
.pagegen-molecule-container:hover,
.pagegen-pdf-container:hover,
.pagegen-chart-container:hover {
  box-shadow: var(--shadow-md);
}

/* Image container specific styles */
.pagegen-image-container {
  display: inline-block;
  max-width: 100%;
}

/* Title styles for all containers */
.pagegen-title {
  background: var(--bg-light);
  padding: 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-primary);
  font-size: 0.95rem;
}

/* Content wrapper styles */
.pagegen-content {
  padding: 10px;
  text-align: center;
  background: var(--bg-white);
  position: relative;
}

/* PDF content wrapper */
.pagegen-pdf-container .pagegen-content {
  padding: 0;
  background: var(--bg-white);
  position: relative;
}

/* Chart content wrapper */
.pagegen-chart-container .pagegen-content {
  padding: 20px;
  background: var(--bg-white);
  position: relative;
}

/* Image styles */
.pagegen-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
}

/* Molecule viewer styles */
.pagegen-molecule-viewer {
  width: 100%;
  height: 400px;
  position: relative;
  background: var(--bg-white);
}

/* PDF viewer styles */
.pagegen-pdf {
  width: 100%;
  height: 600px;
  border: none;
}

/* PDF fallback styles */
.pagegen-pdf-fallback {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
}

/* Chart canvas styles */
.pagegen-chart {
  max-width: 100%;
  height: auto;
}

/* Error message styles */
.pagegen-error {
  padding: 20px;
  text-align: center;
  color: #dc3545;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  margin: 10px;
}

/* Download link styles */
.pagegen-download-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.pagegen-download-link:hover {
  text-decoration: underline;
  color: var(--accent-color);
}

/* Responsive design adjustments for PageGen */
@media (max-width: 768px) {
  .pagegen-image-container,
  .pagegen-molecule-container,
  .pagegen-pdf-container,
  .pagegen-chart-container {
    margin: 15px 0;
  }
  
  .pagegen-title {
    padding: 8px;
    font-size: 0.9rem;
  }
  
  .pagegen-content {
    padding: 8px;
  }
  
  .pagegen-chart-container .pagegen-content {
    padding: 15px;
  }
  
  .pagegen-molecule-viewer {
    height: 300px;
  }
  
  .pagegen-pdf {
    height: 400px;
  }
}

@media (max-width: 480px) {
  .pagegen-molecule-viewer {
    height: 250px;
  }
  
  .pagegen-pdf {
    height: 300px;
  }
  
  .pagegen-title {
    font-size: 0.85rem;
    padding: 6px;
  }
}

/* Print styles for PageGen elements */
@media print {
  .pagegen-image-container,
  .pagegen-molecule-container,
  .pagegen-pdf-container,
  .pagegen-chart-container {
    break-inside: avoid;
    margin: 10px 0;
    box-shadow: none;
  }
  
  .pagegen-molecule-viewer {
    height: 200px;
  }
  
  .pagegen-pdf {
    height: 300px;
  }
  
  .pagegen-title {
    background: white !important;
    color: black !important;
  }
}