@import url("/assets/fonts.css");

/* ═══════════════════════════════════════════════════════════════════
   واجهة المتجر — موبايل أولاً، عرض أقصى 480 بكسل.
   لا لون هوية ثابت هنا: --brand و--brand-dark تُحقنان من صف المتجر.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --ink:      #1d1d2b;
  --muted:    #6f6f85;
  --faint:    #9c9cb0;
  --line:     #e9e9f1;
  --bg:       #f2f2f6;
  --frame:    #f6f6fa;   /* خلفية صندوق الصور — محايدة فاتحة */
  --surface:  #ffffff;
  --ok:       #1a7f52;
  --ok-bg:    #e7f6ee;
  --sale:     #d92d20;

  --bar-height: 3.875rem;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* السمة hidden يجب أن تسبق أي display في الأنماط — وإلا ظهر المخفي */
[hidden] { display: none !important; }

/* تسمية للقارئ الآلي دون أن تُرى — الحقول تكتفي بالـplaceholder بصرياً */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Tajawal", system-ui, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  min-height: 100vh;
  padding-bottom: calc(var(--bar-height) + env(safe-area-inset-bottom, 0px) + 1rem);
  overflow-x: hidden;
}

/* الصفحات بلا شريط سفلي لا تحتاج حشوه */
.shell.no-bar { padding-bottom: 2rem; }

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.4; }
img { max-width: 100%; display: block; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ═══ ١ · المعرض ═══════════════════════════════════════════════════ */

.gallery { position: relative; background: var(--bg); }

.slides {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.slides::-webkit-scrollbar { display: none; }

.slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  /* النسبة تثبّت ارتفاع الصندوق فلا تقفز الصفحة بين صورة وأخرى */
  aspect-ratio: 4 / 3;
  background: var(--frame);
}

/* contain لا cover: الصورة كاملة مهما كانت نسبتها، والفراغ يملؤه الإطار */
.slide img { width: 100%; height: 100%; object-fit: contain; }

.slide.empty {
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: .9375rem;
}

.back {
  position: absolute;
  inset-block-start: .875rem;
  inset-inline-start: .875rem;
  z-index: 3;
  width: 2.375rem;
  height: 2.375rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  cursor: pointer;
}

/* السهم يشير إلى الخلف في الاتجاه العربي */
.back svg { transform: scaleX(1); }

.dots {
  position: absolute;
  inset-block-end: .875rem;
  inset-inline: 0;
  display: flex;
  justify-content: center;
  gap: .375rem;
  z-index: 2;
}

.dot {
  width: .4375rem;
  height: .4375rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .65);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  cursor: pointer;
  transition: width .2s, background .2s;
}

.dot.on { width: 1.125rem; border-radius: 999px; background: #fff; }

/* ═══ ٢ · الاسم والسعر ═════════════════════════════════════════════ */

.head { padding: 1.125rem 1.125rem .25rem; }
.head h1 { font-size: 1.3125rem; }
.head .short { margin: .25rem 0 0; color: var(--muted); font-size: .9375rem; }

.prices { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .625rem; }
.prices .now { font-size: 1.375rem; font-weight: 700; color: var(--brand); }
.prices .now small { font-size: .875rem; font-weight: 500; }
.prices .was { color: var(--faint); text-decoration: line-through; font-size: 1rem; }

.prices .save {
  padding: .0625rem .5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--sale) 12%, white);
  color: var(--sale);
  font-size: .8125rem;
  font-weight: 700;
}

/* ═══ ٣ · العرض الافتراضي ══════════════════════════════════════════ */

.hero-offer {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin: 1rem 1.125rem 0;
  padding: .875rem 1rem;
  border: 1px solid color-mix(in srgb, var(--brand) 25%, white);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--brand) 8%, white);
}

.hero-offer p {
  margin: 0;
  flex: 1;
  color: var(--brand-dark);
  font-size: 1.0625rem;
  font-weight: 700;
}

.hero-offer .badge {
  padding: .125rem .5rem;
  border-radius: 999px;
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ═══ ٤ · سطر الثقة ════════════════════════════════════════════════ */

.trust {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin: 1rem 1.125rem 0;
  padding: .875rem .5rem;
  border-block: 1px solid var(--line);
}

.trust div { display: flex; flex-direction: column; align-items: center; gap: .25rem; text-align: center; }
.trust svg { color: var(--brand); width: 1.375rem; height: 1.375rem; }
.trust span { color: var(--muted); font-size: .75rem; font-weight: 500; line-height: 1.4; }

/* ═══ ٥ · التفاصيل ═════════════════════════════════════════════════ */

.details { padding: 1.25rem 1.125rem 0; }
.details h2 { font-size: 1.0625rem; margin-bottom: .75rem; }
.details .block + .block { margin-top: 1.125rem; }
.details h3 { font-size: .9375rem; margin-bottom: .375rem; color: var(--brand-dark); }
.details p { margin: 0; color: #45455c; font-size: .9375rem; }
.details img { width: 100%; border-radius: var(--radius); margin: .5rem 0; }

/* ═══ ٦ · الفاصل ═══════════════════════════════════════════════════ */

.divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.75rem 1.125rem 1.25rem;
  color: var(--faint);
  font-size: .8125rem;
  font-weight: 500;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ═══ ٧ · الفورم ═══════════════════════════════════════════════════ */

.order { padding: 0 1.125rem; }

.step { margin: 0 0 1rem; padding: 0; border: 0; }

.step legend {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .625rem;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
}

.step .num {
  display: grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: .875rem;
}

/* ── العروض ── */

.offers { display: flex; flex-direction: column; gap: .5rem; }

.offer {
  position: relative;
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .6875rem .75rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.offer input { position: absolute; opacity: 0; pointer-events: none; }

.offer::before {
  content: '';
  flex: 0 0 auto;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid var(--line);
  border-radius: 50%;
  transition: border-color .15s, box-shadow .15s;
}

.offer.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 5%, white); }
.offer.on::before { border-color: var(--brand); box-shadow: inset 0 0 0 3px var(--brand); }

.offer .text { flex: 1; font-size: .9375rem; font-weight: 500; }
.offer .amount { font-weight: 700; color: var(--brand-dark); white-space: nowrap; }

.offer .tag {
  padding: .0625rem .4375rem;
  border-radius: 999px;
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ── الخيارات ── */

.option { margin-top: 1rem; }
.option-name { display: block; margin-bottom: .5rem; font-size: .875rem; font-weight: 700; }
.option-name i { color: var(--sale); font-style: normal; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .4375rem .75rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: .875rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip img { width: 1.5rem; height: 1.5rem; border-radius: 50%; object-fit: cover; }
.chip small { color: var(--muted); font-size: .75rem; }
.chip.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, white); font-weight: 700; }

/* ── الحقول ── */

.field { margin-bottom: .5rem; }

.field input, .field select, .field textarea {
  width: 100%;
  padding: .5625rem .75rem;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #fbfbfd;
  color: inherit;
  font: inherit;
  /* 16px مقصود: أي أصغر يجعل iOS يكبّر الصفحة عند التركيز على الحقل */
  font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}

.field textarea { resize: vertical; line-height: 1.6; }

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
  background: #fff;
}

.field input.bad { border-color: var(--sale); }
.field .err { margin: .375rem 0 0; color: var(--sale); font-size: .8125rem; }

/* ── كود الخصم ── */

.coupon-row { display: flex; gap: .5rem; }
.coupon-row input { flex: 1; min-width: 0; text-transform: uppercase; }

.coupon-apply {
  flex: 0 0 auto;
  padding: 0 1rem;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.coupon-apply:hover { border-color: var(--brand); background: #fbfbfd; }
.coupon-apply:active { transform: translateY(1px); }

/* الأخضر هو الافتراضي: أغلب ما يُعرض هنا نجاحُ تطبيق */
.coupon-note { margin: .375rem 0 0; color: var(--ok, #1a9e5f); font-size: .8125rem; }
.coupon-note.bad { color: var(--sale); }

/* ── الملخّص ── */

.summary {
  margin-top: .75rem;
  padding: .625rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafc;
}

.summary .line { display: flex; justify-content: space-between; gap: 1rem; font-size: .875rem; line-height: 1.6; }
.summary .line span { color: var(--muted); }
.summary .line b { font-weight: 500; }
.summary .off b { color: var(--ok, #1a9e5f); }

.summary .total {
  margin-top: .375rem;
  padding-top: .375rem;
  border-top: 1px dashed var(--line);
  font-size: 1rem;
}

.summary .total span { color: var(--ink); font-weight: 700; }
.summary .total b { color: var(--brand); font-weight: 700; }
.summary .note { margin: .375rem 0 0; color: var(--faint); font-size: .75rem; }

/* ── زر الطلب ── */

.order-button {
  width: 100%;
  margin-top: 1rem;
  padding: .875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .625rem;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent);
  transition: transform .1s, box-shadow .15s;
}

.order-button:active { transform: translateY(1px); box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 30%, transparent); }
.order-button b { font-weight: 700; opacity: .92; }

.pending {
  margin: .625rem 0 0;
  padding: .625rem .875rem;
  border-radius: 10px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: .875rem;
  text-align: center;
}

/* ═══ ٨ · الشريط السفلي ════════════════════════════════════════════ */

.bar {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: 10;
  max-width: 480px;
  margin: 0 auto;
  height: calc(var(--bar-height) + env(safe-area-inset-bottom, 0px));
  padding: .625rem 1rem calc(.625rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: .875rem;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.bar-price { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.bar-price small { color: var(--muted); font-size: .75rem; }
.bar-price b { color: var(--brand-dark); font-size: 1.0625rem; font-weight: 700; }

.bar-button {
  flex: 0 0 auto;
  padding: .6875rem 1.5rem;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.bar-button:active { transform: translateY(1px); }

/* ═══ القائمة والصفحات الفارغة ═════════════════════════════════════ */

.store-head { padding: 1.25rem 1.125rem; text-align: center; border-bottom: 1px solid var(--line); }
.store-head h1 { font-size: 1.25rem; color: var(--brand-dark); }
.store-head .logo { max-height: 3rem; margin: 0 auto; object-fit: contain; }

.catalog {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  padding: 1rem 1.125rem;
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.card:active { transform: translateY(1px); }

.card-image { aspect-ratio: 4 / 3; background: var(--bg); display: grid; place-items: center; }
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-image .empty { color: var(--faint); font-size: .8125rem; }

.card-body { padding: .625rem .75rem .75rem; }
.card-body h2 { font-size: .9375rem; font-weight: 500; }

.card-price { display: flex; align-items: baseline; gap: .5rem; margin-top: .25rem; flex-wrap: wrap; }
.card-price .now { color: var(--brand); font-weight: 700; font-size: .9375rem; }
.card-price .was { color: var(--faint); text-decoration: line-through; font-size: .8125rem; }

.blank { padding: 3rem 1.5rem; text-align: center; color: var(--muted); }
.blank.tall { min-height: 70vh; display: grid; place-content: center; gap: .5rem; }
.blank h1 { font-size: 1.25rem; color: var(--ink); }
.blank p { margin: 0; font-size: .9375rem; }

.ghost-button {
  display: inline-block;
  margin-top: .75rem;
  padding: .625rem 1.25rem;
  border: 1.5px solid var(--brand);
  border-radius: 10px;
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}


/* ═══ أخطاء الفورم ═════════════════════════════════════════════════ */

.form-errors {
  margin-bottom: 1rem;
  padding: .75rem .875rem;
  border: 1px solid color-mix(in srgb, var(--sale) 30%, white);
  border-radius: 10px;
  background: color-mix(in srgb, var(--sale) 8%, white);
}

.form-errors p { margin: 0; color: var(--sale); font-size: .875rem; }
.form-errors p + p { margin-top: .25rem; }

/* ═══ صفحة الشكر ═══════════════════════════════════════════════════ */

.thanks { padding: 2rem 1.125rem 1.5rem; text-align: center; }

.thanks .tick {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 12%, white);
  color: var(--brand);
}

.thanks .tick svg { width: 2rem; height: 2rem; stroke-width: 2.4; }

.thanks h1 { font-size: 1.375rem; }
.thanks .lead { margin: .375rem 0 1.25rem; color: var(--muted); font-size: .9375rem; }

.order-no {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.25rem;
  padding: .4375rem .875rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 8%, white);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, white);
}

.order-no span { color: var(--muted); font-size: .8125rem; }
.order-no b { color: var(--brand-dark); font-size: 1.0625rem; font-variant-numeric: tabular-nums; }

.receipt, .who {
  margin-bottom: 1rem;
  padding: .875rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafc;
  text-align: right;
}

.receipt .line, .who .line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  font-size: .9375rem;
}

.receipt .line + .line, .who .line + .line { margin-top: .5rem; }
.receipt .muted, .who span:first-child { color: var(--muted); font-size: .8125rem; }
.receipt .item b { font-weight: 700; }
.who b { font-weight: 500; }
.who b.ltr { direction: ltr; unicode-bidi: isolate; }

.receipt .total {
  margin-top: .625rem;
  padding-top: .625rem;
  border-top: 1px dashed var(--line);
  font-size: 1.0625rem;
}

.receipt .total span { color: var(--ink); font-weight: 700; font-size: 1rem; }
.receipt .total b { color: var(--brand); }

.whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .8125rem 1rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.whatsapp svg { width: 1.25rem; height: 1.25rem; stroke-width: 1.9; }

.thanks .keep { margin: 1rem 0 0; color: var(--faint); font-size: .8125rem; }
.thanks .more { display: inline-block; margin-top: 1rem; color: var(--brand-dark); font-weight: 700; }

/* ═══ تفضيلات المستخدم ═════════════════════════════════════════════ */

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