/* ============================================================================
   جنبك — طبقة المكوّنات الموحّدة
   ----------------------------------------------------------------------------
   brand.css يحمل الرموز (ألوان، استدارات، ظلال) ومكوّنات هوية «سوق جنبك».
   هذا الملف يبني فوقها الهيكل المشترك بين التطبيقات الأربعة — الراكب،
   الكابتن، السوق، ولوحة التحكم — حتى تبدو منتجاً واحداً لا أربعة.

   قاعدة: لا لون ثابت هنا. كل شيء عبر متغيّرات brand.css ليعمل الوضع
   الليلي والتلوين المتعدّد بلا تكرار.
   ============================================================================ */

/* ============================================================ الهيكل العام */
.jb-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.jb-main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  padding: 18px 16px calc(var(--nav-h) + 26px + env(safe-area-inset-bottom));
}
.jb-main.wide { max-width: 1240px; }
.jb-main.flush { padding-inline: 0; }

/* بلا شريط سفلي (اللوحات المكتبية والصفحات القانونية) */
.jb-main.no-nav { padding-bottom: 40px; }

/* ============================================================ الرأس */
.jb-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-top));
  padding-top: max(10px, env(safe-area-inset-top));
  min-height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid var(--line);
}
.jb-header .grow { flex: 1; min-width: 0; }

/* زر أيقوني — 44×44 حد أدنى للمس */
.jb-iconbtn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.jb-iconbtn:hover  { border-color: var(--brand-500); color: var(--brand-600); }
.jb-iconbtn:active { transform: scale(.94); }
.jb-iconbtn.plain  { border-color: transparent; background: transparent; }

/* عدّاد فوق زر (السلة، الإشعارات) */
.jb-count {
  position: absolute;
  inset-block-start: -5px; inset-inline-start: -5px;
  min-width: 19px; height: 19px; padding: 0 5px;
  display: none; place-items: center;
  border-radius: var(--r-pill);
  background: var(--err); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 1;
  border: 2px solid var(--surface);
}
.jb-count.on { display: grid; }
.jb-count-wrap { position: relative; }

/* ============================================================ الشريط السفلي */
.jb-nav {
  position: fixed;
  inset-inline: 0; bottom: 0;
  z-index: 45;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border-top: 1px solid var(--line);
}
.jb-nav a {
  min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 11px; font-weight: 700;
  transition: color var(--t-fast), background var(--t-fast);
  position: relative;
}
.jb-nav a svg { width: 21px; height: 21px; }
.jb-nav a:active { background: var(--surface-3); }
.jb-nav a.on { color: var(--brand-600); }
.jb-nav a.on::before {
  content: ""; position: absolute; top: 2px;
  width: 22px; height: 3px; border-radius: var(--r-pill);
  background: var(--grad-brand);
}

/* ============================================================ عناوين الأقسام */
.jb-kicker {
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
  color: var(--brand-600);
  font-size: 11.5px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
}

.jb-sec { margin-bottom: 26px; }

.jb-sec-h {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 13px;
}
.jb-sec-h h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.jb-sec-h p  { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.jb-sec-h a  {
  font-size: 13px; font-weight: 700; color: var(--brand-600);
  text-decoration: none; white-space: nowrap;
}
.jb-sec-h a:hover { text-decoration: underline; }

/* ============================================================ الأزرار الناعمة */
.jb-btn.soft {
  background: color-mix(in srgb, var(--brand-500) 12%, transparent);
  color: var(--brand-700);
  border: 1.5px solid color-mix(in srgb, var(--brand-500) 18%, transparent);
  box-shadow: none;
  border-radius: var(--r-pill);
}
.jb-btn.soft:hover {
  background: color-mix(in srgb, var(--brand-500) 18%, transparent);
  transform: none;
  box-shadow: none;
}
:root[data-theme="dark"] .jb-btn.soft { color: var(--brand-300); }

.jb-btn.pill { border-radius: var(--r-pill); }

/* ============================================================ شارات النطاق */
/* تُستخدم في السوق والشحن الدولي: قريب / داخل السودان / إقليمي / دولي */
.jb-scope {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r-pill); padding: 5px 11px;
  font-size: 11.5px; font-weight: 800;
}
.jb-scope.nearby { color: var(--brand-800); background: color-mix(in srgb, #22C55E 16%, transparent); }
.jb-scope.local  { color: var(--brand-700); background: color-mix(in srgb, #14B8A6 16%, transparent); }
.jb-scope.region { color: #7C2D12;          background: color-mix(in srgb, #F97316 16%, transparent); }
.jb-scope.intl   { color: #3730A3;          background: color-mix(in srgb, #4F46E5 16%, transparent); }
:root[data-theme="dark"] .jb-scope.nearby { color: #86EFAC; }
:root[data-theme="dark"] .jb-scope.local  { color: #5EEAD4; }
:root[data-theme="dark"] .jb-scope.region { color: #FDBA74; }
:root[data-theme="dark"] .jb-scope.intl   { color: #A5B4FC; }

/* حالة/دور */
.jb-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 700;
}
.jb-pill.active  { background: var(--ok-bg);   color: var(--ok); }
.jb-pill.pending { background: var(--warn-bg); color: var(--warn); }
.jb-pill.stopped { background: var(--err-bg);  color: var(--err); }
.jb-pill.mute    { background: var(--surface-3); color: var(--muted); }

/* ============================================================ الحالة الفارغة */
.jb-empty {
  padding: 34px 24px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1.5px dashed var(--line);
  text-align: center;
}
.jb-empty .ic {
  width: 56px; height: 56px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: var(--brand-50); color: var(--brand-600);
}
:root[data-theme="dark"] .jb-empty .ic { background: color-mix(in srgb, var(--brand-500) 14%, transparent); }
.jb-empty h3 { margin: 0 0 6px; font-size: 16px; }
.jb-empty p  { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.8; }
.jb-empty .jb-btn { margin-top: 16px; }

/* ============================================================ روابط سريعة */
.jb-quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.jb-quick a {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink); font-weight: 700; font-size: 13.5px;
  text-decoration: none;
  box-shadow: var(--sh-xs);
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.jb-quick a:hover { transform: translateY(-2px); border-color: var(--brand-200); box-shadow: var(--sh-md); }
.jb-quick a svg { width: 19px; height: 19px; color: var(--brand-600); flex: none; }

/* ============================================================ صفوف القائمة */
.jb-rows { display: grid; gap: 10px; }
.jb-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  color: inherit; text-decoration: none;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.jb-row:hover  { border-color: var(--brand-200); }
.jb-row:active { transform: scale(.99); }
.jb-row .ic {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--brand-50); color: var(--brand-600);
}
:root[data-theme="dark"] .jb-row .ic { background: color-mix(in srgb, var(--brand-500) 14%, transparent); }
.jb-row .bd  { flex: 1; min-width: 0; }
.jb-row .t   { font-size: 14px; font-weight: 700; }
.jb-row .s   { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.jb-row .e   { flex: none; text-align: end; font-size: 13px; font-weight: 700; }

/* ============================================================ بطاقة الحساب */
.jb-account {
  padding: 20px;
  border-radius: var(--r-xl);
  background: var(--grad-hero);
  border: 1px solid var(--line);
  box-shadow: var(--sh-md);
}
.jb-avatar {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: var(--grad-brand); color: #fff;
  font-weight: 800; font-size: 19px;
  box-shadow: var(--sh-brand);
}

/* ============================================================ لوحة الخريطة */
.jb-map {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-3);
  box-shadow: var(--sh-sm);
}
.jb-map .canvas { width: 100%; height: 100%; min-height: 220px; }
.jb-map.tall .canvas { min-height: 380px; }

/* شريط معلومات عائم فوق الخريطة: المسافة، الوصول، الازدحام */
.jb-map-hud {
  position: absolute;
  inset-inline: 10px; bottom: 10px;
  z-index: 500;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  border: 1px solid var(--line);
  box-shadow: var(--sh-md);
}
.jb-map-hud .item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; }
.jb-map-hud .item svg { width: 15px; height: 15px; color: var(--brand-600); }
.jb-map-hud .item .v { color: var(--ink); }
.jb-map-hud .item .k { color: var(--muted); font-weight: 600; }
.jb-map-hud .sp { flex: 1; }

/* أزرار عائمة على الخريطة (تحديد موقعي، ملء الشاشة) */
.jb-map-ctl {
  position: absolute;
  inset-inline-end: 10px; top: 10px;
  z-index: 500;
  display: grid; gap: 8px;
}
.jb-map-ctl button {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink-2); cursor: pointer;
  box-shadow: var(--sh-sm);
  transition: color var(--t-fast), transform var(--t-fast);
}
.jb-map-ctl button:hover  { color: var(--brand-600); }
.jb-map-ctl button:active { transform: scale(.93); }

/* مؤشّر الازدحام */
.jb-traffic { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; }
.jb-traffic::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
}
.jb-traffic.moderate       { color: var(--warn); }
.jb-traffic.moderate::before { background: var(--warn); }
.jb-traffic.heavy          { color: var(--err); }
.jb-traffic.heavy::before  { background: var(--err); }
.jb-traffic.light          { color: var(--ok); }

/* ============================================================ الإشعار العائم */
.jb-toast {
  position: fixed;
  inset-inline: 16px;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  z-index: 90;
  max-width: 420px;
  margin-inline: auto;
  padding: 13px 17px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--surface);
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--sh-lg);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
}
.jb-toast.on  { opacity: 1; transform: none; }
.jb-toast.err { background: var(--err); color: #fff; }

/* ============================================================ الشاشة المنبثقة */
.jb-sheet-back {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 15, 20, .5);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base);
}
.jb-sheet-back.on { opacity: 1; pointer-events: auto; }

.jb-sheet {
  position: fixed;
  inset-inline: 0; bottom: 0; z-index: 81;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface);
  box-shadow: var(--sh-xl);
  transform: translateY(100%);
  transition: transform var(--t-slow);
}
.jb-sheet.on { transform: none; }
.jb-sheet::before {
  content: ""; display: block;
  width: 42px; height: 4px; margin: 6px auto 16px;
  border-radius: var(--r-pill);
  background: var(--line);
}
@media (min-width: 720px) {
  .jb-sheet { inset-inline: auto; inset-inline-start: 50%; transform: translate(-50%, 100%);
              width: 460px; border-radius: var(--r-xl); bottom: 24px; }
  .jb-sheet.on { transform: translate(-50%, 0); }
}

/* ============================================================ مبدّل الوضع */
/* «جنبك رايد ⇄ سوق جنبك» — العنصر الذي يوحّد المنصتين */
.jb-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.jb-switch a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 700;
  color: var(--muted); text-decoration: none;
  transition: background var(--t-base), color var(--t-base);
}
.jb-switch a svg { width: 15px; height: 15px; }
.jb-switch a.on {
  background: var(--surface);
  color: var(--brand-600);
  box-shadow: var(--sh-xs);
}

/* ============================================================ مساعدات */
.jb-stack   { display: grid; gap: 12px; }
.jb-inline  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.jb-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.jb-grow    { flex: 1; min-width: 0; }
.jb-mute    { color: var(--muted); }
.jb-sm      { font-size: 12.5px; }
.jb-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jb-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* شريط تمرير أفقي بلا مقبض */
.jb-scroll-x {
  display: flex; gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding-bottom: 4px;
}
.jb-scroll-x::-webkit-scrollbar { display: none; }
.jb-scroll-x > * { scroll-snap-align: start; flex: none; }

/* ==================================================== شريط الشركاء والرعاة */
/* علامات ترعى المنصة. الشعارات ملك أصحابها، فنعرضها بحيادية:
   بلا قصّ، بلا تلوين، وعلى خلفية محايدة تناسب الشعارات الملوّنة. */
.sponsors .sp-strip{
  display:flex;gap:12px;overflow-x:auto;padding:4px 2px 10px;
  scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch;
}
.sponsors .sp-strip::-webkit-scrollbar{height:4px}
.sponsors .sp-strip::-webkit-scrollbar-thumb{background:var(--line-2);border-radius:99px}

.sp-item{
  flex:none;scroll-snap-align:start;
  width:118px;height:74px;
  display:grid;place-items:center;padding:10px;
  background:var(--surface);border:1px solid var(--line);
  border-radius:var(--r-md);
  transition:transform var(--t-fast),box-shadow var(--t-fast),border-color var(--t-fast);
}
a.sp-item:hover{transform:translateY(-2px);box-shadow:var(--sh-sm);border-color:var(--brand-300)}
.sp-item img{max-width:100%;max-height:52px;object-fit:contain}
.sp-item .sp-txt{
  font-size:12.5px;font-weight:700;color:var(--ink-2);text-align:center;line-height:1.4;
  overflow:hidden;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;
}

/* الوضع الليلي: الشعارات غالباً مصمَّمة لخلفية بيضاء، فنُبقيها عليها
   بدل قلبها — قلب الألوان يشوّه هوية العلامة. */
:root[data-theme="dark"] .sp-item{background:#F7F9F9;border-color:transparent}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .sp-item{background:#F7F9F9;border-color:transparent}
}

/* ============================================ نائب صورة المنتج */
/*
 * لا صورة لكل منتج، وترك مربّع رمادي فارغ يوحي بصفحة معطّلة.
 * الحرف الأول على تدرّج مشتقّ من اسم المنتج يبدو تصميماً مقصوداً،
 * ويمنح كل منتج لوناً ثابتاً يميّزه.
 *
 * --ph-h تُمرَّر من JS كنمط مضمّن؛ نعلن الافتراضي هنا كي يبقى النائب
 * صالحاً لو لم تصل القيمة لأي سبب.
 */
:root{ --ph-h: 170; }

.prod .ph-mark{
  position:absolute;inset:0;
  display:grid;place-items:center;
  background:
    linear-gradient(135deg,
      hsl(var(--ph-h, 170) 46% 92%),
      hsl(calc(var(--ph-h, 170) + 26) 40% 84%));
}
.prod .ph-mark b{
  font-family:var(--font-display);
  font-size:34px;font-weight:800;line-height:1;
  color:hsl(var(--ph-h, 170) 52% 30%);
  opacity:.85;
}

:root[data-theme="dark"] .prod .ph-mark{
  background:
    linear-gradient(135deg,
      hsl(var(--ph-h, 170) 24% 22%),
      hsl(calc(var(--ph-h, 170) + 26) 20% 17%));
}
:root[data-theme="dark"] .prod .ph-mark b{ color:hsl(var(--ph-h, 170) 40% 72%) }
