/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Times New Roman', Times, serif;
  font-size: 12pt;
  background: #e0e0e0;
  color: #000;
}

/* ── PAGE WRAPPER (simulasi kertas A4) ── */
.page {
  width: 210mm;
  min-height: 297mm;
  margin: 20px auto;
  background: #fff;
  padding: 20mm 20mm 20mm 25mm;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

/* ═══════════════════════════════════════
   HEADER KHUSUS MATERI AJAR
   ═══════════════════════════════════════ */

.materi-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 3px double #1a1a1a;
}

/* ── Title Block: Color block biru gradasi ── */
.materi-judul-utama {
  font-size: 15pt;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 10px 20px;
  color: #fff;
  background: linear-gradient(135deg, #1a3a5f 0%, #2c5282 100%);
  border-radius: 4px;
}

.materi-judul-sub {
  font-size: 9.5pt;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
  padding: 5px 14px;
  color: #1a3a5f;
  background: #eef5fb;
  border: 1px solid #c4d9eb;
  border-radius: 3px;
  display: inline-block;
  width: auto;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* ── COMPACT META — inline flow, ringkas ── */
.materi-meta-compact {
  font-size: 7.5pt;
  line-height: 1.7;
  margin-bottom: 4px;
  color: #333;
}

.materi-meta-item {
  display: inline;
  margin-right: 4px;
  white-space: normal;
}

.materi-meta-label {
  font-weight: 700;
  color: #1a1a1a;
}

.materi-meta-label::after {
  content: ': ';
  font-weight: 700;
}

.materi-meta-value {
  color: #444;
}

.materi-meta-item::after {
  content: '\A0\B7\A0';
  color: #94a3b8;
  font-weight: normal;
}

.materi-meta-item:last-child::after {
  content: '';
}

.materi-pemahaman {
  background: #eff6ff;
  padding: 6px 12px;
  border-left: 3px solid #2563eb;
  font-style: italic;
  font-size: 9pt;
  margin: 6px 0 2px;
  line-height: 1.5;
  color: #1e3a5f;
  border-radius: 0 3px 3px 0;
}

.materi-pemahaman strong {
  font-style: normal;
}

/* ═══════════════════════════════════════
   SECTION DIVIDER
   ═══════════════════════════════════════ */

.materi-section-divider {
  font-size: 13pt;
  font-weight: bold;
  text-align: center;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 20px 0 14px;
  padding: 8px 0;
  border-top: 2px solid #2c5282;
  border-bottom: 1px solid #94a3b8;
  color: #1e3a5f;
  background: #f1f5f9;
}

/* ═══════════════════════════════════════
   PERTEMUAN
   ═══════════════════════════════════════ */

.materi-pertemuan-header {
  font-size: 13pt;
  font-weight: bold;
  margin: 18px 0 10px;
  padding-bottom: 4px;
  border-bottom: 2px solid #2c5282;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: #1a3a5f;
}

.materi-pertemuan-header span {
  font-size: 10pt;
  font-weight: normal;
  color: #555;
}

.materi-fokus {
  font-size: 10pt;
  font-style: italic;
  color: #555;
  margin-bottom: 8px;
}

.materi-tujuan {
  margin: 6px 0 10px 18px;
  font-size: 11pt;
  line-height: 1.6;
}

.materi-tujuan li {
  margin-bottom: 3px;
}

/* ═══════════════════════════════════════
   BAB — Accent bar kiri biru tua
   ═══════════════════════════════════════ */

.materi-bab {
  margin: 14px 0;
}

.materi-bab-judul {
  font-size: 12pt;
  font-weight: 700;
  margin: 12px 0 8px;
  padding: 4px 0 4px 12px;
  border-left: 4px solid #2c5282;
  color: #1e3a5f;
  background: #f0f5fb;
  border-radius: 0 3px 3px 0;
}

.materi-teks {
  margin-bottom: 8px;
}

.materi-teks p {
  text-align: justify;
  margin: 0 0 8px;
  text-indent: 1.5em;
  line-height: 1.7;
}

/* ═══════════════════════════════════════
   SUB BAB — Accent bar kiri biru medium
   ═══════════════════════════════════════ */

.materi-sub-bab {
  margin: 10px 0 8px 14px;
  padding-left: 12px;
  border-left: 3px solid #3b82f6;
}

.materi-sub-bab-judul {
  font-weight: 700;
  margin: 8px 0 4px;
  font-size: 11pt;
  color: #1e40af;
}

.materi-sub-bab-penjelasan p {
  text-align: justify;
  margin: 0 0 6px;
  text-indent: 1.5em;
  font-size: 11pt;
  line-height: 1.6;
}

.materi-poin {
  margin: 4px 0 6px 18px;
  font-size: 11pt;
  line-height: 1.6;
}

/* ── Contoh: aksen kuning/oranye ── */
.materi-contoh {
  background: #fef9ee;
  border-left: 3px solid #f59e0b;
  border-radius: 0 4px 4px 0;
  padding: 6px 12px;
  margin: 8px 0;
  font-size: 10.5pt;
  font-style: italic;
  color: #333;
  line-height: 1.5;
  break-inside: avoid;
}

.materi-contoh-label {
  font-weight: 700;
  font-style: normal;
  font-size: 10pt;
  color: #b45309;
}

/* ═══════════════════════════════════════
   GAMBAR PLACEHOLDER — page-break safety
   ═══════════════════════════════════════ */

.placeholder-gambar {
  border: 2px dashed #94a3b8;
  border-radius: 4px;
  padding: 16px;
  text-align: center;
  margin: 12px 0;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  break-inside: avoid;
  page-break-inside: avoid;
}

.placeholder-gambar img.gambar-upload {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.placeholder-desc {
  font-size: 10pt;
  color: #666;
  font-style: italic;
}

/* ═══════════════════════════════════════
   RANGKUMAN — aksen hijau
   ═══════════════════════════════════════ */

.materi-rangkuman {
  margin: 16px 0;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid #22c55e;
  border-radius: 0 4px 4px 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

.materi-rangkuman-judul {
  font-size: 12pt;
  font-weight: 700;
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #86efac;
  color: #166534;
}

.materi-rangkuman ul {
  margin: 0 0 0 18px;
  font-size: 11pt;
  line-height: 1.7;
}

.materi-rangkuman ul li {
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════
   REFLEKSI — aksen kuning (sudah bagus, perkuat)
   ═══════════════════════════════════════ */

.materi-refleksi {
  margin: 16px 0;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 0 4px 4px 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

.materi-refleksi-judul {
  font-size: 12pt;
  font-weight: 700;
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f59e0b;
  color: #92400e;
}

.materi-refleksi ol {
  margin: 0 0 0 18px;
  font-size: 11pt;
  line-height: 1.7;
}

.materi-refleksi ol li {
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════
   DAILY NOTE
   ═══════════════════════════════════════ */

.materi-note {
  margin: 16px 0;
  padding: 8px 12px;
  background: #f1f5f9;
  border-left: 3px solid #64748b;
  font-size: 10pt;
  color: #475569;
  font-style: italic;
  break-inside: avoid;
  page-break-inside: avoid;
}

/* ═══════════════════════════════════════
   DAFTAR PUSTAKA / GLOSARIUM
   ═══════════════════════════════════════ */

.materi-daftar-pustaka {
  margin: 16px 0;
  font-size: 10.5pt;
  line-height: 1.7;
}

.materi-daftar-pustaka-judul {
  font-size: 12pt;
  font-weight: 600;
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #1a1a1a;
}

.materi-daftar-pustaka ol {
  margin: 0 0 0 18px;
}

/* ═══════════════════════════════════════
   NATURAL PAGE FLOW — Anti paksa halaman baru
   ═══════════════════════════════════════ */

/* Heading tidak dipaksa ke halaman baru — alir natural */
.materi-section-divider,
.materi-pertemuan-header,
.materi-bab-judul,
.materi-sub-bab-judul {
  page-break-after: avoid;
  break-after: avoid;
}

/* Hindari orphans/widows pada paragraf */
.materi-teks p,
.materi-sub-bab-penjelasan p,
.materi-poin li,
.materi-tujuan li {
  orphans: 3;
  widows: 3;
}

/* ═══════════════════════════════════════
   PRINT — page-break safety untuk gambar
   ═══════════════════════════════════════ */

@media print {
  body { background: #fff; }
  .page {
    margin: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Gambar: JANGAN terpotong di pinggir halaman */
  .placeholder-gambar {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    border-color: #666 !important;
  }

  .placeholder-gambar img.gambar-upload {
    max-height: 260px;
  }

  /* Blok penting: hindari pemotongan */
  .materi-rangkuman {
    background: #f0fdf4 !important;
    border-color: #bbf7d0 !important;
    border-left-color: #22c55e !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .materi-refleksi {
    background: #fffbeb !important;
    border-color: #fde68a !important;
    border-left-color: #f59e0b !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .materi-pemahaman {
    background: #eff6ff !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .materi-contoh {
    background: #fef9ee !important;
    border-left-color: #f59e0b !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .materi-note {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* Judul bab/sub-bab tidak sendirian di bawah */
  .materi-bab-judul,
  .materi-sub-bab-judul {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* Section divider & pertemuan header tidak sendirian di bawah */
  .materi-section-divider,
  .materi-pertemuan-header {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
}
