/* ============================================================
   FORT ROAD D-I-KHAN EXAM PAPER TEMPLATE (ALL SUBJECTS + RTL)
   ============================================================ */

.exam-paper-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  color: #000000;
  padding: 14mm 17mm 16mm 17mm;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  font-family: 'Times New Roman', Times, Georgia, serif;
  font-size: var(--paper-font-size, 12pt);
  line-height: var(--paper-line-height, 1.42);
  position: relative;
}

.exam-paper-sheet.show-border {
  outline: 1.5pt solid #000;
  outline-offset: -8mm;
}

/* Urdu / Arabic / Islamiat RTL Paper Mode */
.exam-paper-sheet.rtl-mode {
  direction: rtl;
  font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', 'Urdu Typesetting', 'Traditional Arabic', 'Times New Roman', serif;
  line-height: 1.75;
}

.rtl-inline {
  direction: rtl;
  unicode-bidi: embed;
  font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', 'Urdu Typesetting', 'Traditional Arabic', serif;
}

/* Header Section — Exact Islamabad Schools (College Section) Layout with Logo */
.paper-header {
  margin-bottom: 8pt;
}

.paper-header-banner {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4pt;
}

.paper-header-banner td {
  vertical-align: top;
  padding: 0;
}

.paper-logo-cell {
  width: 68pt;
  text-align: left;
}

.paper-logo-img {
  width: 60pt;
  height: 51pt;
  object-fit: contain;
  display: block;
}

.paper-title-cell {
  text-align: center;
  padding-right: 68pt; /* balances logo cell width so title is dead-center on page */
}

.exam-paper-sheet.rtl-mode .paper-title-cell {
  padding-right: 0;
  padding-left: 68pt;
}

.paper-school-name {
  font-size: 20pt;
  font-weight: bold;
  line-height: 1.15;
  white-space: nowrap;
}

.paper-campus-line {
  font-size: 15pt;
  font-weight: bold;
  line-height: 1.25;
}

.paper-session-line {
  font-size: 13pt;
  font-weight: normal;
  line-height: 1.25;
}

/* Metadata 2-Column Table */
.paper-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 5pt;
  margin-bottom: 5pt;
  font-size: 1em;
}

.paper-meta-table td {
  padding: 2pt 0;
  vertical-align: bottom;
}

.paper-meta-table td.meta-left {
  width: 62%;
  text-align: start;
}

.paper-meta-table td.meta-right {
  width: 38%;
  text-align: start;
  padding-inline-start: 24pt;
}

.meta-label {
  font-weight: bold;
}

.meta-value {
  font-weight: normal;
}

.paper-divider {
  border: none;
  border-top: 1pt solid #000;
  margin: 5pt 0 7pt 0;
}

/* General Note / Instructions Box */
.paper-general-note {
  font-size: 0.94em;
  font-style: italic;
  margin-bottom: 6pt;
}

/* Sections */
.paper-section {
  margin-top: 8pt;
  margin-bottom: 9pt;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1pt;
}

.section-title {
  font-size: 1.05em;
  font-weight: bold;
}

.section-marks {
  font-size: 0.96em;
  font-weight: bold;
}

.section-instruction-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5pt;
}

.section-instruction {
  font-size: 1em;
  font-weight: bold;
}

/* Question Items */
.paper-questions-list {
  display: flex;
  flex-direction: column;
  gap: var(--paper-q-gap, 4.5pt);
}

.paper-question-item {
  page-break-inside: avoid;
  break-inside: avoid;
}

.q-stem-row {
  display: flex;
  align-items: baseline;
  width: 100%;
}

.q-number {
  min-width: 22pt;
  font-weight: normal;
  flex-shrink: 0;
}

.q-stem-text {
  flex: 1;
  text-align: start;
}

.q-subline {
  display: block;
  margin-top: 2pt;
  padding-inline-start: 10pt;
}

.q-item-marks {
  margin-inline-start: 10pt;
  font-weight: bold;
  white-space: nowrap;
}

/* Match the Columns Table (English, Science, Junior Classes) */
.paper-match-table {
  width: 88%;
  margin-inline-start: 22pt;
  margin-top: 4pt;
  margin-bottom: 4pt;
  border-collapse: collapse;
  font-size: 0.96em;
}

.paper-match-table th,
.paper-match-table td {
  border: 0.75pt solid #000;
  padding: 2.5pt 8pt;
  text-align: start;
  width: 50%;
}

.paper-match-table th {
  font-weight: bold;
  background: #f8f8f8;
}

/* MCQ Options Grid — Matches User Screenshot Exactly */
.mcq-options-grid {
  margin-inline-start: 22pt;
  margin-top: 2pt;
  display: grid;
  align-items: center;
  row-gap: 2.5pt;
  column-gap: 8pt;
}

.mcq-options-grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mcq-options-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mcq-options-grid.cols-1 {
  grid-template-columns: 1fr;
}

.mcq-option-cell {
  display: inline-flex;
  align-items: center;
  gap: 3.5pt;
  text-align: start;
  min-width: 0;
}

.mcq-opt-letter {
  white-space: nowrap;
  flex-shrink: 0;
}

.mcq-opt-content {
  line-height: 1.35;
}

/* ============================================================
   NATIVE HIGH-PRECISION MATH, SCIENCE & MATRIX RENDERING
   ============================================================ */

/* Bracketed Matrix: e.g. [[-1, 0, 2], [0, 3, -4]] */
.math-matrix {
  display: inline-table;
  vertical-align: middle;
  border-collapse: collapse;
  border-left: 1.2pt solid #000;
  border-right: 1.2pt solid #000;
  position: relative;
  margin: 1pt 3pt;
  padding: 0 2pt;
  font-family: 'Times New Roman', Times, serif;
  direction: ltr;
}

.math-matrix::before,
.math-matrix::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3.5pt;
  border-top: 1.2pt solid #000;
  border-bottom: 1.2pt solid #000;
  pointer-events: none;
}

.math-matrix::before {
  left: 0;
}

.math-matrix::after {
  right: 0;
}

/* Determinant vertical bars: det(a, b; c, d) */
.math-det {
  display: inline-table;
  vertical-align: middle;
  border-collapse: collapse;
  border-left: 1.2pt solid #000;
  border-right: 1.2pt solid #000;
  margin: 1pt 3pt;
  padding: 0 2pt;
  font-family: 'Times New Roman', Times, serif;
  direction: ltr;
}

.math-matrix-row {
  display: table-row;
}

.math-matrix-cell {
  display: table-cell;
  text-align: center;
  padding: 0.5pt 4.5pt;
  line-height: 1.15;
  font-size: 0.96em;
  white-space: nowrap;
}

/* Stacked Fraction: frac(1, 625) */
.math-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 2pt;
  line-height: 1.05;
  font-size: 0.92em;
  direction: ltr;
}

.math-frac-num {
  border-bottom: 0.9pt solid #000;
  padding: 0 2.5pt 1pt 2.5pt;
  text-align: center;
}

.math-frac-den {
  padding: 1pt 2.5pt 0 2.5pt;
  text-align: center;
}

/* Overline / Repeating Decimal Bar / Vector / Line Segment */
.math-overline {
  text-decoration: overline;
}

/* Radical / Square Root: sqrt(6) */
.math-sqrt {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
  direction: ltr;
}

.math-sqrt-sign {
  font-size: 1.05em;
  line-height: 1;
}

.math-sqrt-body {
  border-top: 0.85pt solid #000;
  padding-top: 0.5pt;
  margin-left: -0.5pt;
}

/* Tall Parentheses for Fractions */
.math-tall-paren {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  direction: ltr;
}

.math-tall-paren-char {
  transform: scaleY(1.45);
  display: inline-block;
  font-weight: normal;
  margin: 0 1pt;
}

/* Blank Answer Lines (Optional for Junior Classes) */
.answer-lines-block {
  margin-inline-start: 22pt;
  margin-top: 4pt;
}

.answer-line {
  border-bottom: 0.75pt dotted #555;
  height: 18pt;
  width: 100%;
}

/* ============================================================
   PRINT MEDIA RULES (A4 EXACT PRINT / PDF EXPORT)
   ============================================================ */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 15mm 14mm 15mm;
  }

  html, body {
    background: #ffffff !important;
    height: auto !important;
    overflow: visible !important;
  }

  .app-header,
  .composer-pane,
  .preview-toolbar {
    display: none !important;
  }

  .app-workspace,
  .preview-pane,
  .preview-scroll-container {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
  }

  .exam-paper-sheet {
    width: 100% !important;
    min-height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }
}
