/* V65: adaptable Arabic header text while retaining original form input for validation/export */
.afia-header-native {position:absolute!important;inset:auto!important;width:1px!important;height:1px!important;min-width:1px!important;min-height:1px!important;max-width:1px!important;opacity:0!important;pointer-events:none!important;overflow:hidden!important;padding:0!important;margin:0!important;border:0!important;clip-path:inset(50%)!important;}
.afia-header-field {position:relative!important;min-width:0!important;max-width:100%!important;overflow:visible!important;}
.afia-header-expand {display:block;box-sizing:border-box;position:relative;width:100%;max-width:100%;min-width:0;min-height:25px;height:auto!important;max-height:none!important;overflow:visible!important;word-break:normal;overflow-wrap:anywhere!important;white-space:pre-wrap!important;unicode-bidi:plaintext;direction:rtl;text-align:inherit;line-height:1.55;letter-spacing:normal!important;text-overflow:clip;outline-offset:1px;cursor:text;user-select:text;-webkit-user-select:text;border-radius:3px;}
.afia-header-expand:focus-visible{outline:1px solid currentColor;outline-offset:2px}
.afia-header-expand:empty:before {content:attr(data-placeholder);color:inherit;opacity:.66;pointer-events:none;}
.brand-name,.brand-name .edu-name,.brand-name .school-name,.centered-brand-identity,.identity,.institution,.brand-input,.sheet-header .brand-area {min-width:0;}
.brand-name .edu-name,.brand-name .school-name{white-space:normal!important;overflow:visible!important;overflow-wrap:anywhere!important;}
.brand-name .afia-header-expand{padding:1px 3px;line-height:1.36!important;}
.centered-brand-identity .afia-header-expand{max-width:100%;}
.identity .afia-header-expand {padding:0 4px;text-align:right;line-height:1.65;}
.brand-input .afia-header-expand {padding:1px 2px;text-align:center;line-height:1.55;}
.sheet-header:has(.afia-header-expand),.sheet-header:has(.afia-header-expand) .brand-area {overflow:visible!important;}
/* Fixed visual artwork and logo size: grow text without scaling or moving the artwork. */
.gold-page .brand:has(.afia-header-expand){height:auto!important;min-height:146px!important;}
.gold-page .gold-header-art {height:146px!important;max-height:146px!important;object-fit:fill!important;}
.gold-page .identity .afia-header-expand {padding:2px 3px;text-align:center;line-height:1.45!important;border-bottom:1px dotted #b0b9a8;}
/* Do not compress header text into a horizontal input when printing. */
@media print {
 *,*:before,*:after{-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important;}
 .afia-header-native {display:none!important;}
 .afia-header-expand {font-synthesis:none!important;white-space:pre-wrap!important;overflow-wrap:anywhere!important;letter-spacing:normal!important;}
 /* Pages with established print value spans should render those, never two copies. */
 .afia-header-has-print .afia-header-expand {display:none!important;}
 .afia-header-has-print .print-value {white-space:pre-wrap!important;overflow-wrap:anywhere!important;height:auto!important;max-height:none!important;}
}
.output-mode .afia-header-has-print .afia-header-expand,
.afia-export-document .afia-header-has-print .afia-header-expand,
.afia-print-mode .afia-header-has-print .afia-header-expand {display:none!important;}
.output-mode .afia-header-has-print .print-value{white-space:pre-wrap!important;overflow-wrap:anywhere!important;height:auto!important;}
/* Long department/school names are allowed to grow vertically; preserve logo dimensions. */
.sheet-header:has(.afia-header-expand){height:auto!important;max-height:none!important;min-height:35mm!important;flex:0 0 auto!important;overflow:visible!important;padding-top:3mm!important;padding-bottom:3mm!important;}
.sheet-header:has(.afia-header-expand) .brand-area{height:auto!important;max-height:none!important;min-height:0!important;align-items:center!important;}
.sheet-header:has(.afia-header-expand) .institution{height:auto!important;min-height:0!important;max-height:none!important;grid-template-rows:auto auto!important;row-gap:2px!important;overflow:visible!important;justify-content:center!important;}
.sheet-header:has(.afia-header-expand) .brand-input{height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important;display:block!important;}
.sheet-header:has(.afia-header-expand) .afia-header-expand{height:auto!important;min-height:24px!important;max-height:none!important;padding-top:3px!important;padding-bottom:3px!important;}
.centered-brand-identity:has(.afia-header-expand),.centered-brand-identity:has(.afia-header-expand) .brand-name{height:auto!important;max-height:none!important;overflow:visible!important;}
.header:has(.afia-header-expand),.header:has(.afia-header-expand) .brand-header{height:auto!important;max-height:none!important;overflow:visible!important;}
.afia-header-expand{padding-bottom:4px!important;}
@media print{
 .sheet-header:has(.afia-header-expand){height:auto!important;max-height:none!important;min-height:35mm!important;flex:0 0 auto!important;}
 .sheet-header:has(.afia-header-expand) .institution,.sheet-header:has(.afia-header-expand) .brand-input{height:auto!important;max-height:none!important;min-height:0!important;overflow:visible!important;}
 .sheet-header:has(.afia-header-expand) .brand-input .print-value{height:auto!important;max-height:none!important;min-height:0!important;overflow:visible!important;padding:3px 1px!important;line-height:1.5!important;}
}
.output-mode .sheet-header:has(.afia-header-expand) .institution,.output-mode .sheet-header:has(.afia-header-expand) .brand-input{height:auto!important;max-height:none!important;overflow:visible!important;}
.output-mode .sheet-header .brand-input .print-value{height:auto!important;max-height:none!important;line-height:1.5!important;}
/* Preserve the original absolute alignment of national-day gold's identity. */
.gold-page .identity.afia-header-field{position:absolute!important;right:3.2%!important;top:20px!important;}
/* Execution report has ID-level fixed 35mm dimensions; supersede these only
   when the header has a genuinely expanded editable line. */
#pageOne .sheet-header:has(.afia-header-expand),#pageTwo .sheet-header:has(.afia-header-expand),
.print-sheet .sheet-header:has(.afia-header-expand){height:auto!important;min-height:35mm!important;max-height:none!important;flex-basis:auto!important;overflow:visible!important;}
#pageOne .sheet-header:has(.afia-header-expand) .brand-area,
#pageTwo .sheet-header:has(.afia-header-expand) .brand-area{height:auto!important;min-height:0!important;max-height:none!important;grid-template-rows:auto!important;overflow:visible!important;}
#pageOne .sheet-header:has(.afia-header-expand) .institution,
#pageTwo .sheet-header:has(.afia-header-expand) .institution{height:auto!important;min-height:0!important;max-height:none!important;grid-template-rows:auto auto!important;overflow:visible!important;align-self:center!important;}
#pageOne .sheet-header:has(.afia-header-expand) .brand-input,
#pageTwo .sheet-header:has(.afia-header-expand) .brand-input{height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important;flex:0 0 auto!important;}

/* V66: the separate print-only text copies must grow naturally for long titles.
   Higher specificity overrides old fixed 7.5mm/23px header print cells. */
@media print {
 .institution .brand-input.afia-header-has-print,
 .print-sheet .institution .brand-input.afia-header-has-print,
 .sheet-header .institution .brand-input.afia-header-has-print {
   height:auto!important;min-height:7.5mm!important;max-height:none!important;
   overflow:visible!important;align-items:stretch!important;
 }
 .institution .brand-input.afia-header-has-print .print-value,
 .print-sheet .institution .brand-input.afia-header-has-print .print-value,
 .sheet-header .institution .brand-input.afia-header-has-print .print-value {
   display:block!important;box-sizing:border-box!important;
   height:auto!important;max-height:none!important;min-height:7.5mm!important;
   overflow:visible!important;white-space:pre-wrap!important;
   overflow-wrap:anywhere!important;text-overflow:clip!important;
   font-family:var(--afia-header-font-family, Cairo, sans-serif)!important;
   font-weight:var(--afia-header-font-weight,700)!important;
   font-size:var(--afia-header-font-size,12px)!important;
   color:var(--afia-header-text-color,inherit)!important;
   text-align:var(--afia-header-text-align,right)!important;
   line-height:1.4!important;letter-spacing:normal!important;
 }
}

/* V68: ALWAYS one line in edit, preview, print and cloned PDF surfaces. */
.afia-header-expand{display:block!important;white-space:nowrap!important;overflow-wrap:normal!important;word-break:keep-all!important;line-height:1.4!important;min-height:0!important;max-height:1.65em!important;overflow-x:auto!important;overflow-y:hidden!important;scrollbar-width:none;text-overflow:clip!important;padding-block:0!important;}
.afia-header-expand::-webkit-scrollbar{display:none}
.afia-header-field{min-width:0!important;max-width:100%!important;}
.afia-header-has-print .print-value{white-space:nowrap!important;overflow-wrap:normal!important;word-break:keep-all!important;line-height:1.35!important;font-size:var(--afia-header-fit-size,var(--afia-header-font-size,12px))!important;}
.sheet-header:has(.afia-header-expand){height:var(--afia-header-original-height,35mm)!important;min-height:var(--afia-header-original-height,35mm)!important;max-height:var(--afia-header-original-height,35mm)!important;flex:0 0 var(--afia-header-original-height,35mm)!important;padding-block:0!important;}
.gold-page .brand:has(.afia-header-expand){height:146px!important;min-height:146px!important;max-height:146px!important;}
.afia-header-field[data-afia-header-overflow=\"true\"] .afia-header-expand{outline:1px dotted #a76533;outline-offset:1px;}
@media print{
 .afia-header-expand{white-space:nowrap!important;overflow-wrap:normal!important;word-break:keep-all!important;overflow:visible!important;line-height:1.35!important;}
 .afia-header-has-print .print-value{white-space:nowrap!important;overflow-wrap:normal!important;word-break:keep-all!important;overflow:visible!important;max-height:1.65em!important;min-height:0!important;height:auto!important;}
 .sheet-header:has(.afia-header-expand){height:var(--afia-header-original-height,35mm)!important;min-height:var(--afia-header-original-height,35mm)!important;max-height:var(--afia-header-original-height,35mm)!important;flex:0 0 var(--afia-header-original-height,35mm)!important;}
 .gold-page .brand:has(.afia-header-expand){height:146px!important;min-height:146px!important;max-height:146px!important;}
}

/* V71 | TYPOGRAPHICALLY BALANCED INSTITUTIONAL HEADER */
/* Shared optical font size for both lines, fixed separator-to-content spacing,
   preserved Cairo faces and the form's original weight and colors. */
.afia-header-balanced .afia-header-field .afia-header-expand,
.afia-header-balanced .afia-header-field .print-value {
  font-family:Cairo,sans-serif!important;
  font-size:var(--afia-header-balanced-size,12px)!important;
  line-height:1.42!important;
  height:1.58em!important;min-height:1.58em!important;max-height:1.58em!important;
  padding-block:0!important;
  white-space:nowrap!important;overflow-wrap:normal!important;
  text-overflow:clip!important;
  box-sizing:border-box!important;
}
/* Equal distances from the vertical rule to logo and to text start. */
.sheet-header:has(.afia-header-balanced) .brand-area{column-gap:2.8mm!important;}
.sheet-header:has(.afia-header-balanced) .institution{gap:2mm!important;}
.sheet-header:has(.afia-header-balanced) .institution .brand-input{padding:0!important;margin:0!important;}
.sheet-header:has(.afia-header-balanced) .institution .afia-header-expand{text-align:right!important;padding-inline:2px!important;}
/* Execution: permit the text column to extend to the LEFT only. The logo and
   separator remain anchored to the original two first grid columns. */
.sheet-header:has(.afia-header-balanced) .brand-area{position:relative!important;}
.sheet-header:has(.afia-header-balanced) .brand-area .institution{
 position:absolute!important;top:50%!important;
 right:calc(26mm + 1.3px + 2.8mm)!important;
 transform:translateY(-50%)!important;
 width:min(85mm,calc(100vw - 140px))!important;
 min-width:0!important;max-width:85mm!important;
 display:flex!important;flex-direction:column!important;justify-content:center!important;
 box-sizing:border-box!important;overflow:visible!important;
}
/* Other forms: keep their existing header identity geometry, do not reflow. */
.brand-name.afia-header-balanced .afia-header-expand,
.identity.afia-header-balanced .afia-header-expand{
 padding-inline:2px!important;
}
@media print{
 .afia-header-balanced .afia-header-field .print-value{
  font-size:var(--afia-header-balanced-size,12px)!important;
  height:1.58em!important;min-height:1.58em!important;max-height:1.58em!important;
  line-height:1.42!important;overflow:hidden!important;
 }
 #printReport .print-sheet .institution .institution-text{
  font-family:Cairo,sans-serif!important;
  font-size:var(--afia-execution-header-fit-size,12px)!important;
  line-height:1.35!important;
  letter-spacing:normal!important;
  white-space:nowrap!important;overflow-wrap:normal!important;
 }
 #printReport .print-sheet .brand-area .institution{
  right:calc(26mm + 1.3px + 2.8mm)!important;
 }
}
/* V71 long official names: expand writing surface towards the free side, not
   the logo, so a long department name and a short school name fit together. */
.brand-name.afia-header-balanced > .afia-header-field{
  width:min(430px,calc(100vw - 145px))!important;
  max-width:none!important;
  align-self:flex-start!important;
  flex:0 0 auto!important;
}
.brand-name.afia-header-balanced > .afia-header-field .afia-header-expand{
  width:100%!important;max-width:100%!important;
}
/* Wider text area; the logo and divider remain on their old grid tracks. */
.sheet-header:has(.afia-header-balanced) .brand-area .institution{
  width:min(105mm,calc(100vw - 140px))!important;
  max-width:105mm!important;
}
/* Gold identity is backed by artwork; keep artwork static and grow right-aligned
   text only within the undisturbed right-hand part of the image. */
.gold-page .identity.afia-header-balanced{
  width:min(335px,calc(100vw - 34px))!important;
  max-width:335px!important;
  text-align:right!important;
}
.gold-page .identity.afia-header-balanced .afia-header-expand{text-align:right!important;}
@media print{
  #printReport .print-sheet .brand-area .institution{
    width:105mm!important;min-width:105mm!important;max-width:105mm!important;
  }
}

.sheet-header:has(.afia-header-balanced) .brand-area .institution{
 transform:translateY(-50%) translateX(var(--afia-balanced-shift,0px))!important;
}

/* Print size comes from the fixed A4 composition rather than mobile viewport. */
@media print{
 .afia-header-balanced .afia-header-field .print-value,
 .afia-header-balanced .afia-header-field .afia-header-expand{
  font-size:var(--afia-header-print-size,var(--afia-header-balanced-size,12px))!important;
 }
}
