/* ════════════════════════════════════════════════════════════════
   Goustenu · reseller — أنماط لوحة الوكيل البائع
   ================================================================
   أخضر زيتونيّ لا بنفسجيّ ولا أحمر: ثلاث لوحات في المنصّة، ولكنةٌ لكلٍّ
   منها. والتمييز البصريّ الفوريّ حاجزٌ أوّل ضدّ «تصرّفتُ في اللوحة الخطأ»
   — وهذه اللوحة **ليست لي**: يفتحها بائعٌ يملك ثلاثة مواقع لا أكثر.

   البنية: شريط جانبيّ ثابت (يتحوّل درجاً منزلقاً على الهاتف) + شريط علويّ
   بعنوان يتغيّر + عروض يظهر منها واحد. الأصناف التي تحتاجها العدّة
   المشتركة (`shared/ui-kit.mjs`): `.toast` · `.modal-*` · `.btn` ·
   `.field` · `.lbl` · `.hint` · `.field-row` · `.icon-btn`.
   ════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  --accent: #3F6B4A; --accent-d: #2F5238; --accent-soft: #e6efe8;
  --bg: #f7f5f1; --card: #fff; --ink: #2a2320; --muted: #837a72; --faint: #a79e95;
  --line: #e8e1db;
  --ok: #2E6B41; --ok-soft: #e8f3ec;
  --warn: #8A5A12; --warn-soft: #fdf1dd;
  --err: #A63D2F; --err-soft: #fbeae7;
  --r: 14px; --shadow: 0 4px 18px rgba(40, 32, 20, .06);
  --side-w: 15rem;
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font);
  font-size: 16px; line-height: 1.55; font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { display: block; font-size: .78rem; color: var(--muted); margin-top: var(--s2); }
.ic { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ─── أزرار وحقول ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 42px; padding: 0 var(--s4);
  border: 1px solid transparent; border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: var(--err); color: #fff; }
.btn.sm { min-height: 34px; padding: 0 var(--s3); font-size: .84rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; flex: none;
  border: 1px solid transparent; border-radius: 9px; background: transparent;
  color: var(--muted); font: inherit; cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.field {
  width: 100%; min-height: 42px; padding: var(--s2) var(--s3);
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--ink); font: inherit;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.lbl { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin: var(--s3) 0 var(--s1); }
.field-row { margin-bottom: var(--s3); }
.i18n-grid > * { margin-bottom: var(--s2); }
.i18n-more summary { cursor: pointer; color: var(--muted); font-size: .84rem; }

/* ─── الدخول ─── */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.login-card {
  width: min(23rem, 100%); padding: var(--s5);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.login-brand { color: var(--accent); font-weight: 800; }
.login-title { font-size: 1.3rem; margin-top: var(--s1); }
.login-sub { color: var(--muted); font-size: .86rem; margin: var(--s1) 0 var(--s2); }
.login-error { min-height: 1.2rem; margin: var(--s2) 0 0; color: var(--err); font-size: .84rem; }

/* ─── القشرة ─── */
.shell { display: flex; min-height: 100vh; }
.scrim {
  position: fixed; inset: 0; z-index: 30; background: rgba(24, 17, 12, .45);
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.shell.side-open .scrim { opacity: 1; visibility: visible; }

.side {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40;
  width: var(--side-w); display: flex; flex-direction: column;
  background: var(--accent); color: #fff; padding: var(--s4) var(--s3);
  transform: translateX(100%);                 /* RTL: الدرج يخرج نحو البداية */
  transition: transform .24s cubic-bezier(.2, .8, .25, 1);
}
.shell.side-open .side { transform: none; }
.side-brand { display: flex; align-items: center; gap: var(--s2); padding-inline-start: var(--s2); }
.side-logo { width: 34px; height: 34px; border-radius: 9px; }
.side-name { font-weight: 800; line-height: 1.2; }
.side-sub { font-size: .76rem; opacity: .8; }

.side-nav { display: flex; flex-direction: column; gap: var(--s1); margin-top: var(--s5); }
.nav-btn {
  display: flex; align-items: center; gap: var(--s2);
  min-height: 42px; padding: 0 var(--s3);
  border: 0; border-radius: 10px; background: transparent;
  color: rgba(255, 255, 255, .82); font: inherit; font-weight: 600; text-align: start; cursor: pointer;
}
.nav-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-btn.on { background: #fff; color: var(--accent); }
.nav-btn .label { flex: 1; }
.nav-count {
  min-width: 1.5rem; padding: 0 .35rem; border-radius: 999px;
  background: rgba(255, 255, 255, .2); font-size: .75rem; text-align: center;
}
.nav-btn.on .nav-count { background: var(--accent-soft); color: var(--accent-d); }

.side-cta { margin-top: var(--s4); }
.side-cta .btn.primary { background: #fff; color: var(--accent); border-color: #fff; }
.side-cta .btn.primary:hover { background: var(--accent-soft); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s2); font-size: .82rem; }
.install-chip, .side-logout {
  display: flex; align-items: center; gap: var(--s2);
  min-height: 38px; padding: 0 var(--s3);
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 9px;
  background: transparent; color: #fff; font: inherit; cursor: pointer;
}
.install-chip:hover, .side-logout:hover { background: rgba(255, 255, 255, .14); }
.side-user {
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3); opacity: .85; word-break: break-all;
}

/* ─── المحتوى ─── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s4);
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.page-title { font-size: 1.05rem; font-weight: 800; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: var(--s2); }
.search {
  display: none; align-items: center; gap: var(--s2);
  padding: 0 var(--s3); min-height: 38px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted);
}
.search input { border: 0; outline: none; font: inherit; width: 11rem; background: transparent; color: var(--ink); }
.search.on { display: flex; }

.view { display: none; padding: var(--s4); }
.view.active { display: block; }

/* ─── بطاقات وأرقام ─── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: var(--s4); margin-bottom: var(--s4);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.card-title { font-size: 1rem; font-weight: 800; }
.card-sub { font-size: .78rem; color: var(--faint); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--s3); text-align: center; cursor: pointer;
}
.stat:hover { border-color: var(--accent); }
.stat-val { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-lbl { font-size: .76rem; color: var(--muted); }
.stat.tone-ok .stat-val { color: var(--ok); }
.stat.tone-warn .stat-val { color: var(--warn); }
.stat.tone-err .stat-val { color: var(--err); }
.stat.tone-accent .stat-val { color: var(--accent); }

.two-col { display: grid; grid-template-columns: 1fr; gap: var(--s4); }

/* ─── قوائم ─── */
.line {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) 0; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.line:first-child { border-top: none; }
.line-main { display: flex; flex-direction: column; min-width: 0; }
.line-name { font-weight: 700; }
.line-sub { font-size: .78rem; color: var(--muted); }
.line-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .73rem; font-weight: 700; }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.grace { background: var(--warn-soft); color: var(--warn); }
.badge.expired { background: var(--err-soft); color: var(--err); }
.badge.suspended { background: var(--accent-soft); color: var(--accent-d); }
.badge.trashed { background: #f1eae7; color: var(--muted); }

.chips { display: flex; gap: var(--s1); flex-wrap: wrap; margin-bottom: var(--s3); }
.chip {
  min-height: 34px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  color: var(--muted); font: inherit; font-size: .84rem; cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* بطاقة مطعم */
.rest {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--s3) var(--s4); margin-bottom: var(--s3);
}
.rest.is-suspended { border-inline-start: 4px solid var(--warn); background: #fbf7ef; }
.rest.is-trashed { border-inline-start: 4px solid var(--err); background: #fbf2f0; }
.rest-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.rest-logo {
  width: 40px; height: 40px; border-radius: 10px; flex: none; overflow: hidden;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
  font-weight: 800;
}
.rest-logo img { width: 100%; height: 100%; object-fit: cover; }
.rest-name { font-weight: 700; }
.rest-id { font-size: .74rem; color: var(--faint); direction: ltr; }
.rest-meta { display: flex; gap: var(--s3); flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: var(--s1); }
.rest-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

.cmd {
  display: block; margin-top: var(--s2); padding: var(--s2) var(--s3);
  background: #f4f1ee; border: 1px dashed var(--line); border-radius: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem;
  overflow-x: auto; white-space: pre; direction: ltr; text-align: left;
}
.chart-wrap { display: grid; place-items: center; }
.donut-lbl { fill: var(--muted); font-size: 6px; }

/* ─── شاشة تفصيل مطعم (drill-down) ─── */
.detail-head {
  display: grid; gap: var(--s3); margin-bottom: var(--s4);
}
.back-btn { align-self: start; } /* زرّ .btn.ghost.sm موجود — لا لون ولا حجم هنا */

.detail-id {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--s3) var(--s4);
}
.detail-id .line-main { flex: 1; }

.detail-name {
  display: inline-flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  font-weight: 700; font-size: 1.05rem;
}

.switch {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: var(--s1) var(--s3);
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  cursor: pointer; font-size: .84rem; font-weight: 700; color: var(--muted);
}
.switch input {
  width: 20px; height: 20px; margin: 0;
  accent-color: var(--accent); cursor: pointer;
}
/* :has() زينة لا شرط — متصفّحٌ لا يفهمها يُبقي المفتاح مقروءاً بحدّه ونصّه */
.switch:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-d);
}
.switch:has(input:disabled) { opacity: .6; }

/* ─── toast + modal (تستعملهما العدّة المشتركة) ─── */
.toast {
  position: fixed; inset-inline: 0; bottom: var(--s4); margin-inline: auto;
  width: fit-content; max-width: 90%; padding: var(--s2) var(--s4);
  border-radius: 999px; background: #2a2320; color: #fff; font-size: .88rem;
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; z-index: 60;
}
.toast.show { opacity: 1; visibility: visible; }
.toast-err { background: var(--err); }

.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: var(--s4); background: rgba(24, 17, 12, .5);
}
.modal-card { width: min(31rem, 100%); max-height: 88vh; overflow-y: auto; background: var(--card); border-radius: var(--r); }
.modal-card.wide { width: min(46rem, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 1rem; }
.modal-body { padding: var(--s4); }
.modal-actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s4); flex-wrap: wrap; }
.confirm-msg { margin: 0; line-height: 1.6; }
body.modal-open { overflow: hidden; }

/* ─── سطح المكتب: الشريط ثابت ظاهر دائماً ─── */
@media (min-width: 60rem) {
  .side { transform: none; }
  .shell { padding-inline-start: var(--side-w); }
  .menu-btn { display: none; }
  .scrim { display: none; }
  .search { display: flex; }
  .two-col { grid-template-columns: 1.4fr 1fr; }
  .view { padding: var(--s5); }
}

@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; } }
