/* استمارة حجز وحدة سكنية — إدخال وعرض وطباعة */
@import url("https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap");

:root {
  --rf-blue: #1a3b6e;
  --rf-blue-dark: #142d54;
  --rf-gray-cell: #e8edf3;
  --rf-border: #1a1a1a;
  --rf-text: #111;
  --rf-a4-w: 210mm;
  --rf-a4-h: 297mm;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body.rf-body,
.rf-body {
  margin: 0;
  padding: 1rem;
  font-family: "Tajawal", "Segoe UI", sans-serif;
  direction: rtl;
  text-align: right;
  color: var(--rf-text);
  background: #f0f2f5;
  line-height: 1.45;
}

/* صفحة الإدخال داخل البطاقة — بدون فرض ارتفاع A4 */
.rf-body.rf-body--embedded {
  background: transparent;
  padding: 0;
  display: block;
}

.rf-body.rf-body--embedded .rf-sheet {
  width: min(100%, var(--rf-a4-w));
  min-height: auto;
  margin-left: auto;
  margin-right: auto;
}

.rf-toolbar {
  max-width: var(--rf-a4-w);
  margin: 0 auto 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.rf-toolbar button,
.rf-toolbar a {
  font-family: inherit;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--rf-blue);
  background: var(--rf-blue);
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
}

.rf-sheet {
  width: min(100%, var(--rf-a4-w));
  max-width: var(--rf-a4-w);
  margin: 0 auto;
  background: #fff;
  padding: 10mm 12mm 12mm;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #ccc;
}

/* ===== Header ===== */
.rf-header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
}

.rf-header-start {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 20px !important;
}

.rf-header-start .rf-complex-name {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--rf-blue);
  margin: 0 0 4px;
}

    .rf-header-end .rf-complex-name {
        font-size: 1.1rem;
        font-weight: 400;
        color: var(--rf-blue);
        margin: 0 0 4px;
    }

.rf-header-center {
  display: flex;
  justify-content: center;
}

.rf-stamp {
  border: none;
  padding: 0;
  margin: 0;
  text-align: center;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rf-stamp-img {
  display: block;
  max-height: 110px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.rf-header-end {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 20px !important;
}

.rf-emaar-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.rf-emaar-en {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  color: var(--rf-blue);
}

.rf-emaar-ar {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--rf-blue);
}

.rf-serial {
  margin-top: 6px;
  font-size: 0.9rem;
}

.rf-serial input {
  width: 72px;
  text-align: center;
}

.rf-banner {
  background: var(--rf-blue);
  color: #fff;
  text-align: center;
  padding: 10px 12px;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.rf-subtitle-en {
  text-align: center;
  font-size: 0.75rem;
  margin: -4px 0 8px;
  color: #333;
}

.rf-license-box {
  border: 1px solid var(--rf-border);
  padding: 8px 10px;
  text-align: center;
  font-size: 0.82rem;
  margin-bottom: 12px;
}

/* ===== Tables ===== */
.rf-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 10px;
  font-size: 1rem;
}

.rf-table th,
.rf-table td {
  border: 1px solid var(--rf-border);
  padding: 6px 8px;
  vertical-align: middle;
}

.rf-table .rf-label {
  background: var(--rf-gray-cell);
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
  line-height: 2.35;
}

.rf-table thead .rf-label {
  white-space: nowrap;
}

.rf-label--top {
  vertical-align: top;
  padding-top: 8px;
}

.rf-cell-tall {
  vertical-align: top;
  min-height: 3.75rem;
  padding-top: 6px;
  padding-bottom: 8px;
}

.rf-row-national-head .rf-label-national {
  text-align: center;
  font-weight: 700;
  padding: 8px 10px;
}

.rf-row-national-body .rf-cell-national {
  padding-top: 8px;
  padding-bottom: 10px;
}

.rf-input--national,
.rf-value--national {
  display: block;
  width: 100%;
  min-height: 2rem;
  letter-spacing: 0.02em;
}

.rf-value--multiline {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  min-height: 2.75rem;
}

.rf-textarea--address {
  min-height: 4.5rem;
  line-height: 1.45;
}

.rf-section-banner {
  background: var(--rf-blue);
  color: #fff;
  text-align: center;
  font-weight: 700;
  padding: 8px;
  font-size: 1rem;
}

.rf-section-banner td {
  border-color: var(--rf-blue-dark);
}

/* حقول الإدخال داخل الخلايا */
.rf-input,
.rf-textarea {
  width: 100%;
  max-width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  padding: 4px 2px;
  direction: rtl;
  text-align: right;
  color: var(--rf-text);
}

.rf-textarea {
  min-height: 2.5rem;
  resize: vertical;
  display: block;
}

.rf-input:focus,
.rf-textarea:focus {
  outline: 2px solid rgba(26, 59, 110, 0.35);
  outline-offset: 0;
}

.rf-value {
  min-height: 1.6em;
  word-break: break-word;
}

.rf-financial .rf-col-desc {
  width: 38%;
}

.rf-financial .rf-col-num {
  width: 22%;
  text-align: center;
}

.rf-financial .rf-col-words {
  width: 40%;
}

.rf-financial thead th {
  background: var(--rf-gray-cell);
  font-weight: 700;
}

.rf-pledge {
  border: 1px solid var(--rf-border);
  padding: 10px 12px;
  font-size: 1.25rem;
  line-height: 1.65;
  text-align: justify;
  text-justify: inter-word;
  margin-bottom: 10px;
}

.rf-signatures .rf-sign-label {
  
  height: 30px;
  line-height: 30px;
  vertical-align: middle;
  background: var(--rf-gray-cell);
  font-weight: 600;
  width: 42%;
}

.rf-signatures .rf-sign-space {
  min-height: 66px;
}

.rf-footer {
  display: flex;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #ccc;
  font-size: 0.78rem;
  padding: 10px;
}

.rf-footer-res {
    display: flex;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #ccc;
    font-size: 0.78rem;
    padding: 10px;
    flex-direction: row;
    justify-content: space-between;
}

.rf-qr {
  width: 72px;
  height: 72px;
  border: 1px solid var(--rf-border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
  overflow: hidden;
}

.rf-qr-img {
  display: block;
  width: 68px;
  height: 68px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.rf-contact {
  text-align: center;
  line-height: 1.6;
}

.rf-phones {
  text-align: left;
  line-height: 1.6;
}

.rf-page-num {
  grid-column: 1 / -1;
  text-align: left;
  font-size: 0.72rem;
  color: #555;
  margin-top: 4px;
}

/* معاينة الصفحة كـ A4 */
@media screen {
  .reservation-print-shell .rf-sheet {
    display: flex;
    flex-direction: column;
    width: var(--rf-a4-w);
    min-height: var(--rf-a4-h);
    max-width: var(--rf-a4-w);
    box-sizing: border-box;
  }

  .reservation-print-shell .rf-footer {
    margin-top: auto;
    flex-shrink: 0;
  }
}

/* ===== طباعة ===== */
@media print {
  @page {
    size: A4 portrait;
    /* هوامش متوازنة تترك مساحة للطباعة وتمنع قطع المحتوى */
    margin: 3mm 2mm;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    /* block-level بسيط — flex يسبب مشاكل في بعض محركات الطباعة */
    display: block !important;
    width: 100% !important;
  }

  body.rf-body,
  .rf-body {
    background: #fff;
    padding: 0;
    width: 100% !important;
    display: block !important;
  }

  .rf-toolbar {
    display: none !important;
  }

  .rf-sheet {
    box-shadow: none;
    border: none;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 4mm 6mm;
    /* flex يتيح دفع الـ footer للأسفل */
    display: flex !important;
    flex-direction: column !important;
    /* يملأ ارتفاع الورقة كاملاً: A4 - هوامش الصفحة (8mm×2) */
    min-height: calc(297mm - 16mm) !important;
    box-sizing: border-box;
    font-size: 9pt;
    line-height: 1.25;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    page-break-inside: avoid;
    page-break-after: avoid;
  }

  .reservation-print-shell {
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .rf-table {
    margin-bottom: 3px !important;
    font-size: 8pt;
  }

  .rf-table th,
  .rf-table td {
    padding: 4px 6px !important;
    vertical-align: top;
  }

  .rf-input,
  .rf-textarea {
    padding: 0 2px !important;
    font-size: inherit !important;
  }

  .rf-value--multiline {
    min-height: 0 !important;
    line-height: 1.3 !important;
  }

  .rf-textarea--address {
    min-height: 2rem !important;
  }

  .rf-pledge {
    font-size: 8pt !important;
    line-height: 1.5 !important;
    padding: 5px 8px !important;
  }

  .rf-footer {
    margin-top: auto !important;
    flex-shrink: 0;
    page-break-inside: avoid;
  }

  .rf-qr-img {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .rf-page-num {
    display: none !important;
  }

  .rf-banner,
  .rf-section-banner,
  .rf-table .rf-section-banner {
    background: var(--rf-blue) !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .rf-label,
  thead .rf-label,
  .rf-sign-label {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    height: 30px;
    line-height: 30px;
    vertical-align: middle;
  }

  .rf-signatures,
  .rf-table {
    page-break-inside: avoid;
  }
}