/* ============================================
   مِداد — الأنماط المشتركة
   ============================================ */

:root {
  --bg: #F2EEE3;
  --surface: #FBF9F2;
  --text: #16231F;
  --text-soft: #3A4A42;
  --muted: #565B50;
  --line: #D8D0BC;

  --accent: #B87C24;
  --accent-strong: #96631A;
  --on-accent: #FBF9F2;

  --forest: #21503D;
  --forest-soft: #EAF0EA;
  --danger: #A23B2E;
  --danger-soft: #F7EAE7;

  --plate: #16231F;
  --on-plate: #F2EEE3;

  --font-display: 'Reem Kufi', Tahoma, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131914;
    --surface: #1B231C;
    --text: #EDE8D9;
    --text-soft: #C7C0AC;
    --muted: #9AA292;
    --line: #2C362D;

    --accent: #D9A24C;
    --accent-strong: #E8B463;
    --on-accent: #16231F;

    --forest: #4E9270;
    --forest-soft: #1D2A21;
    --danger: #D97862;
    --danger-soft: #2A1C19;

    --plate: #EDE8D9;
    --on-plate: #16231F;
  }
}

:root[data-theme="dark"] {
  --bg: #131914;
  --surface: #1B231C;
  --text: #EDE8D9;
  --text-soft: #C7C0AC;
  --muted: #9AA292;
  --line: #2C362D;

  --accent: #D9A24C;
  --accent-strong: #E8B463;
  --on-accent: #16231F;

  --forest: #4E9270;
  --forest-soft: #1D2A21;
  --danger: #D97862;
  --danger-soft: #2A1C19;

  --plate: #EDE8D9;
  --on-plate: #16231F;
}

/* ---------- الأساسيات ---------- */

* { box-sizing: border-box; }

/* لازم تسبق قواعد display حتى لا تتغلّب عليها عناصر مثل .pay-option */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }

body {
  direction: rtl;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.has-cart-bar { padding-bottom: 88px; }

::selection { background: var(--accent); color: var(--on-accent); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }

/* ---------- الترويسة ---------- */

header.site { padding: 22px 0 18px; border-bottom: 1px solid var(--line); }
.site-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand-mark { font-family: var(--font-display); font-size: 1.7rem; letter-spacing: 0.5px; }
.brand-sub { font-size: 0.78rem; color: var(--muted); border-right: 1px solid var(--line); padding-right: 10px; }

.cart-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--forest-soft); color: var(--forest);
  border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.cart-chip svg { width: 16px; height: 16px; flex-shrink: 0; }

.cart-count {
  background: var(--accent); color: var(--on-accent);
  min-width: 20px; height: 20px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; padding: 0 5px;
  font-variant-numeric: tabular-nums;
}

/* ---------- الواجهة الرئيسية ---------- */

.hero {
  padding: 56px 0 48px;
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: end;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  font-size: 0.78rem; color: var(--forest); letter-spacing: 0.06em; font-weight: 600;
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--forest); display: inline-block; }

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.15; font-weight: 700; margin: 0 0 18px;
  text-wrap: balance;
}

.hero-lede { color: var(--text-soft); font-size: 1.05rem; max-width: 46ch; }

.price-plate {
  background: var(--plate); color: var(--on-plate);
  padding: 26px 28px;
  border-top: 3px solid var(--accent);
}
.price-plate .from { font-size: 0.78rem; opacity: 0.7; margin-bottom: 6px; }
.price-plate .num {
  font-family: var(--font-display);
  font-size: 2.6rem; font-variant-numeric: tabular-nums;
  line-height: 1; display: inline-block;
}
.price-plate .cur {
  font-family: var(--font-body);
  background: var(--on-plate); color: var(--plate);
  font-size: 0.78rem; font-weight: 600;
  padding: 3px 8px; border-radius: 4px;
  margin-inline-start: 8px; vertical-align: middle;
}

/* ---------- الخدمات ---------- */

.section-head { padding: 44px 0 22px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-head h2 { font-family: var(--font-display); font-size: 1.5rem; }
.section-head p { color: var(--muted); font-size: 0.85rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; padding-bottom: 30px; }

.card { background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.swatch { height: 7px; width: 100%; }
.card-body { padding: 20px 20px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-tag { font-size: 0.72rem; color: var(--forest); font-weight: 600; letter-spacing: 0.04em; }
.card-title { font-size: 1.08rem; font-weight: 700; }
.card-desc { color: var(--muted); font-size: 0.88rem; line-height: 1.65; flex: 1; }

.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 10px; border-top: 1px dashed var(--line);
}
.card-price { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; }
.card-price small { font-weight: 500; font-size: 0.75rem; color: var(--muted); margin-inline-start: 3px; }

/* ---------- الأزرار ---------- */

.btn {
  font-family: var(--font-body);
  background: var(--text); color: var(--bg);
  border: none; padding: 9px 16px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.btn:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn[data-added="true"] { background: var(--forest); color: var(--bg); }

.btn-lg { padding: 14px 22px; font-size: 0.95rem; width: 100%; }

.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: transparent; color: var(--accent); border-color: var(--accent); }

/* ---------- التذييل ---------- */

footer.site {
  padding: 34px 0 40px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.82rem;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap;
}
footer.site .brand-mark { font-size: 1rem; color: var(--text); display: block; }

/* شارات وسائل الدفع المعتمدة */
.pay-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pay-badge {
  font-size: 0.7rem; font-weight: 600;
  color: var(--text-soft); background: var(--surface);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 9px; white-space: nowrap;
}

/* ---------- شريط السلة ---------- */

.cart-bar {
  position: fixed; inset-inline: 0; bottom: 0;
  background: var(--plate);
  border-top: 1px solid var(--line);
  z-index: 40;
  transform: translateY(0);
  transition: transform 0.2s ease;
}
.cart-bar.empty { transform: translateY(100%); }

.cart-summary {
  max-width: 1040px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  color: var(--on-plate);
}
.cart-summary .left { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; cursor: pointer; }
.cart-summary .total { font-family: var(--font-display); font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.cart-summary .toggle-icon { transition: transform 0.2s ease; opacity: 0.7; }
.cart-bar.open .toggle-icon { transform: rotate(180deg); }

.cart-panel { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; border-top: 1px solid transparent; }
.cart-bar.open .cart-panel { max-height: 60vh; overflow-y: auto; border-top-color: var(--line); }

.cart-items { max-width: 1040px; margin: 0 auto; padding: 6px 24px 18px; }

.cart-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-bottom: 1px dashed var(--line); color: var(--on-plate);
}
.cart-row .name { font-size: 0.9rem; font-weight: 600; }
.cart-row .line-price { font-size: 0.78rem; opacity: 0.7; font-variant-numeric: tabular-nums; }

.qty-controls { display: flex; align-items: center; gap: 10px; }
.qty-controls button {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--on-plate);
  font-size: 1rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.qty-controls button:hover { border-color: var(--accent); color: var(--accent); }
.qty-controls .qty { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; color: var(--on-plate); }

.remove-btn { background: none; border: none; color: var(--danger); font-size: 0.78rem; cursor: pointer; text-decoration: underline; padding: 0; font-family: var(--font-body); }

.empty-note { text-align: center; padding: 24px 0 10px; font-size: 0.85rem; opacity: 0.7; color: var(--on-plate); }

/* ============================================
   صفحة الدفع
   ============================================ */

.checkout-head { padding: 40px 0 8px; }
.checkout-head h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin-bottom: 8px; }
.checkout-head p { color: var(--muted); font-size: 0.9rem; }

.checkout-grid {
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 32px;
  padding: 28px 0 60px; align-items: start;
}

/* --- ملخص الطلب --- */

.summary {
  background: var(--surface); border: 1px solid var(--line);
  position: sticky; top: 24px;
}
.summary-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.summary-head h2 { font-family: var(--font-display); font-size: 1.1rem; }
.summary-head a { font-size: 0.78rem; color: var(--accent); }

.summary-lines { padding: 6px 20px; }
.summary-line {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
.summary-line:last-child { border-bottom: none; }
.summary-line .l-name { font-size: 0.88rem; font-weight: 600; }
.summary-line .l-meta { font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.summary-line .l-amount { font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.summary-totals { padding: 14px 20px 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.total-row { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.total-row.grand {
  font-size: 1.15rem; color: var(--text); font-weight: 700;
  font-family: var(--font-display);
  padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line);
}

/* --- النموذج --- */

.form-section { margin-bottom: 30px; }
.form-section > h2 {
  font-family: var(--font-display); font-size: 1.1rem;
  padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-body); font-size: 0.78rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }

.field label { font-size: 0.82rem; font-weight: 600; }
.field label .opt { font-weight: 400; color: var(--muted); font-size: 0.76rem; }

.field input, .field textarea {
  font-family: var(--font-body); font-size: 0.9rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); padding: 11px 13px;
  width: 100%;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: 0.8; }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
.field input[dir="ltr"] { text-align: right; font-variant-numeric: tabular-nums; }

.field .err { font-size: 0.76rem; color: var(--danger); display: none; }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.field.invalid .err { display: block; }

/* --- طرق الدفع --- */

.pay-methods { display: flex; flex-direction: column; gap: 12px; }

.pay-option {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--line); background: var(--surface);
  padding: 16px; cursor: pointer;
  transition: border-color 0.12s ease;
}
.pay-option:hover { border-color: var(--accent); }
.pay-option input { margin: 4px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.pay-option:has(input:checked),
.pay-option.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.pay-option .po-title { font-size: 0.92rem; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pay-option .po-desc { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

.badge {
  font-size: 0.68rem; font-weight: 600; padding: 2px 7px;
  background: var(--forest-soft); color: var(--forest); border-radius: 3px;
}

.pay-detail {
  display: none;
  margin-top: 14px; padding: 14px 16px;
  background: var(--bg); border: 1px dashed var(--line);
}
.pay-option:has(input:checked) + .pay-detail,
.pay-detail.show { display: block; }

.bank-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 0.84rem; }
.bank-row + .bank-row { border-top: 1px dashed var(--line); }
.bank-row .bk { color: var(--muted); }
.bank-row .bv { font-weight: 600; font-variant-numeric: tabular-nums; }
.bank-row .bv[dir="ltr"] { letter-spacing: 0.02em; }

.notice {
  font-size: 0.82rem; padding: 12px 14px;
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid currentColor;
}

.fine-print { font-size: 0.76rem; color: var(--muted); margin-top: 14px; line-height: 1.7; }
.fine-print a { color: var(--accent); text-underline-offset: 2px; }

/* --- شاشة التأكيد --- */

.confirm { padding: 60px 0 80px; max-width: 620px; margin: 0 auto; text-align: center; }
.confirm-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--forest); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
}
.confirm h1 { font-size: 1.9rem; margin-bottom: 12px; }
.confirm > p { color: var(--text-soft); font-size: 0.95rem; }

.order-ref {
  margin: 26px 0; padding: 20px;
  background: var(--plate); color: var(--on-plate);
  border-top: 3px solid var(--accent);
}
.order-ref .orl { font-size: 0.76rem; opacity: 0.7; margin-bottom: 6px; }
.order-ref .orv {
  font-family: var(--font-display); font-size: 1.7rem;
  letter-spacing: 0.06em; font-variant-numeric: tabular-nums;
}
.order-ref .ort { font-size: 0.84rem; opacity: 0.8; margin-top: 10px; }

.next-steps { text-align: right; background: var(--surface); border: 1px solid var(--line); padding: 20px; margin-bottom: 22px; }
.next-steps h3 { font-family: var(--font-display); font-size: 1rem; margin-bottom: 12px; }
.next-steps ol { margin: 0; padding-inline-start: 20px; color: var(--text-soft); font-size: 0.87rem; line-height: 1.9; }

.confirm-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* --- سلة فارغة --- */

.empty-cart { padding: 80px 0 100px; text-align: center; }
.empty-cart h1 { font-size: 1.6rem; margin-bottom: 12px; }
.empty-cart p { color: var(--muted); margin-bottom: 24px; font-size: 0.92rem; }

/* ============================================
   صفحات السياسات
   ============================================ */

.policy { padding-bottom: 70px; }

.policy-nav {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 26px 0 0;
}
.policy-nav a {
  font-size: 0.84rem; font-weight: 600;
  padding: 8px 15px; border: 1px solid var(--line);
  border-radius: 999px; text-decoration: none; color: var(--muted);
  transition: color 0.12s ease, border-color 0.12s ease;
}
.policy-nav a:hover { color: var(--accent); border-color: var(--accent); }
.policy-nav a[aria-current="page"] {
  background: var(--forest-soft); color: var(--forest); border-color: var(--forest);
}

.policy-head { padding: 32px 0 20px; border-bottom: 1px solid var(--line); }
.policy-head h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin-bottom: 10px; }
.policy-head .updated { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* بطاقة بيانات المزوّد / التواصل */
.legal-box {
  background: var(--surface); border: 1px solid var(--line);
  padding: 18px 20px; margin: 24px 0 8px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 26px;
}
.legal-box h2 { grid-column: 1 / -1; font-family: var(--font-display); font-size: 0.98rem; margin-bottom: 2px; }
.legal-item { display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; }
.legal-item .lk { font-size: 0.74rem; color: var(--muted); }
.legal-item .lv { font-weight: 600; }
.legal-item .lv[dir="ltr"] { font-variant-numeric: tabular-nums; }
.todo { color: var(--danger); font-weight: 500; font-size: 0.8rem; }

/* نص السياسة */
.policy-body { max-width: 68ch; padding-top: 26px; }
.policy-body section + section { margin-top: 30px; }
.policy-body h2 {
  font-family: var(--font-display); font-size: 1.12rem;
  margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline;
}
.policy-body h2 .sn {
  font-family: var(--font-body); font-size: 0.8rem; font-weight: 700;
  color: var(--accent); font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.policy-body h3 { font-size: 0.95rem; margin: 18px 0 6px; }
.policy-body p { color: var(--text-soft); font-size: 0.92rem; line-height: 1.85; }
.policy-body p + p { margin-top: 10px; }
.policy-body ul, .policy-body ol {
  color: var(--text-soft); font-size: 0.92rem; line-height: 1.85;
  margin: 10px 0 0; padding-inline-start: 22px;
}
.policy-body li + li { margin-top: 6px; }
.policy-body strong { color: var(--text); font-weight: 700; }
.policy-body a { color: var(--accent); }

/* جدول نسب الاسترداد */
.policy-table-wrap { overflow-x: auto; margin-top: 14px; }
.policy-table { border-collapse: collapse; width: 100%; min-width: 420px; font-size: 0.88rem; }
.policy-table th, .policy-table td {
  border: 1px solid var(--line); padding: 10px 13px; text-align: right; vertical-align: top;
}
.policy-table th { background: var(--forest-soft); color: var(--forest); font-weight: 700; font-size: 0.82rem; }
.policy-table td { color: var(--text-soft); }
.policy-table td.pct { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* تنبيه داخل النص */
.callout {
  border-inline-start: 3px solid var(--accent);
  background: var(--surface);
  padding: 14px 16px; margin-top: 16px;
  font-size: 0.88rem; color: var(--text-soft); line-height: 1.8;
}

/* روابط التذييل */
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* ---------- الاستجابة ---------- */

@media (max-width: 860px) {
  .checkout-grid { grid-template-columns: 1fr; }
  .summary { position: static; order: -1; }
}

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; }
  .price-plate { justify-self: start; }
  .field-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
