/* print.css: mesin dokumen. Semua satuan dalam cm supaya identik di layar & di cetak. */

:root {
  --m-top: 3cm;
  --m-right: 3cm;
  --m-bottom: 3cm;
  --m-left: 4cm;
  --doc-font: "Times New Roman", Times, "Liberation Serif", serif;
}

@page { size: A4; margin: 0; }

.sheets { transform-origin: 0 0; }

.sheet {
  position: relative;
  box-sizing: border-box;
  width: 21cm;
  height: 29.7cm;
  padding: var(--m-top) var(--m-right) var(--m-bottom) var(--m-left);
  margin: 0 0 14px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .28);
}

.pg-body {
  height: 23.7cm;
  overflow: hidden;
  font-family: var(--doc-font);
  font-size: 12pt;
  line-height: 1.5;
  color: #000;
}
.pg-body > :first-child { margin-top: 0; }

.sheets.building { position: fixed; top: 0; left: -20000px; visibility: hidden; }

.para { margin: 0; text-indent: 1.2cm; text-align: justify; }
.no-indent { text-indent: 0; }
.h-bab { margin: 0; font-weight: 700; text-align: center; text-transform: uppercase; }
.h-bab .line { display: block; }
.h-bab.bab-new { margin-top: 12pt; }
.h-sub { margin: 12pt 0 6pt; font-weight: 700; text-align: left; }
.li { margin: 0; margin-left: 1.5cm; text-indent: -1.5cm; text-align: justify; }
.ref { margin: 0 0 6pt 1.5cm; text-indent: -1.5cm; text-align: justify; }
.empty-slot { margin: 0; color: #666; font-style: italic; }

/* ---------- cover ---------- */
.cover .pg-body {
  display: flex;
  flex-direction: column;
  text-align: center;
}
.cover .pg-body > p {
  margin: 0;
  padding: 0;
  text-indent: 0;
  text-align: center;
}
.cover .c-jenis {
  margin: 0 0 10pt !important;
  font-size: 12pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.cover .c-judul {
  margin: 0 !important;
  font-size: 16pt;
  line-height: 1.35;
  font-weight: 700;
  text-transform: uppercase;
}
.cover .c-sub {
  margin-top: 3pt !important;
  font-style: italic;
}
.cover .c-siswa {
  margin-top: 2pt !important;
  font-weight: 700;
  line-height: 1.25;
}
.cover .c-member-compact {
  font-size: 11pt;
  margin-top: 1pt !important;
}
.cover .c-anggota {
  margin-top: 1pt !important;
  line-height: 1.25;
}
.cover .c-kampus {
  margin-top: 2pt !important;
  font-weight: 700;
}
.cover .campus-dosen-label { margin-top: 3pt !important; }
.cover .campus-dosen { font-weight: 700; }
.cover .campus-oleh { margin-top: 0 !important; font-weight: 700; }
.cover .campus-date { font-weight: 700; }

/* SMA: kelas → sekolah → kota → tahun ajaran menempel di dasar halaman. */
.cover.sma .sma-bottom-start {
  margin-top: auto !important;
  padding-top: 12pt;
}
.cover.sma .cover-tahun {
  margin-top: 2pt !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Kuliah: identitas (prodi/fakultas/institusi/kota) menempel di dasar halaman. */
.cover.kampus .campus-bottom-start {
  margin-top: auto !important;
  padding-top: 12pt;
}
.cover.kampus .campus-gap-1 { height: 28pt; }
.cover.kampus .logo { margin: 46pt 0 42pt; }
.cover.kampus .campus-bottom-gap { height: 48pt; }
.cover.kampus .campus-members-4,
.cover.kampus .campus-members-5,
.cover.kampus .campus-members-6,
.cover.kampus .campus-members-7,
.cover.kampus .campus-members-8 { height: 28pt; }

.cover .logo { width: 100%; }
/* SMA: jarak ~30px antara logo dan teks atas/bawah */
.cover.sma .logo {
  margin: 30px 0 30px !important;
}
.cover .logo img {
  display: block;
  margin: 0 auto;
  width: 4.8cm;
  height: 4.8cm;
  object-fit: contain;
}
.cover .logo-sma img { width: 4.8cm; height: 4.8cm; }
.cover .logo-sma.logo-count-5 img,
.cover .logo-sma.logo-count-6 img { width: 4.2cm; height: 4.2cm; }
.cover .logo-sma.logo-count-7 img { width: 3.6cm; height: 3.6cm; }
.cover .logo-kampus img { width: 3.8cm; height: 3.8cm; }

.cover .logo .logo-ph {
  margin: 0 auto;
  width: 4.8cm;
  height: 4.8cm;
  border: 1px dashed #999;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: pre-line;
  text-align: center;
  font-size: 8pt;
  color: #666;
  letter-spacing: .02em;
}
.cover.kampus .logo .logo-ph {
  width: 3.8cm;
  height: 3.8cm;
}

.cover .gap-1 { height: 7pt; }
.cover .gap-2 { height: 6pt; }
.cover .gap-3 { height: 10pt; }

.cover-arab { font-size: 14pt; line-height: 1.6; margin: 0 0 6pt; }
.sign { text-align: right; text-indent: 0; margin: 0; }
.sign-space { height: 48pt; }
.sign-name { text-decoration: underline; }

/* ---------- daftar isi ---------- */
.toc-item {
  display: flex;
  align-items: baseline;
  gap: 0;
  margin: 0;
  text-indent: 0;
  text-align: left;
}
.toc-item .toc-label {
  flex: 0 1 auto;
  min-width: 0;
  max-width: calc(100% - 1.6cm);
  overflow-wrap: anywhere;
  line-height: 1.5;
  padding-right: 0.15cm;
}
.toc-item .toc-dots {
  flex: 1 1 0.8cm;
  min-width: 0.8cm;
  height: 0;
  border-bottom: 1.2px dotted #000;
  align-self: baseline;
  position: relative;
  top: -0.35em;
  margin: 0 0.12cm;
}
.toc-item .toc-page {
  flex: none;
  min-width: 0.5cm;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-left: 0.1cm;
}
.toc-item.lvl-2 { padding-left: 1.2cm; }

.pgnum {
  position: absolute;
  font-family: var(--doc-font);
  font-size: 12pt;
  color: #000;
}
.pgnum.bottom {
  top: auto !important;
  bottom: 0.8cm !important;
  left: 0 !important;
  right: 0 !important;
  width: 100%;
  text-align: center;
}

@media print {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    height: auto !important;
    width: auto !important;
    overflow: visible !important;
  }
  #viewDash, .appbar, .tabbar, #paneForm, .zoombar, #toast,
  .ai-overlay, #checklist, .form-note, .editor-appbar-inner { display: none !important; }
  #viewEditor, #panePaper, #paperWrap, #sheets {
    display: block !important;
    position: static !important;
    transform: none !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    max-width: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
  .sheets.building { position: static !important; left: auto !important; visibility: visible !important; }

  /*
   * KUNCI anti-halaman-kosong:
   * pakai page-break-BEFORE pada sheet ke-2 dst, BUKAN page-break-after.
   * page-break-after:always di sheet terakhir sering memicu halaman blank di Chrome/Android.
   */
  .sheet {
    box-shadow: none !important;
    margin: 0 !important;
    width: 21cm !important;
    height: 29.7cm !important;
    max-height: 29.7cm !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: auto !important;
    break-after: auto !important;
    page-break-before: auto !important;
    break-before: auto !important;
  }
  .sheet + .sheet {
    page-break-before: always !important;
    break-before: page !important;
  }
}
