@font-face {
  font-family: "Cairo";
  src: url("fonts/cairo-arabic-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFC, U+0660-0669;
}
@font-face {
  font-family: "Cairo";
  src: url("fonts/cairo-arabic-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFC, U+0660-0669;
}
@font-face {
  font-family: "Cairo";
  src: url("fonts/cairo-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "Cairo";
  src: url("fonts/cairo-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}

:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --text-soft: #475569;
  --border: #e2e8f0;
  --danger: #b91c1c;
  --radius: 14px;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
}

/* الترويسة */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 18px 16px 22px;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.app-title { font-size: 1.35rem; font-weight: 700; }
.sample-badge {
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 0.8rem;
  font-weight: 700;
}
.disclaimer {
  margin-top: 6px;
  font-size: 0.82rem;
  opacity: 0.92;
}

/* الشاشات */
.view { padding: 16px; max-width: 640px; margin: 0 auto; }
.view-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; color: var(--primary-dark); }

/* قائمة الخدمات */
.services-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.service-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.service-card.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.service-info { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.service-name {
  font-weight: 700;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex: 1 1 auto;
  min-width: 0;
}
.service-price { color: var(--text-soft); font-size: 0.85rem; white-space: nowrap; }
.service-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-dark);
  cursor: pointer;
  line-height: 1;
  touch-action: manipulation;
}
.stepper button:active { background: var(--primary-light); }
.stepper button:disabled { opacity: 0.35; cursor: default; }
.stepper .qty {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.line-total { font-weight: 700; color: var(--primary-dark); font-size: 0.95rem; white-space: nowrap; }

/* الحقول */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.optional { font-weight: 400; color: var(--text-soft); font-size: 0.8rem; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: var(--card);
  color: var(--text);
}
.field input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.discount-input { max-width: 140px; text-align: center; }

/* الملخص */
.summary-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.summary-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.92rem;
}
.summary-list .s-name { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.summary-list .s-amount { white-space: nowrap; font-weight: 700; }

/* الإجماليات */
.totals {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.totals-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.totals-row dt { color: var(--text-soft); }
.totals-row dd { font-weight: 700; }
.totals-grand { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 10px; }
.totals-grand dt { color: var(--text); font-weight: 700; }
.totals-grand dd { color: var(--primary-dark); font-size: 1.15rem; }

/* الأزرار */
.btn {
  font: inherit;
  font-weight: 700;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  touch-action: manipulation;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary-dark); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--danger); }
.btn-ghost.armed { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 700; }
.btn-block { display: block; width: 100%; margin-bottom: 10px; }

/* الحالة الفارغة */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

/* بطاقة عرض السعر */
.quote-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 16px;
}
.quote-head { border-bottom: 2px solid var(--primary); padding-bottom: 10px; margin-bottom: 12px; }
.quote-head h3 { font-size: 1.25rem; color: var(--primary-dark); }
.quote-meta { color: var(--text-soft); font-size: 0.85rem; }
.quote-client { font-weight: 700; margin-top: 4px; }
.quote-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 12px; }
.quote-table th {
  text-align: right;
  border-bottom: 1px solid var(--border);
  padding: 6px 4px;
  color: var(--text-soft);
  font-size: 0.8rem;
}
.quote-table td { border-bottom: 1px solid var(--border); padding: 8px 4px; vertical-align: top; }
.quote-table td:first-child { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.quote-table th:nth-child(n+2), .quote-table td:nth-child(n+2) { text-align: center; white-space: nowrap; }
.quote-note { font-size: 0.78rem; color: var(--text-soft); margin-top: 10px; }
.quote-actions { display: flex; flex-direction: column; gap: 10px; }
.copy-feedback { text-align: center; color: var(--primary-dark); font-weight: 700; min-height: 1.5em; font-size: 0.9rem; }

/* شريط التبويبات */
.tab-bar {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 10;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  position: relative;
}
.tab[aria-current="page"] { color: var(--primary-dark); font-weight: 700; }
.tab-icon { width: 22px; height: 22px; fill: currentColor; }
.tab-count {
  position: absolute;
  top: 6px;
  inset-inline-start: calc(50% + 8px);
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

@media (min-width: 640px) {
  .app-header { padding: 22px 24px 26px; }
  .view { padding: 20px 24px; }
}

/* الطباعة / حفظ PDF */
@page { size: A4; margin: 12mm; }
@media print {
  body { background: #fff; padding-bottom: 0; }
  .no-print, .app-header, .tab-bar, .view-title { display: none !important; }
  .view { padding: 0; max-width: none; }
  .view[hidden] { display: none !important; }
  .quote-card { border: none; border-radius: 0; padding: 0; }
}
