/* ==========================================================================
   Stylesheet Khusus Cetak Buku Induk Siswa MI (Standar Nasional Kemenag)
   Ukuran: Folio (F4 - 215x330mm) / A4 (210x297mm)
   Batas Jilid: Margin Kiri 20mm untuk Penjilidan Hard Cover
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tinos:ital,wght@0,400;0,700;1,400&family=Inter:wght@400;500;600;700&display=swap');

/* Screen Preview Environment */
body.cetak-body {
  background-color: #334155;
  margin: 0;
  padding: 0;
  font-family: 'Tinos', 'Times New Roman', Times, serif;
  color: #000000;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Floating Toolbar (Layar Monitor Saja) */
.cetak-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  font-family: 'Inter', sans-serif;
}

.cetak-toolbar-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.cetak-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cetak-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.2s;
}

.cetak-btn-print {
  background: #10b981;
  color: #ffffff;
}
.cetak-btn-print:hover {
  background: #059669;
}

.cetak-btn-back {
  background: #475569;
  color: #ffffff;
}
.cetak-btn-back:hover {
  background: #64748b;
}

.cetak-select {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  background: #1e293b;
  color: #ffffff;
  border: 1px solid #475569;
  font-size: 0.85rem;
  outline: none;
}

/* Container Lembar Kertas */
.cetak-paper-container {
  padding: 80px 20px 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

/* Lembar Buku Induk Fisik */
.sheet {
  background: #ffffff;
  width: 215mm;
  min-height: 330mm;
  padding: 15mm 15mm 15mm 20mm; /* Kiri 20mm untuk space jilid */
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  position: relative;
  page-break-after: always;
}

/* Kop Resmi Madrasah */
.kop-surat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2.5px solid #000000;
  padding-bottom: 8px;
  margin-bottom: 15px;
}

.kop-logo {
  width: 65px;
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kop-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.kop-text {
  flex: 1;
  text-align: center;
  padding: 0 10px;
}

.kop-text h4 {
  font-size: 11pt;
  font-weight: 700;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.2;
}

.kop-text h2 {
  font-size: 15pt;
  font-weight: 800;
  text-transform: uppercase;
  margin: 2px 0;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

.kop-text p {
  font-size: 8.5pt;
  margin: 0;
  line-height: 1.3;
}

/* Judul Lembar */
.sheet-title {
  text-align: center;
  margin-bottom: 15px;
}

.sheet-title h3 {
  font-size: 12pt;
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: underline;
  margin: 0;
}

.sheet-title p {
  font-size: 9pt;
  margin: 2px 0 0 0;
}

/* Tabel Biodata (Lembar A) */
.table-biodata {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5pt;
  line-height: 1.35;
}

.table-biodata td {
  padding: 2.5px 4px;
  vertical-align: top;
}

.table-biodata td.section-header {
  font-weight: 700;
  background-color: #f1f5f9;
  border-top: 1px solid #000000;
  border-bottom: 1px solid #000000;
  padding: 4px;
  text-transform: uppercase;
  font-size: 9.5pt;
}

.table-biodata td.num {
  width: 25px;
  text-align: center;
}

.table-biodata td.sub-num {
  width: 20px;
  text-align: right;
  padding-right: 6px;
}

.table-biodata td.label {
  width: 220px;
}

.table-biodata td.sep {
  width: 10px;
  text-align: center;
}

.table-biodata td.val {
  font-weight: 600;
}

/* Kotak Pas Foto 3x4 */
.photo-box {
  width: 30mm;
  height: 40mm;
  border: 1px solid #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8pt;
  color: #64748b;
  text-align: center;
  background: #fafafa;
}

/* Tabel Nilai & Kehadiran (Lembar B & C) */
.table-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5pt;
  margin-top: 8px;
}

.table-grid th, .table-grid td {
  border: 1px solid #000000;
  padding: 4px 5px;
  text-align: center;
  vertical-align: middle;
}

.table-grid th {
  background-color: #f8fafc;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 8pt;
}

.table-grid td.text-left {
  text-align: left;
}

.table-grid td.bold {
  font-weight: 700;
}

/* Bagian Tanda Tangan */
.signature-section {
  margin-top: 25px;
  display: flex;
  justify-content: space-between;
  font-size: 9.5pt;
  page-break-inside: avoid;
}

.sig-box {
  text-align: center;
  width: 220px;
}

.sig-space {
  height: 60px;
}

.sig-name {
  font-weight: 700;
  text-decoration: underline;
}

.sheet-footer {
  position: absolute;
  bottom: 8mm;
  left: 20mm;
  right: 15mm;
  display: flex;
  justify-content: space-between;
  font-size: 7.5pt;
  color: #64748b;
  border-top: 0.5px solid #cbd5e1;
  padding-top: 3px;
}

/* ==========================================================================
   PRINT MEDIA RULES (Otomatis Aktif Saat Tombol Cetak / Ctrl+P Ditekan)
   ========================================================================== */
@media print {
  @page {
    size: 215mm 330mm; /* Folio / F4 */
    margin: 0;
  }
  
  body.cetak-body {
    background: #ffffff !important;
  }
  
  .cetak-toolbar {
    display: none !important;
  }
  
  .cetak-paper-container {
    padding: 0 !important;
    gap: 0 !important;
  }
  
  .sheet {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 15mm 15mm 15mm 20mm !important;
    page-break-after: always !important;
    width: 215mm !important;
    height: 330mm !important;
    overflow: hidden;
  }
  
  .table-biodata td.section-header,
  .table-grid th {
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
