
/* A4 official school letter layout — uses existing ministry and school assets. */
.gl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin:14px 0}
.gl-toolbar span{font-weight:600}
.gl-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:14px 0 25px}
.gl-form>label{display:flex;flex-direction:column;gap:6px;font-weight:700;font-size:14px}
.gl-form input:not([type=checkbox]),.gl-form textarea{width:100%;box-sizing:border-box;border:1px solid #ccd6dd;border-radius:9px;background:#fff;padding:10px 12px;color:#233247;font:inherit;min-height:42px}
.gl-form textarea{min-height:120px;resize:vertical;line-height:1.8}
.gl-form .gl-numberless{display:flex;align-items:center;flex-direction:row;gap:7px;grid-column:1/-1}
.gl-form .gl-numberless input{width:18px;height:18px}
.gl-form-wide{grid-column:1/-1}
#gl-conflict{color:#a02525;font-weight:700;margin:0}
.gl-preview{overflow-x:auto;background:#eef2f2;padding:16px;display:flex;justify-content:center}
.gl-sheet{width:210mm;height:297mm;min-width:210mm;min-height:297mm;box-sizing:border-box;background:#fff;position:relative;overflow:hidden;color:#111;padding:0;font-family:"Noto Naskh Arabic","Noto Naskh","Arial",serif;direction:rtl;box-shadow:0 3px 20px #0002}
.gl-sheet .gl-topband,.gl-sheet .gl-bottomband{position:absolute;left:0;right:0;height:3.2mm;background:#166241;z-index:3}
.gl-sheet .gl-topband{top:0;border-bottom:2mm solid #e1c48b}
.gl-sheet .gl-bottomband{bottom:0;border-top:2.5mm solid #e1c48b}
.gl-letterhead{height:52mm;padding:7mm 13mm 4mm;box-sizing:border-box;display:grid;grid-template-columns:1fr 1.15fr 1fr;gap:4mm;border-bottom:0.6mm solid #166241;position:relative;z-index:2;background:#fff}
.gl-letterhead>div{min-width:0;display:flex;flex-direction:column;align-items:center;text-align:center;font-size:8.4px;font-family:Arial,"Noto Naskh Arabic",sans-serif;line-height:1.45;font-weight:600}
.gl-rightbrand img,.gl-leftbrand img{width:15mm;height:15mm;object-fit:contain;margin:0 0 1mm}
.gl-letterhead .gl-midbrand{padding-top:3mm;gap:1mm}
.gl-midbrand img{width:49mm;height:13mm;object-fit:contain}
.gl-midbrand small{color:#31724a;font-size:10px;line-height:1.4}
.gl-watermark{position:absolute;z-index:0;top:73mm;left:37mm;width:136mm;height:136mm;background:url("assets/logo.png") center/contain no-repeat;opacity:.065;pointer-events:none}
.gl-border{position:absolute;top:53mm;bottom:4mm;width:6mm;z-index:1;pointer-events:none;background:
 radial-gradient(circle at center,transparent 0 1.1px,#c3ad79 1.1px 1.5px,transparent 1.6px) center top/6mm 8mm repeat-y,
 radial-gradient(ellipse at 25% 30%,transparent 1.5px,#d8cb9c 1.6px 2.15px,transparent 2.2px) center top/6mm 12mm repeat-y;
 opacity:.75}
.gl-border-right{right:1.5mm}.gl-border-left{left:1.5mm;transform:scaleX(-1)}
.gl-document{position:relative;z-index:2;padding:0 29mm 0;line-height:1.55}
.gl-number{position:absolute;right:29mm;top:7mm;display:flex;flex-direction:column;align-items:flex-start;gap:0;font-size:17px;white-space:nowrap;line-height:1.45}
.gl-number b{font-family:Arial,sans-serif;font-size:17px;direction:ltr;font-weight:700;unicode-bidi:isolate;display:inline-block}
.gl-addressee{position:absolute;top:37mm;right:25mm;left:25mm;text-align:center;font-size:18px;font-weight:700;line-height:1.55;overflow-wrap:anywhere}
.gl-subject{position:absolute;top:52mm;right:25mm;left:25mm;text-align:center;font-size:18px;font-weight:700;text-decoration:underline;line-height:1.55;overflow-wrap:anywhere}
.gl-greeting{position:absolute;top:66mm;right:29mm;font-size:17px;font-weight:700}
.gl-letterbody{position:absolute;top:79mm;right:29mm;left:29mm;font-size:19px;line-height:1.6;text-align:justify;font-weight:700;white-space:normal;overflow-wrap:break-word;unicode-bidi:plaintext;max-height:42mm;overflow:hidden}
.gl-closing{position:absolute;top:124mm;right:29mm;left:29mm;font-size:19px;font-weight:700;text-align:center;white-space:pre-wrap}
.gl-signature{position:absolute;top:174mm;left:40mm;min-width:50mm;text-align:center;font-size:18px;font-weight:700}
.gl-sheet .gl-document{height:238mm}
.gl-print-view{padding:0;margin:0;background:white}
.gl-print-view .gl-sheet{box-shadow:none;margin:0 auto}
@media (max-width:780px){.gl-form{grid-template-columns:1fr}.gl-preview{justify-content:flex-start;padding:4px;overflow-x:auto}.gl-sheet{transform-origin:top right}}
@media print{
 html,body{margin:0!important;padding:0!important;width:210mm!important;background:#fff!important;-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important}
 .gl-sheet{width:210mm!important;height:297mm!important;min-height:297mm!important;box-shadow:none!important;margin:0!important;break-inside:avoid!important;page-break-inside:avoid!important;-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important}
 .gl-preview{padding:0!important;background:transparent!important;overflow:visible!important}
}

/* Pixel-faithful mode: use the exact A4 image embedded in the user's Word template. */
.gl-template-control{display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:12px 15px;border:1px solid #d7e1e3;border-radius:10px;background:#f7faf9}
.gl-template-control label{display:flex;flex-direction:column;gap:6px;font-weight:700;min-width:280px;flex:1}
.gl-template-control input{font:inherit;max-width:100%}
#gl-template-state{color:#244d40;font-size:13px;max-width:580px}
.gl-sheet.gl-original-bg{background-color:#fff;background-size:100% 100%;background-position:center;background-repeat:no-repeat}
.gl-original-bg .gl-topband,.gl-original-bg .gl-bottomband,.gl-original-bg .gl-watermark,.gl-original-bg .gl-border{display:none!important}
.gl-original-bg .gl-letterhead{visibility:hidden;border:0;height:52mm}
.gl-original-bg .gl-number{right:auto;left:30mm;top:6mm;align-items:flex-end;text-align:right}
.gl-original-bg .gl-addressee{top:39mm}
.gl-original-bg .gl-subject{top:52mm}
.gl-original-bg .gl-greeting{top:65mm}
.gl-original-bg .gl-letterbody{top:75mm;line-height:1.65}
.gl-original-bg .gl-closing{top:111mm}
.gl-original-bg .gl-signature{top:165mm}
@media print{
 .gl-sheet.gl-original-bg{-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important}
}

.gl-template-control[hidden]{display:none!important}
.gl-original-image{display:none}
.gl-original-bg .gl-original-image{display:block;position:absolute;inset:0;width:210mm;height:297mm;object-fit:fill;z-index:0;pointer-events:none}
.gl-original-bg .gl-letterhead,.gl-original-bg .gl-document{position:relative;z-index:2}
.gl-original-bg .gl-letterhead{visibility:hidden}
@media print{.gl-original-bg .gl-original-image{display:block!important}}

/* Official correspondence: aligned Western-digit count/date and principal name artwork. */
.gl-sheet .gl-number,.gl-sheet.gl-original-bg .gl-number{
 position:absolute;top:7mm;left:27mm;right:auto;min-width:66mm;
 display:flex;flex-direction:column;align-items:stretch;gap:1mm;
 color:#111;font-family:"Noto Naskh Arabic",Arial,sans-serif;
 font-size:16px;font-weight:800;line-height:1.3;
}
.gl-sheet .gl-meta-row{
 display:grid;grid-template-columns:18mm 45mm;gap:2mm;
 align-items:center;white-space:nowrap;direction:rtl;
}
.gl-sheet .gl-meta-label{display:block;text-align:right;font-weight:800}
.gl-sheet .gl-meta-value{display:block;direction:ltr;unicode-bidi:isolate;text-align:left;font-family:Arial,sans-serif;font-weight:800;font-size:16px;letter-spacing:0;font-variant-numeric:tabular-nums}
.gl-sheet .gl-signature,.gl-sheet.gl-original-bg .gl-signature{
 top:162mm;left:30mm;width:68mm;min-width:0;
 display:flex;flex-direction:column;align-items:center;gap:2.5mm;
 font-weight:800;font-size:19px;text-align:center;
}
.gl-sheet .gl-signature-title{font-size:19px;font-weight:800;line-height:1.4}
.gl-manager-name-art{display:block;width:64mm;height:auto;max-height:20mm;object-fit:contain}
@media print{.gl-manager-name-art{width:64mm!important;max-height:20mm!important}}

/* V7: keep each printed book number/date immediately beside its Arabic label. */
.gl-sheet .gl-number,.gl-sheet.gl-original-bg .gl-number{
 left:25mm;right:auto;top:7mm;width:64mm;min-width:0;
 display:flex;flex-direction:column;align-items:flex-start;gap:1mm;
 font-family:Arial,Tahoma,sans-serif;
}
.gl-sheet .gl-meta-row{
 direction:rtl;display:flex;flex-direction:row;align-items:baseline;
 justify-content:flex-start;gap:2.5mm;width:100%;
 line-height:1.45;white-space:nowrap;
}
.gl-sheet .gl-meta-label{
 display:inline-block;flex:none;min-width:17mm;
 text-align:right;font-family:Arial,Tahoma,sans-serif;
 font-size:16px;font-weight:800;
}
.gl-sheet .gl-meta-value{
 display:inline-block;flex:1;min-width:0;
 text-align:right;direction:ltr;unicode-bidi:isolate;
 font-family:Arial,Tahoma,sans-serif;font-size:16px;font-weight:800;
 font-variant-numeric:tabular-nums;letter-spacing:0;
}
.gl-sheet .gl-signature,.gl-sheet.gl-original-bg .gl-signature{
 display:flex;flex-direction:column;align-items:center;justify-content:flex-start;
 gap:2.5mm;width:76mm;min-width:0;left:26mm;top:162mm;
 font-family:Arial,Tahoma,"Noto Naskh Arabic",sans-serif;
}
.gl-sheet .gl-signature-title{font-size:19px;font-weight:800}
.gl-sheet .gl-manager-readable-name{
 display:block;white-space:nowrap;direction:rtl;
 font-size:21px;line-height:1.7;letter-spacing:0;
 font-weight:800;color:#111;text-align:center;
}

/* Approved principal calligraphy artwork, preserved as image on every printed letter. */
.gl-sheet .gl-manager-approved-art{
 display:block;width:42mm;max-width:100%;height:auto;max-height:15mm;
 object-fit:contain;object-position:center;
 image-rendering:auto;
}
@media print{
 .gl-sheet .gl-manager-approved-art{display:block!important;width:42mm!important;max-height:15mm!important}
}

/* A4 left-side correspondence metadata: labels next to values, ISO year/month/day. */
.gl-sheet .gl-number,.gl-sheet.gl-original-bg .gl-number{
 position:absolute!important;
 left:18mm!important;right:auto!important;top:7mm!important;
 width:auto!important;min-width:0!important;max-width:78mm!important;
 display:flex!important;flex-direction:column!important;align-items:flex-start!important;
 gap:1mm!important;
}
.gl-sheet .gl-meta-row{
 display:flex!important;flex-direction:row!important;direction:rtl!important;
 justify-content:flex-start!important;align-items:baseline!important;
 gap:2mm!important;width:auto!important;min-width:0!important;
 white-space:nowrap!important;
}
.gl-sheet .gl-meta-label{
 flex:0 0 auto!important;min-width:0!important;
 font-size:16px!important;text-align:right!important;
}
.gl-sheet .gl-meta-value{
 flex:0 0 auto!important;min-width:0!important;
 font-size:16px!important;text-align:left!important;
 direction:ltr!important;unicode-bidi:isolate!important;
}
