/* دليل تسعير مشاريع التصميم — #نذير */

/* Montserrat-Arabic — SIL OFL 1.1 (fonts/OFL.txt) */
@font-face {
  font-family: "Montserrat Arabic";
  src: url("fonts/montserrat-arabic-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Montserrat Arabic";
  src: url("fonts/montserrat-arabic-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Montserrat Arabic";
  src: url("fonts/montserrat-arabic-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Montserrat Arabic";
  src: url("fonts/montserrat-arabic-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
:root {
  --brand: #2D2A47;
  --brand-2: #5B5391;
  --brand-solid: #2D2A47;
  --on-brand: #FFFFFF;
  --heading: #2D2A47;
  --bg: #FAFAFC;
  --surface: #FFFFFF;
  --surface-2: #F5F4FA;
  --text: #1F2937;
  --muted: #6B7280;
  --border: #E6E4EE;
  --row-alt: #FAFAFD;

  --amber-bg: #FEF3C7; --amber-tx: #92400E; --amber-bd: #F5D78A;
  --red-bg: #FDE8E8;   --red-tx: #991B1B;   --red-bd: #F6BDBD;
  --green-bg: #DCFCE7; --green-tx: #14532D; --green-bd: #A7E8BE;
  --blue-bg: #E0F2FE;  --blue-tx: #075985;  --blue-bd: #A9DBF7;
  --gray-bg: #F3F4F6;  --gray-tx: #374151;  --gray-bd: #DDE0E5;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(45, 42, 71, .06), 0 6px 20px rgba(45, 42, 71, .06);
  --topbar-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #C9C3F0;
    --brand-2: #A79FE0;
    --brand-solid: #5B5391;
    --heading: #E4E0FA;
    --bg: #121118;
    --surface: #1A1923;
    --surface-2: #221F31;
    --text: #E7E5F0;
    --muted: #A09CB5;
    --border: #2F2C40;
    --row-alt: #1E1C29;

    --amber-bg: rgba(245, 158, 11, .12); --amber-tx: #FCD34D; --amber-bd: rgba(245, 158, 11, .35);
    --red-bg: rgba(239, 68, 68, .12);    --red-tx: #FCA5A5;   --red-bd: rgba(239, 68, 68, .35);
    --green-bg: rgba(34, 197, 94, .12);  --green-tx: #86EFAC; --green-bd: rgba(34, 197, 94, .35);
    --blue-bg: rgba(14, 165, 233, .12);  --blue-tx: #7DD3FC;  --blue-bd: rgba(14, 165, 233, .35);
    --gray-bg: rgba(255, 255, 255, .05); --gray-tx: #D1D5DB;  --gray-bd: rgba(255, 255, 255, .12);

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 17px;
  line-height: 1.9;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand-2); }
strong { font-weight: 700; }
svg { width: 1.15em; height: 1.15em; flex: none; }

.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 50; background: var(--brand-solid); color: var(--on-brand); padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 10px; }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; border-radius: 6px; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  background: #2D2A47;
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.topbar-inner {
  max-width: 1180px; height: 100%; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.brand-mark { font-weight: 700; background: rgba(255, 255, 255, .12); padding: 2px 10px; border-radius: 8px; font-size: 15px; }
.brand-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px;
  border-radius: 12px; border: 1.5px solid var(--brand-solid);
  background: var(--brand-solid); color: var(--on-brand);
  font: inherit; font-weight: 600; font-size: 16px; text-decoration: none;
  transition: transform .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--brand); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--brand-2); }
.btn--small { min-height: 38px; padding: 0 14px; font-size: 14px; background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .22); color: #fff; }
.btn--small:hover { background: rgba(255, 255, 255, .2); }

/* ---------- التخطيط ---------- */
.layout {
  max-width: 1180px; margin: 0 auto; padding: 0 16px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px;
}
main { min-width: 0; max-width: 780px; width: 100%; margin: 0 auto; }
.sidebar { display: none; }

@media (min-width: 1100px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  main { margin: 0; }
  .sidebar {
    display: block; position: sticky; top: calc(var(--topbar-h) + 24px);
    align-self: start; max-height: calc(100vh - var(--topbar-h) - 48px); overflow: auto;
    padding: 28px 0;
  }
  .toc-block { display: none; }
}
.sidebar-title { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }

/* ---------- المقدمة ---------- */
.hero { padding: 48px 0 8px; text-align: center; }
.eyebrow { display: inline-block; margin: 0 0 14px; padding: 4px 14px; border-radius: 999px; background: var(--surface-2); color: var(--brand-2); font-weight: 600; font-size: 14px; }
.hero h1 { margin: 0; color: var(--heading); font-size: clamp(30px, 6.5vw, 46px); line-height: 1.35; font-weight: 700; }
.lead { margin: 10px 0 4px; color: var(--brand-2); font-weight: 600; font-size: clamp(17px, 3.6vw, 20px); }
.source { margin: 0; color: var(--muted); font-size: 15px; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 26px 0 30px; }
.disclaimer { text-align: start; }

.contacts { display: grid; gap: 12px; margin-top: 16px; text-align: start; }
@media (min-width: 720px) { .contacts { grid-template-columns: 1fr 1fr; } }
.contact {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: inherit; text-decoration: none; box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .15s ease;
}
.contact:hover { border-color: var(--brand-2); transform: translateY(-1px); }
.contact-icon {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  display: grid; place-items: center; background: #2D2A47; color: #fff;
}
.contact-icon svg { width: 22px; height: 22px; }
.contact-body { display: flex; flex-direction: column; min-width: 0; }
.contact-title { font-weight: 700; color: var(--heading); font-size: 16px; }
.contact-text { color: var(--muted); font-size: 14.5px; line-height: 1.75; }
.contact-link { margin-top: 4px; color: var(--brand-2); font-weight: 700; font-size: 15px; text-align: end; direction: ltr; unicode-bidi: isolate; }

/* ---------- المحتويات ---------- */
.toc { list-style: none; margin: 0; padding: 0; }
.toc a { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--text); }
.toc .num { color: var(--muted); font-weight: 700; font-size: 13px; min-width: 1.6em; }
.toc--side a { padding: 6px 12px; border-radius: 8px; font-size: 15px; line-height: 1.6; border-inline-start: 2px solid transparent; }
.toc--side a:hover { background: var(--surface-2); }
.toc--side a.active { background: var(--surface-2); color: var(--heading); font-weight: 600; border-inline-start-color: var(--brand-2); }
.toc--side a.active .num { color: var(--brand-2); }

.toc-block { margin: 40px 0 8px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.toc-block-title { margin: 0 0 8px; font-weight: 700; color: var(--heading); }
.toc--grid { display: grid; gap: 2px 20px; }
@media (min-width: 640px) { .toc--grid { grid-template-columns: 1fr 1fr; } }
.toc--grid a { padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 16px; line-height: 1.6; }
.toc--grid a:hover { color: var(--brand-2); }

/* ---------- الأقسام ---------- */
.chapter { padding-top: 40px; }
.chapter h2 {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 18px; padding-bottom: 12px;
  border-bottom: 2px solid var(--heading);
  color: var(--heading); font-size: clamp(23px, 4.6vw, 28px); line-height: 1.45; font-weight: 700;
}
.chapter h2 .num {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 10px;
  background: #2D2A47; color: #fff; font-size: 17px;
}
.chapter h3 { margin: 30px 0 10px; color: var(--brand-2); font-size: 20px; line-height: 1.5; font-weight: 700; }
.chapter p { margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 15px; }

.list { margin: 0 0 16px; padding: 0; list-style: none; }
.list li { position: relative; padding-inline-start: 28px; margin-bottom: 8px; }
.list li::before { position: absolute; inset-inline-start: 4px; top: 0; color: var(--brand-2); font-weight: 700; }
.list--dot li::before { content: "•"; font-size: 1.2em; line-height: 1.6; }
.list--check li::before { content: "✓"; }
.list--warn li::before { content: "⚠"; color: var(--amber-tx); }

.steps-title { color: var(--brand-2); font-weight: 700; margin-bottom: 8px !important; }
.steps { margin: 0 0 18px; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding-inline-start: 44px; margin-bottom: 10px; min-height: 30px; }
.steps li::before {
  content: counter(s); position: absolute; inset-inline-start: 0; top: 2px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--brand-2); font-weight: 700; font-size: 15px; line-height: 1;
}

.quote {
  margin: 18px 0 20px; padding: 16px 20px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  border-inline-start: 4px solid var(--brand-2);
}
.quote blockquote { margin: 0; font-size: 16.5px; line-height: 1.95; }
.quote figcaption { margin-top: 6px; color: var(--muted); font-size: 14px; }

.callout {
  margin: 18px 0 20px; padding: 14px 18px;
  border-radius: var(--radius-sm); border: 1px solid;
  font-size: 16px; line-height: 1.85;
}
.callout p { margin: 0 0 6px !important; }
.callout p:last-child { margin-bottom: 0 !important; }
.callout-title { font-weight: 700; font-size: 17px; }
.callout--amber { background: var(--amber-bg); color: var(--amber-tx); border-color: var(--amber-bd); }
.callout--red { background: var(--red-bg); color: var(--red-tx); border-color: var(--red-bd); }
.callout--green { background: var(--green-bg); color: var(--green-tx); border-color: var(--green-bd); font-size: 18px; }
.callout--blue { background: var(--blue-bg); color: var(--blue-tx); border-color: var(--blue-bd); }
.callout--gray { background: var(--gray-bg); color: var(--gray-tx); border-color: var(--gray-bd); }

/* ---------- الجداول ---------- */
.table-wrap { margin: 16px 0 22px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 15.5px; line-height: 1.75; }
.table th { background: #2D2A47; color: #fff; font-weight: 600; padding: 10px 14px; text-align: start; }
.table td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: top; }
.table tbody tr:nth-child(even) td { background: var(--row-alt); }

/* على الجوال: كل صف يصير بطاقة، وعنوان العمود يظهر فوق قيمته */
@media (max-width: 640px) {
  .table-wrap { border: 0; background: none; overflow: visible; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    margin-bottom: 10px; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .table tbody tr:nth-child(even) td { background: none; }
  .table td { border: 0; padding: 3px 0; }
  .table td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block;
    color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 1.5;
  }
  .table td:empty { display: none; }
  .table td:first-child { font-weight: 700; color: var(--heading); }
  .table td:first-child::before { display: none !important; }
}

/* ---------- الحاسبة ---------- */
.calc {
  display: grid; gap: 18px; margin: 18px 0 24px;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
@media (min-width: 760px) { .calc { grid-template-columns: 1.15fr 1fr; align-items: start; padding: 22px; } }
.calc-inputs { display: grid; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field-label { font-weight: 600; font-size: 15.5px; color: var(--heading); display: flex; justify-content: space-between; gap: 8px; padding: 0; }
.field-label output { color: var(--brand-2); font-weight: 700; }
.field-hint { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin-bottom: 4px; }
.input-wrap { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); overflow: hidden; }
.input-wrap:focus-within { border-color: var(--brand-2); }
.input-wrap input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 17px; font-weight: 600; padding: 9px 12px;
  direction: ltr; text-align: right;
}
.input-wrap input:focus { outline: none; }
.unit { padding: 0 12px; color: var(--muted); font-size: 14px; border-inline-start: 1px solid var(--border); }

.seg { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg--4 { grid-template-columns: repeat(4, 1fr); display: grid; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 6px 12px; border-radius: 9px; font-weight: 600; font-size: 15px; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--heading); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 3px solid var(--brand-2); }

.toggle { flex-direction: row; align-items: flex-start; gap: 12px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle-ui { flex: none; width: 44px; height: 26px; margin-top: 2px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; }
.toggle-ui::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: inset-inline-start .15s; }
.toggle input:checked + .toggle-ui { background: var(--brand-2); }
.toggle input:checked + .toggle-ui::after { inset-inline-start: 21px; }
.toggle input:focus-visible + .toggle-ui { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.toggle > span:last-child { display: flex; flex-direction: column; }

input[type="range"] { width: 100%; accent-color: var(--brand-2); margin: 4px 0 0; }

.calc-results { display: grid; gap: 12px; }
@media (min-width: 760px) { .calc-results { position: sticky; top: calc(var(--topbar-h) + 20px); } }
.result-main {
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px; border-radius: var(--radius-sm);
  background: #2D2A47; color: #fff;
}
.result-label { font-size: 14.5px; opacity: .85; }
.result-value { font-size: 38px; font-weight: 700; line-height: 1.3; }
.result-value small { font-size: 16px; font-weight: 500; opacity: .85; }
.result-note { font-size: 13.5px; opacity: .8; line-height: 1.6; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.result-grid > div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.result-grid dt { font-size: 13px; color: var(--muted); line-height: 1.5; }
.result-grid dd { margin: 0; font-weight: 700; font-size: 18px; color: var(--heading); }
.result-grid .danger { background: var(--red-bg); }
.result-grid .danger dt, .result-grid .danger dd { color: var(--red-tx); }
.calc-warn { margin: 0 !important; padding: 10px 12px; border-radius: 10px; background: var(--amber-bg); color: var(--amber-tx); font-size: 14.5px; line-height: 1.7; }

.checklist { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.checklist label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.checklist input { width: 20px; height: 20px; margin-top: 6px; flex: none; accent-color: var(--brand-2); }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--brand-2); }

.closing { text-align: center; margin: 48px 0 8px; font-size: 20px; font-weight: 700; color: var(--brand-2); }

/* ---------- التذييل ---------- */
.footer { margin-top: 48px; border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { max-width: 1180px; margin: 0 auto; padding: 22px 16px 28px; text-align: center; color: var(--muted); font-size: 15px; }
.footer p { margin: 4px 0; }
.footer strong { color: var(--heading); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; }

.to-top {
  position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 15;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-solid); color: #fff; text-decoration: none; font-size: 20px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.to-top.show { opacity: 1; pointer-events: auto; }

@media print {
  .topbar, .sidebar, .toc-block, .to-top, .actions, .footer-links { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .chapter { break-before: page; }
}
