@page { size: A4; margin: 5mm 5mm 5mm 5mm; }
:root { --primary: #008000; --text: #1a1a1a; --border: #008000; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Kufi Arabic', Arial, sans-serif; background: #f5f5f5; padding: 20px; direction: rtl; }
.page { width: 210mm; min-height: 297mm; background: white; margin: 0 auto; padding: 12mm; box-shadow: 0 2px 10px rgba(0,0,0,0.1); position: relative; }
.header { display: grid; grid-template-columns: 1fr auto 1fr; gap: 15px; align-items: center; margin-bottom: 3mm; }
.header-left { text-align: left; direction: ltr; color: var(--primary); }
.header-left h2 { font-size: 18px; font-weight: bold; margin-bottom: 3px; direction: ltr; }
.header-left p { font-size: 14px; font-weight: 700; margin-top: 2px; direction: ltr; font-style: normal; }
.header-logo { width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; }
.header-logo img { width: 100%; height: 100%; object-fit: contain; }
.header-right { text-align: right; color: var(--primary); direction: rtl; }
.header-right h1 { font-size: 20px; font-weight: bold; margin-bottom: 3px; }
.header-right p { font-size: 13px; margin-top: 2px; }
.subtitle { text-align: center; color: var(--primary); font-size: 13px; margin: 3px 0 5px 0; font-style: italic; }
.divider-line { border-bottom: 2px solid var(--border); margin-bottom: 3mm; }
.patient-info { display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 3mm; font-size: 14px; align-items: center; direction: ltr; justify-content:flex-start; }
.info-field { display: flex; align-items: center; gap: 6px; direction: ltr; }
.info-field label { font-weight: bold; color: var(--text); white-space: nowrap; }
.info-field input { border: none; border-bottom: 1px dotted #666; outline: none; font-size: 14px; padding: 2px 5px; background: transparent; direction: ltr; text-align: left; }
.info-field.name input { width: 180px; }
.info-field.date input { width: 94px; }
.info-field.age input { width: 259px; }
.info-field.address input { width: 220px; }
.address-row{ margin: 2mm 0 3mm; direction: ltr; display: flex; align-items: center; gap: 6px; }
.address-row label{ font-weight: 700; white-space: nowrap; color: var(--text); }
.address-row input{ flex: 1; border: none; border-bottom: 1px dotted #666; border-radius: 0; padding: 2px 5px; font-size: 14px; outline: none; background: transparent; direction: ltr; text-align: left; }
.imp-section { margin-bottom: 3mm; display: flex; align-items: center; gap: 10px; direction: ltr; }
.imp-section label { font-weight: bold; color: var(--text); white-space: nowrap; }
.imp-section input { flex: 1; border: 1.5px solid var(--border); border-radius: 4px; padding: 6px 10px; font-size: 14px; outline: none; direction: ltr; text-align: left; }
.content { display: grid; grid-template-columns: 1fr 2px 28%; gap: 15px; min-height: 165mm; }
.prescription { border: 1.5px solid var(--border); border-radius: 4px; padding: 12px; display: flex; flex-direction: column; position: relative; }
.rx-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--primary); direction: ltr; }
.rx-symbol { font-size: 36px; font-family: 'Times New Roman', serif; font-weight: bold; line-height: 1; }
.rx-header span { display: none; }
.prescription textarea { flex: 1; border: 1px solid #ddd; border-radius: 4px; padding: 10px; font-size: 14px; font-family: Arial, sans-serif; direction: ltr; text-align: left; resize: none; outline: none; line-height: 1.6; min-height: 145mm; white-space: pre-wrap; }
.divider { background: var(--border); width: 2px; }
.clinical-record { border: 1.5px solid var(--border); border-radius: 4px; padding: 12px; }
.clinical-record h3 { color: var(--primary); font-size: 14px; margin-bottom: 12px; font-weight: bold; text-align: left; direction: ltr; }
.vital-sign { display: grid; grid-template-columns: 50px 1fr; gap: 10px; margin-bottom: 10px; align-items: center; direction: ltr; }
.vital-sign label { font-weight: bold; color: var(--text); text-align: left; direction: ltr; font-size: 13px; }
.vital-sign input { border: none; border-bottom: 1px solid #999; outline: none; padding: 4px; font-size: 13px; direction: ltr; text-align: left; width: 100%; max-width: 150px; }
.dietary-notice { text-align: center; font-size: 14px; color: #000; margin-top: 4mm; padding-top: 3mm; border-top: 1px solid #000; line-height: 1.6; }
.dietary-notice p { margin: 2px 0; }
.footer { background: var(--primary); color: white; text-align: center; padding: 8px 15px; margin-top: 3mm; border-radius: 4px; font-size: 11px; line-height: 1.6; }
.ribbon .row { margin: 3px 0; display: flex; align-items: center; justify-content: center; gap: 15px; flex-wrap: wrap; }
.ribbon .row span { display: inline-block; }
.ribbon .row b { font-weight: bold; }
.actions { margin-top: 8mm; display: flex; gap: 10px; justify-content: center; }
.actions button { padding: 10px 25px; font-size: 15px; border: 1.5px solid var(--primary); background: #e6ffe6; color: #004d00; border-radius: 6px; cursor: pointer; font-weight: bold; transition: all .2s; }
.actions button:hover { background: #ccffcc; transform: translateY(-1px); }
.suggest-box { position: absolute; z-index: 20; top: 85px; left: 12px; right: 12px; max-height: 240px; overflow: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); display: none; }
.suggest-item { padding: 8px 12px; cursor: pointer; display:flex; align-items:center; justify-content:space-between; }
.suggest-item:hover { background: #f1f5f9; }
.suggest-right { font-size:12px; color:#334155; }
.helper-panel { position:absolute; z-index:21; left: 12px; right: 12px; top: 330px; background:#ffffff; border:1px solid #cbd5e1; border-radius:10px; padding:10px; display:none; box-shadow:0 8px 24px rgba(0,0,0,.12); }
.helper-panel .row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.helper-panel label { font-size:12px; font-weight:700; }
.helper-panel select, .helper-panel input { padding:6px 8px; border:1px solid #cbd5e1; border-radius:8px; }
.helper-panel button { padding:8px 12px; border:1px solid var(--primary); color:#064e3b; background:#eaffea; border-radius:8px; }
@media print {
  body { background: white; padding: 0; }
  .page { box-shadow: none; margin: 0; width: 100%; padding: 20px 10px 10px; }
  .actions { display: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .subtitle { display: none !important; }
  .header-right h1 { white-space: nowrap; }
  .suggest-box, .helper-panel { display:none !important; }
}