@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("/assets/vendor/urdu/NotoNaskhArabic-Regular.ttf") format("truetype");
  font-display: swap;
}

/* Print-friendly A4 layout */
@page {
  size: A4;
  margin: 15mm;
}

@media print {
  /* Hide everything except the paper content */
  body * {
    visibility: hidden;
  }
  
  .print-paper,
  .print-paper * {
    visibility: visible;
  }
  
  .print-paper {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  body {
    background: #fff !important;
    font-size: 12pt;
    line-height: 1.4;
    margin: 0;
    padding: 0;
  }

  /* Hide all wizard elements */
  .pm-wizard-header,
  .pm-progress-tracker,
  .pm-step-content > .d-flex:first-child,
  .no-print,
  .btn,
  #pmEditorToolbar,
  .pm-step-content > h2 {
    display: none !important;
    visibility: hidden !important;
  }

  .print-paper {
    box-shadow: none !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-paper.card {
    border: none !important;
    box-shadow: none !important;
  }

  .print-paper .card-body {
    border: none !important;
    padding: 0 !important;
  }

  .card-body {
    padding: 0 !important;
  }

  a[href]:after {
    content: "";
  }

  /* Paper header: match on-screen Step 6 rules (same CSS variables, no extra table-layout/font overrides). */
  #pmPaperContent .pm-header-wrap {
    overflow-x: visible !important;
    max-width: none !important;
  }

  #pmPaperContent .pm-header-wrap .pm-paper-header,
  #pmPaperContent .pm-header-wrap .pm-paper-header td,
  #pmPaperContent .pm-header-wrap .pm-paper-header th {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Stacked label + rule line (layout 1): ensure rule prints */
  #pmPaperContent .pm-header-wrap .pm-paper-header .pm-hd-stack-line {
    border-bottom-color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Tables inside question HTML only (nested tables inside the header are not .pm-paper-header) */
  #pmPaperContent .paper-questions table:not(.pm-paper-header) {
    border-collapse: collapse !important;
    width: 100% !important;
  }

  #pmPaperContent .paper-questions table:not(.pm-paper-header) td {
    border: 1px solid #000 !important;
    padding: 8px !important;
  }

  /* Question formatting */
  .q-row {
    page-break-inside: avoid;
    margin-bottom: 15px !important;
  }

  #pmPaperContent .paper-questions .q-text,
  #pmPaperContent .paper-questions .q-num,
  #pmPaperContent .paper-questions .q-marks {
    font-size: var(--pm-question-font-size, 14px) !important;
  }

  #pmPaperContent .paper-questions .q-text .pm-q-image-wrap {
    display: block !important;
    width: 100% !important;
    clear: both !important;
    margin-top: 0.35em !important;
  }

  #pmPaperContent .paper-questions .q-text .pm-q-image-wrap img {
    display: block !important;
    max-width: 100% !important;
    max-height: 160px !important;
    object-fit: contain !important;
  }

  /* Instruction headings — same variable as screen Step 6 */
  #pmPaperContent .pm-instruction-heading {
    font-size: var(--pm-heading-font-size, 16px) !important;
    font-weight: bold !important;
  }

  #pmPaperContent .pm-section-part-heading {
    text-align: center !important;
    font-size: var(--pm-heading-font-size, 16px) !important;
  }

  /* School logo: one layer per Objective / Subjective section (inline opacity on img for reliable print) */
  #pmPaperContent .pm-paper-questions-section {
    position: relative !important;
    isolation: auto !important;
  }

  #pmPaperContent .pm-paper-questions-section > .pm-paper-watermark {
    visibility: visible !important;
    display: flex !important;
    overflow: visible !important;
    z-index: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #pmPaperContent .pm-paper-questions-section > .pm-paper-watermark img,
  #pmPaperContent .pm-paper-wm-logo {
    visibility: visible !important;
    display: block !important;
    max-height: 200mm !important;
    min-height: 40px !important;
    width: auto !important;
    height: auto !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .paper-footer {
    page-break-inside: avoid;
    margin-top: 30px !important;
  }
}

.paper-header {
  display: grid;
  grid-template-columns: 120px 1fr 200px;
  gap: 12px;
  align-items: center;
  border-bottom: 2px solid #111;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.paper-header .school-name {
  text-align: center;
  font-weight: 800;
  font-size: 20px;
  line-height: 1.1;
}

.paper-header .school-address {
  text-align: center;
  font-size: 12px;
  color: #444;
}

.paper-header .paper-meta {
  font-size: 12px;
  text-align: right;
}

.q-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 15px;
  page-break-inside: avoid;
}

.q-row.pm-spacing-compact {
  margin-bottom: 8px;
}

.q-row.pm-spacing-relaxed {
  margin-bottom: 24px;
}

.pm-answer-lines {
  margin-top: 10px;
}

.pm-answer-line {
  height: 24px;
  border-bottom: 1px solid #555;
}

#pmPaperContent {
  max-width: 210mm;
  margin: 0 auto;
  background: #fff;
}

.q-num {
  width: 30px;
  font-weight: 700;
  flex-shrink: 0;
}

.q-text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
}

.q-marks {
  width: 60px;
  text-align: right;
  font-weight: 700;
  flex-shrink: 0;
}

/* Tables inside question body only — never target .pm-paper-header or the whole card can clip / mis-layout on screen */
.print-paper .paper-questions table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.print-paper .paper-questions table td {
  border: 1px solid #000;
  padding: 8px;
  vertical-align: top;
}

.print-paper .paper-questions table td strong {
  font-weight: 600;
}

/* Instructions styling */
.print-paper .mb-3[style*="font-weight: bold"] {
  font-weight: bold !important;
  margin-bottom: 15px !important;
  margin-top: 20px !important;
}

/* Footer styling */
.paper-footer {
  border-top: 1px solid #ddd;
  margin-top: 40px;
  padding-top: 20px;
  font-size: 11pt;
}

/* Dynamic eight-template paper system */
.paper-template { color:#111; font-size:var(--pt-font-size,12px); line-height:1.42; padding:8mm; border:2px solid #1c2d4a; counter-reset:page; }
.pt-border-none { border:0; }.pt-border-double { border:5px double #1c2d4a; }.pt-border-dashed { border:2px dashed #1c2d4a; }
.pt-header { display:grid; grid-template-columns:70px 1fr 150px; gap:12px; align-items:center; border-bottom:2px solid currentColor; padding-bottom:9px; margin-bottom:10px; }
.pt-header.pt-align-left .pt-school-identity { text-align:left; }.pt-header.pt-align-right .pt-school-identity { text-align:right; }.pt-header.pt-align-center .pt-school-identity { text-align:center; }
.pt-logo { width:62px; height:62px; display:flex; align-items:center; justify-content:center; font-weight:800; color:#203a5f; }.pt-logo img { display:block; max-width:100%; max-height:100%; width:auto; height:auto; object-fit:contain; }
.pt-logo-fallback { font-size:15px; }.pt-school-name { font-size:1.7em; line-height:1.05; font-weight:900; text-transform:uppercase; }.pt-exam-type { font-size:1.12em; font-weight:800; margin-top:3px; }.pt-session { font-weight:700; letter-spacing:.04em; }.pt-summary { border-left:1px solid #999; padding-left:8px; font-size:.9em; }.pt-summary span { display:block; }
.pt-student-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); border:1px solid #555; margin:9px 0; }.pt-field { min-height:28px; padding:5px 7px; border:solid #aaa; border-width:0 1px 1px 0; display:flex; gap:5px; }.pt-field span { flex:1; border-bottom:1px dotted #555; min-width:25px; }
.pt-instructions { border-left:4px solid #234b78; background:#f4f7fb; padding:7px 9px; margin:10px 0 14px; }.pt-instructions strong { display:block; text-transform:uppercase; font-size:.9em; }
.pt-section { break-inside:auto; }.pt-section-heading { display:flex; justify-content:space-between; align-items:center; margin:16px 0 9px; font-size:1.08em; font-weight:800; }.pt-heading-bar { color:#fff; background:#203a5f; padding:6px 9px; }.pt-heading-line { border-bottom:2px solid #203a5f; padding-bottom:4px; }.pt-heading-boxed { border:1px solid #203a5f; padding:6px 9px; }.pt-heading-minimal { text-transform:uppercase; letter-spacing:.08em; }
.pt-options { margin:6px 0 0; padding-inline-start:22px; }.pt-options[dir="rtl"] { padding-inline-start:0; padding-inline-end:26px; text-align:right; }.pt-question-text { text-align:left; unicode-bidi:plaintext; }.pt-urdu { font-family:"Noto Nastaliq Urdu","Noto Naskh Arabic",serif; text-align:right; font-size:1.12em; margin-top:4px; }.q-row.q-rtl { flex-direction:row-reverse; }.q-row.q-rtl .q-num,.q-row.q-rtl .q-text { text-align:right; }.q-row.q-rtl .q-marks { text-align:left; }.pt-subquestions { margin:5px 0; padding-inline-start:24px; }.q-rtl .pt-subquestions { padding-inline-start:0; padding-inline-end:26px; }.pt-question-table { margin-top:8px; }.pt-question-table td[dir="rtl"] { text-align:right; }.paper-template .pm-q-image-wrap img { max-width:100%; max-height:190px; object-fit:contain; display:block; margin:6px 0; }
.paper-template .paper-footer { display:flex; justify-content:space-between; border-top:1px solid #777; margin-top:18px; padding-top:7px; font-size:.9em; }.pt-page-current:after { content:counter(page); }
.pt-board-style .pt-header, .pt-grid-box .pt-header { border:1px solid #111; padding:9px; }.pt-board-style .pt-student-fields, .pt-grid-box .pt-student-fields { grid-template-columns:repeat(3,minmax(0,1fr)); }.pt-board-style .pt-section-heading { background:#eee; color:#111; border:1px solid #111; }.pt-grid-box .q-row { border:1px solid #999; padding:7px; }.pt-grid-box .pt-section-heading { background:#fff; color:#111; border:2px solid #111; }
.pt-modern-professional { border-color:#286a74; }.pt-modern-professional .pt-section-heading { background:#286a74; }.pt-objective-subjective .pt-section-heading { background:#3d2366; }.pt-bilingual { border-color:#386641; }.pt-bilingual .pt-section-heading { background:#386641; }.pt-minimal-clean { border-width:1px; }.pt-minimal-clean .pt-header { grid-template-columns:55px 1fr 130px; }.pt-minimal-clean .pt-section-heading { background:transparent; color:#111; border-bottom:1px solid #111; }.pt-premium-branded { border:6px double #845d24; }.pt-premium-branded .pt-header { border-bottom-color:#845d24; }.pt-premium-branded .pt-section-heading { background:#845d24; }

/* Template cards on the settings step */
.pt-select-card { display:block; cursor:pointer; border:1px solid #d0d7e2; border-radius:12px; padding:9px; height:100%; transition:.15s; }.pt-select-card:hover,.pt-select-card.is-selected { border-color:#315ad4; box-shadow:0 0 0 2px #dce7ff; }.pt-mini { min-height:92px; display:flex; flex-direction:column; gap:4px; padding:10px; border:2px solid #203a5f; color:#203a5f; background:#fff; }.pt-mini i { width:18px; height:18px; border:1px solid currentColor; border-radius:50%; }.pt-mini b { font-size:13px; }.pt-mini em { font-size:10px; font-style:normal; }.pt-mini.pt-board-style,.pt-mini.pt-grid-box { border-style:double; }.pt-mini.pt-modern-professional { border-color:#286a74; }.pt-mini.pt-objective-subjective { border-color:#3d2366; }.pt-mini.pt-bilingual { border-color:#386641; direction:rtl; }.pt-mini.pt-minimal-clean { border-width:1px; color:#222; }.pt-mini.pt-premium-branded { border:4px double #845d24; color:#845d24; }.pt-select-name { display:block; font-weight:700; margin-top:7px; }

@media print {
  @page { size:A4 portrait; margin:12mm; }
  .paper-template { width:auto !important; max-width:none !important; padding:0 !important; border-color:#111; font-size:var(--pt-font-size,12px) !important; }
  .paper-template .q-row, .paper-template .pt-student-fields, .paper-template .pt-instructions, .paper-template .pt-section-heading { break-inside:avoid; page-break-inside:avoid; }
  .paper-template .pt-section-heading { break-after:avoid; page-break-after:avoid; }
  .paper-template .pm-q-image-wrap img { max-height:150px !important; }
  .paper-template .paper-footer { position:running(paper-footer); }
}


