/* ========================================
   Sinapax PACS - PDF Theme for Marp
   Optimized for A4 printing and long reading
   Brand Colors: #0056a7 (Blue), #2c3e50 (Dark)
   ======================================== */

/* ===== FONT IMPORTS ===== */
@font-face {
  font-family: 'IRANSansWeb';
  src: url('/assets/fonts/IRANSansWeb.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'BTitrBd';
  src: url('/assets/fonts/BTitrBd.ttf') format('truetype');
  font-display: swap;
}

@font-face {
  font-family: 'BNazanin';
  src: url('/assets/fonts/BNazanin.woff') format('woff');
  font-display: swap;
}

@font-face {
  font-family: 'IranSansDN';
  src: url('/assets/fonts/iransansdn.woff2') format('woff2');
  font-display: swap;
}

/* ===== BASE - A4 OPTIMIZED ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

section {
  font-family: 'IRANSansWeb', 'Segoe UI', sans-serif;
  direction: rtl;
  background: #ffffff;
  color: #2c3e50;
  font-size: 1rem;
  line-height: 1.6;
  padding: 20px 60px;
  page-break-after: always;
  box-shadow: none;
  /* Disable animations for PDF */
  animation: none !important;
}

/* ===== HEADINGS ===== */
h1 {
  font-family: 'BTitrBd', 'IRANSansWeb', sans-serif;
  font-size: 2.0rem;
  color: #0056a7;
  margin-bottom: 8px;
  text-align: center;
  page-break-after: avoid;
}

h2 {
  font-family: 'BTitrBd', 'IRANSansWeb', sans-serif;
  font-size: 1.7rem;
  color: #0056a7;
  padding-bottom: 5px;
  margin-bottom: 5px;
  margin-top: 15px;
  page-break-after: avoid;
}

h3 {
  font-family: 'BTitrBd', 'IRANSansWeb', sans-serif;
  font-size: 1.3rem;
  color: #2c3e50;
  margin: 15px 0 5px 0;
  page-break-after: avoid;
}

h4 {
  font-family: 'IRANSansWeb', sans-serif;
  font-size: 1.1rem;
  color: #0056a7;
  font-weight: bold;
  margin: 12px 0 6px 0;
  page-break-after: avoid;
}

/* ===== TEXT ===== */
p {
  font-size: 1.1rem;
  padding-right: 5px;
  text-align: justify;
  margin-bottom: 8px;
  orphans: 3;
  widows: 3;
}

ul, ol {
  font-size: 1.05rem;
  padding-right: 35px;
  margin-bottom: 10px;
  orphans: 3;
  widows: 3;
}

ul li, ol li {
  margin-bottom: 4px;
}

a {
  color: #0056a7;
  text-decoration: none;
  font-weight: bold;
  border-bottom: 1px solid #0056a7;
}

/* ===== LEAD SLIDE (Title Page) ===== */
section.lead {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

section.lead h1 {
  font-size: 3rem;
  margin-bottom: 10px;
}

section.lead h2 {
  font-family: 'BNazanin', 'IRANSansWeb', sans-serif;
  font-size: 2rem;
  color: #2c3e50;
  border-bottom: none;
  margin-bottom: 15px;
}

section.lead p {
  font-family: 'IranSansDN', 'IRANSansWeb', sans-serif;
  font-size: 1.2rem;
  color: #555;
  text-align: center;
}

/* ===== TABLES ===== */
table {
  font-size: 0.9rem;
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  page-break-inside: avoid;
}

th {
  background: #0056a7;
  color: #ffffff;
  font-weight: bold;
  padding: 10px 12px;
  text-align: center;
}

td {
  padding: 8px 12px;
  text-align: center;
  border-bottom: 1px solid #dee2e6;
}

tr:nth-child(even) { 
  background: #f8f9fa; 
}

/* ===== IMAGES ===== */
img {
  max-width: 85%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  padding: 4px;
  page-break-inside: avoid;
  display: block;
  margin: 10px auto;
}

/* ===== CODE ===== */
code {
  font-family: 'Courier New', monospace;
  background: #f1f3f5;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #0056a7;
}

pre {
  background: #f1f3f5;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  font-size: 0.85rem;
  page-break-inside: avoid;
}

/* ===== BLOCKQUOTE ===== */
blockquote {
  font-family: 'BNazanin', 'IRANSansWeb', sans-serif;
  font-size: 1.1rem;
  color: #2c3e50;
  border-right: 5px solid #0056a7;
  padding: 12px 20px;
  margin: 15px 0;
  background: #f0f7ff;
  border-radius: 6px;
  page-break-inside: avoid;
}

/* ===== PAGE NUMBER ===== */
section::after {
  font-size: 0.75rem;
  color: #6c757d;
  content: "صفحه " attr(data-marpit-pagination) " از " attr(data-marpit-pagination-total);
  position: absolute;
  bottom: 15px;
  left: 30px;
  right: 30px;
  text-align: center;
  border-top: 1px solid #dee2e6;
  padding-top: 10px;
}

/* ===== LAYOUTS ===== */

/* Two Column - PDF Optimized */
.columns {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  align-items: start;
  margin-top: 5px;
  page-break-inside: avoid;
}

.columns .left {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.columns .right {
  display: flex;
  justify-content: center;
  align-items: center;
}

.columns .right img {
  max-width: 100%;
  max-height: 450px;
}

/* Full Image - PDF Optimized */
section.full-image {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

section.full-image img {
  max-width: 80%;
  max-height: 500px;
  margin: 10px auto;
}

/* Horizontal (Text above, Image below) - PDF Optimized */
section.horizontal {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

section.horizontal .content {
  text-align: center;
  margin-bottom: 15px;
}

section.horizontal .content h2 {
  border-bottom: none;
  margin-bottom: 5px;
}

section.horizontal .content p {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 0;
  text-align: center;
}

section.horizontal img {
  max-width: 80%;
  max-height: 400px;
  margin: 0 auto;
}

img.emoji {
  display: inline-block !important;
  width: 1.2em !important;
  height: 1.2em !important;
  min-width: 1.2em !important;
  min-height: 1.2em !important;
  vertical-align: middle !important;
  margin: 0 0.1em !important;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  position: relative !important;
  top: -0.1em !important;
}


/* ===== PRINT OPTIMIZATIONS ===== */
@media print {
  section {
    background: #ffffff !important;
    box-shadow: none !important;
    padding: 15px 50px !important;
    page-break-after: always;
  }

  img {
    box-shadow: none !important;
    break-inside: avoid;
  }

  table, pre, blockquote, ul, ol {
    break-inside: avoid;
  }

  h1, h2, h3, h4 {
    break-after: avoid;
  }

  /* Remove animations */
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  section {
    padding: 15px 25px;
    font-size: 0.9rem;
    width: 100%;
    min-height: auto;
  }

  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.2rem; }
  table { font-size: 0.75rem; }
  td, th { padding: 5px 8px; }
  img { max-width: 100%; }

  .columns {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .columns .right img {
    max-height: 300px;
  }
}