/* ============================================================
   طاولتي — نظام التصميم
   الفكرة: اللون البرتقالي/الذهبي للعلامة، والأسود الدافئ للنص،
   والعنصر المميّز هو "مؤشر القرب" الذي يترجم المسافة إلى قوس بصري.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700;800;900&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  /* لوحة الألوان */
  --flame:   #ED6A2C;   /* برتقالي العلامة */
  --flame-d: #C9521A;
  --amber:   #F9B233;   /* ذهبي العلامة */
  --amber-l: #FFE7B8;
  --basil:   #16A46B;   /* أخضر الإجراءات */
  --basil-l: #E4F7EE;
  --ink:     #1A1512;   /* أسود دافئ */
  --ink-60:  #6B6058;
  --ink-40:  #9A8F86;
  --paper:   #FFFDFA;
  --sand:    #FFF6EA;
  --line:    #EFE4D6;
  --danger:  #D93B30;
  --danger-l:#FDECEA;

  /* الخطوط */
  --display: 'Rubik', system-ui, sans-serif;
  --body:    'IBM Plex Sans Arabic', 'Rubik', system-ui, sans-serif;

  /* المقاييس */
  --r-sm: 10px; --r-md: 16px; --r-lg: 24px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(26,21,18,.06), 0 4px 14px rgba(26,21,18,.05);
  --shadow-2: 0 8px 28px rgba(26,21,18,.10);
  --shadow-flame: 0 10px 24px rgba(237,106,44,.28);
  --nav-h: 68px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; direction: rtl; text-align: right;
  font-family: var(--body); color: var(--ink); background: var(--paper);
  font-size: 15px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: var(--display); font-weight: 800; margin: 0; line-height: 1.2; letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.15rem; font-weight: 700; }
a  { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 6px; }

.wrap { width: min(1240px, 100% - 40px); margin-inline: auto; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; }
.muted { color: var(--ink-60); }
.tiny  { font-size: .8rem; }
.num   { font-family: var(--display); font-variant-numeric: tabular-nums; font-weight: 600; }
.hidden { display: none !important; }
.center { text-align: center; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60; height: var(--nav-h);
  background: rgba(255,253,250,.88); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { height: 100%; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 900; font-size: 1.25rem; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--amber), var(--flame)); color: #fff;
  box-shadow: var(--shadow-flame); font-size: 20px;
}
.brand small { display: block; font-family: var(--body); font-size: .62rem; font-weight: 600;
  letter-spacing: .22em; color: var(--flame); margin-top: -4px; }

/* حبة الموقع — العنصر الذي يربط كل شيء بموقع المستخدم */
.loc-pill {
  display: inline-flex; align-items: center; gap: 8px; max-width: 340px;
  padding: 7px 14px 7px 10px; border-radius: var(--r-pill);
  background: var(--sand); border: 1px solid var(--line); cursor: pointer;
  transition: border-color .18s, transform .18s;
}
.loc-pill:hover { border-color: var(--flame); transform: translateY(-1px); }
.loc-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--basil); flex: none;
  box-shadow: 0 0 0 4px var(--basil-l); }
.loc-pill.off .dot { background: var(--ink-40); box-shadow: 0 0 0 4px var(--line); }
.loc-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .85rem; font-weight: 600; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--r-pill); border: 1px solid transparent;
  font-family: var(--display); font-weight: 600; font-size: .92rem; cursor: pointer;
  background: var(--sand); color: var(--ink); transition: transform .16s, box-shadow .16s, background .16s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--flame); color: #fff; box-shadow: var(--shadow-flame); }
.btn-primary:hover { background: var(--flame-d); }
.btn-go      { background: var(--basil); color: #fff; box-shadow: 0 10px 22px rgba(22,164,107,.26); }
.btn-ghost   { background: transparent; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--flame); color: var(--flame); }
.btn-danger  { background: var(--danger-l); color: var(--danger); }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- الحقول ---------- */
.field { display: block; }
.field > label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-60); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--flame); box-shadow: 0 0 0 4px rgba(237,106,44,.12); outline: none; }
textarea.input { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* ---------- البطاقات ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.card-pad { padding: 20px; }
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }

/* ---------- الشارات ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px;
  border-radius: var(--r-pill); font-size: .75rem; font-weight: 700; font-family: var(--display);
  background: var(--sand); color: var(--ink-60);
}
.badge-open   { background: var(--basil-l); color: var(--basil); }
.badge-closed { background: var(--danger-l); color: var(--danger); }
.badge-hot    { background: linear-gradient(135deg, var(--amber), var(--flame)); color: #fff; }
.badge-wait   { background: var(--amber-l); color: #8A5A00; }

/* حالات الطلب */
.st { padding: 4px 12px; border-radius: var(--r-pill); font-size: .75rem; font-weight: 700; font-family: var(--display); white-space: nowrap; }
.st-pending   { background: var(--amber-l);  color: #8A5A00; }
.st-accepted,
.st-preparing { background: #E7F0FF; color: #1D4ED8; }
.st-ready     { background: #EDE9FE; color: #6D28D9; }
.st-assigned,
.st-picked_up { background: #FFF0E4; color: var(--flame-d); }
.st-delivered { background: var(--basil-l); color: var(--basil); }
.st-cancelled,
.st-rejected  { background: var(--danger-l); color: var(--danger); }

/* ============================================================
   العنصر المميّز: مؤشر القرب
   قوس يمتلئ كلما اقترب المطعم من المستخدم داخل نطاق التوصيل.
   ============================================================ */
.prox { position: relative; width: 46px; height: 46px; flex: none; }
.prox svg { transform: rotate(-90deg); }
.prox .track { stroke: var(--line); }
.prox .fill  { stroke: url(#proxGrad); stroke-linecap: round;
  transition: stroke-dashoffset .7s cubic-bezier(.22,1,.36,1); }
.prox b {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--display); font-size: .68rem; font-weight: 700; line-height: 1;
}
.prox b i { font-style: normal; font-size: .5rem; color: var(--ink-40); display: block; }

/* ---------- الواجهة الرئيسية: البطل ---------- */
.hero { position: relative; overflow: hidden; background: var(--sand); padding: 64px 0 72px; }
.hero::before, .hero::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(4px); opacity: .5;
}
.hero::before { width: 420px; height: 420px; background: radial-gradient(circle, var(--amber-l), transparent 70%); top: -140px; inset-inline-start: -120px; }
.hero::after  { width: 520px; height: 520px; background: radial-gradient(circle, #FFDCC4, transparent 70%); bottom: -220px; inset-inline-end: -140px; }
.hero .wrap { position: relative; display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: .8rem;
  color: var(--flame-d); background: #fff; padding: 6px 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line); margin-bottom: 18px;
}
.hero h1 span { color: var(--flame); }
.hero p.lead { font-size: 1.05rem; color: var(--ink-60); max-width: 46ch; margin: 16px 0 28px; }

/* الرادار — يترجم فكرة "الأقرب إليك" بصرياً */
.radar { position: relative; aspect-ratio: 1; max-width: 420px; margin-inline: auto; }
.radar-ring { position: absolute; inset: 0; border-radius: 50%; border: 1.5px dashed var(--line); }
.radar-ring:nth-child(2) { inset: 14%; }
.radar-ring:nth-child(3) { inset: 28%; border-style: solid; }
.radar-sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(237,106,44,.22), transparent 32%);
  animation: sweep 4.5s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.radar-me {
  position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; border-radius: 50%;
  background: #fff; border: 3px solid var(--flame); display: grid; place-items: center;
  font-size: 22px; box-shadow: var(--shadow-2); z-index: 2;
}
.radar-pin {
  position: absolute; width: 54px; height: 54px; border-radius: 16px; background: #fff;
  box-shadow: var(--shadow-2); display: grid; place-items: center; font-size: 22px;
  animation: pop .6s cubic-bezier(.22,1.4,.4,1) backwards;
}
.radar-pin em { position: absolute; bottom: -9px; font-style: normal; font-family: var(--display);
  font-size: .62rem; font-weight: 700; background: var(--ink); color: #fff; padding: 1px 7px; border-radius: var(--r-pill); }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }

/* ---------- شريط المطابخ ---------- */
.cuisine-rail { display: flex; gap: 14px; overflow-x: auto; padding: 8px 2px 20px; scroll-snap-type: x mandatory; }
.cuisine-rail::-webkit-scrollbar { height: 6px; }
.cuisine-rail::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
.cuisine {
  flex: none; width: 92px; text-align: center; cursor: pointer; scroll-snap-align: start;
  background: none; border: none; padding: 0;
}
.cuisine .disc {
  width: 72px; height: 72px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center;
  font-size: 30px; background: #fff; border: 2px solid var(--line); transition: all .2s;
}
.cuisine:hover .disc { transform: translateY(-4px); border-color: var(--amber); }
.cuisine.active .disc { border-color: var(--flame); background: var(--sand); box-shadow: var(--shadow-flame); }
.cuisine span { font-size: .82rem; font-weight: 600; }
.cuisine.active span { color: var(--flame); }

/* ---------- بطاقة المتجر ---------- */
.store {
  display: flex; flex-direction: column; cursor: pointer; transition: transform .2s, box-shadow .2s;
}
.store:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }
.store-top { position: relative; aspect-ratio: 16/10; background: var(--sand); display: grid; place-items: center; }
.store-top img { max-height: 72%; max-width: 76%; object-fit: contain; }
.store-top .flags { position: absolute; top: 10px; inset-inline-start: 10px; display: flex; gap: 6px; }
.store-body { padding: 14px 16px 16px; display: flex; gap: 12px; align-items: flex-start; }
.store-body h3 { font-size: 1rem; margin-bottom: 2px; }
.store-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--ink-60); margin-top: 8px; }
.store-meta b { font-family: var(--display); color: var(--ink); }
.store.closed { opacity: .62; }

/* ---------- بطاقة العرض/الوجبة ---------- */
.dish { display: flex; flex-direction: column; }
.dish-img { aspect-ratio: 4/3; background: var(--sand); position: relative; }
.dish-img img { width: 100%; height: 100%; object-fit: cover; }
.dish-img .off { position: absolute; top: 10px; inset-inline-end: 10px; }
.dish-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.dish-body p { margin: 0; font-size: .84rem; color: var(--ink-60); flex: 1; }
.price { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.price s { color: var(--ink-40); font-weight: 400; font-size: .85rem; margin-inline-start: 6px; }

/* ---------- الأقسام ---------- */
.section { padding: 56px 0; }
.section.tint { background: var(--sand); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.section-head .eyebrow {
  font-family: var(--display); font-size: .72rem; font-weight: 700; letter-spacing: .18em;
  color: var(--flame); text-transform: uppercase; display: block; margin-bottom: 6px;
}

/* ---------- السلة الجانبية ---------- */
.drawer {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: min(420px, 100%);
  background: var(--paper); z-index: 90; box-shadow: var(--shadow-2);
  transform: translateX(-100%); transition: transform .32s cubic-bezier(.22,1,.36,1);
  display: flex; flex-direction: column;
}
[dir=rtl] .drawer { transform: translateX(-100%); }
.drawer.open { transform: none; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-foot { padding: 18px 20px; border-top: 1px solid var(--line); background: #fff; }
.scrim { position: fixed; inset: 0; background: rgba(26,21,18,.45); z-index: 80; opacity: 0;
  pointer-events: none; transition: opacity .28s; }
.scrim.on { opacity: 1; pointer-events: auto; }

.cart-line { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.qty { display: inline-flex; align-items: center; gap: 4px; background: var(--sand); border-radius: var(--r-pill); padding: 3px; }
.qty button { width: 26px; height: 26px; border-radius: 50%; border: none; background: #fff; cursor: pointer;
  font-family: var(--display); font-weight: 700; box-shadow: var(--shadow-1); }
.totals { display: grid; gap: 6px; font-size: .9rem; margin-bottom: 14px; }
.totals .grand { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 4px; font-size: 1.1rem; font-weight: 700; }

/* ---------- نافذة منبثقة ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 20px; }
.modal.on { display: grid; }
.modal-card { background: var(--paper); border-radius: var(--r-lg); width: min(560px, 100%);
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow-2); position: relative; z-index: 2;
  animation: rise .3s cubic-bezier(.22,1,.36,1); }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
.modal-card.wide { width: min(880px, 100%); }

/* ---------- لوحات التحكم ---------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #fff; padding: 22px 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #fff; margin-bottom: 26px; }
.side nav { display: grid; gap: 4px; }
.side nav a {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: var(--r-sm);
  color: rgba(255,255,255,.72); font-weight: 600; font-size: .92rem; cursor: pointer; transition: .16s;
}
.side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side nav a.active { background: var(--flame); color: #fff; box-shadow: var(--shadow-flame); }
.side .sep { height: 1px; background: rgba(255,255,255,.12); margin: 16px 0; }
.main { padding: 28px 32px 60px; background: #FBF8F4; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; inset-block-start: 0; inset-inline-start: 0; width: 4px; height: 100%; background: var(--flame); }
.kpi.g::after { background: var(--basil); }
.kpi.a::after { background: var(--amber); }
.kpi .v { font-family: var(--display); font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.kpi .l { font-size: .82rem; color: var(--ink-60); }

table.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th, .tbl td { padding: 13px 14px; text-align: right; border-bottom: 1px solid var(--line); font-size: .88rem; }
.tbl th { background: var(--sand); font-family: var(--display); font-weight: 700; font-size: .8rem;
  color: var(--ink-60); position: sticky; top: 0; }
.tbl tbody tr:hover { background: #FFFCF7; }
.tbl td .row { gap: 8px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-md); overflow: auto; max-height: 70vh; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { padding: 8px 16px; border-radius: var(--r-pill); border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-weight: 600; font-size: .86rem; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* رسم بياني بسيط بالأعمدة */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--amber), var(--flame)); border-radius: 6px 6px 0 0;
  min-height: 4px; position: relative; transition: height .6s cubic-bezier(.22,1,.36,1); }
.bars .bar span { position: absolute; bottom: -22px; inset-inline: 0; text-align: center; font-size: .62rem; color: var(--ink-40); }

/* الخط الزمني للطلب */
.timeline { display: grid; gap: 0; }
.tl-step { display: grid; grid-template-columns: 28px 1fr; gap: 14px; padding-bottom: 20px; position: relative; }
.tl-step::before { content: ''; position: absolute; inset-inline-start: 13px; top: 26px; bottom: 0; width: 2px; background: var(--line); }
.tl-step:last-child::before { display: none; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px;
  background: var(--line); color: var(--ink-40); z-index: 1; }
.tl-step.done .tl-dot { background: var(--basil); color: #fff; }
.tl-step.now  .tl-dot { background: var(--flame); color: #fff; box-shadow: 0 0 0 5px rgba(237,106,44,.18); }

/* حالات فارغة */
.empty { text-align: center; padding: 56px 20px; color: var(--ink-60); }
.empty .ico { font-size: 44px; margin-bottom: 12px; opacity: .5; }
.empty h3 { margin-bottom: 6px; }

/* إشعارات مؤقتة */
#toasts { position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 200; display: grid; gap: 10px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-2); font-size: .9rem; animation: rise .28s; max-width: 340px; }
.toast.err { background: var(--danger); }
.toast.ok  { background: var(--basil); }

/* هيكل التحميل */
.skel { background: linear-gradient(90deg, var(--line) 25%, #F7F0E7 50%, var(--line) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* الخريطة */
.map-box { height: 320px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--sand); }

/* التذييل */
.foot { background: var(--ink); color: rgba(255,255,255,.72); padding: 48px 0 28px; margin-top: 40px; }
.foot h4 { color: #fff; font-size: .95rem; margin-bottom: 12px; }
.foot a:hover { color: var(--amber); }
.foot .cols { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.foot .bottom { border-top: 1px solid rgba(255,255,255,.12); margin-top: 32px; padding-top: 18px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .82rem; }

/* ---------- الاستجابة ---------- */
@media (max-width: 900px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .radar { max-width: 300px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { grid-auto-flow: column; overflow-x: auto; }
  .main { padding: 20px 16px 50px; }
  .foot .cols { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .wrap { width: calc(100% - 28px); }
  .topbar .wrap { gap: 10px; }
  .loc-pill { max-width: 150px; }
  .foot .cols { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
