/* ════════════════════════════════════════════════════════════════
   Goustenu · admin — لوحة المطعم. RTL · موبايل أوّلاً · أرقام لاتينية.
   لوحة ألوان دافئة متّسقة مع تطبيق المنيو (--primary #B23A2E).
   ════════════════════════════════════════════════════════════════ */

:root {
  --primary: #B23A2E;
  --primary-d: #8f2c22;
  --primary-soft: #f6e7e4;
  --bg: #f4f1ec;
  --card: #ffffff;
  --ink: #2a2320;
  --muted: #8a807a;
  --line: #e7e1da;
  --field: #fbf9f6;
  --ok: #1f9d55;
  --danger: #c0392b;
  --danger-soft: #fbecea;
  --open: #1f9d55;
  --closed: #c0392b;
  --vacation: #6b4fbb;
  --grace: #c8881a;
  --expired: #c0392b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 2px 10px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.20);
  --font: "Segoe UI", system-ui, -apple-system, "Noto Naskh Arabic", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
body.modal-open { overflow: hidden; }
.hidden { display: none !important; }

/* ─── حقول عامّة ─── */
.field {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.field { resize: vertical; min-height: 44px; }
select.field { appearance: none; background-image: none; }
.field.time { width: auto; min-width: 120px; }
.lbl { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin: 2px 0 4px; }
.hint { display: block; font-size: .74rem; color: var(--muted); margin-top: 4px; }

/* ─── أزرار ─── */
.btn {
  font: inherit; font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--field); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: .84rem; }
.btn.block { width: 100%; display: block; margin-top: 6px; }
.btn:disabled { opacity: .55; cursor: default; filter: none; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  width: 34px; height: 34px;
  font-size: .95rem; line-height: 1;
  cursor: pointer; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--field); }
.icon-btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.icon-btn.danger:hover { background: var(--danger-soft); }

/* ─── شاشة الدخول ─── */
.login-screen {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.login-brand { color: var(--primary); font-weight: 800; letter-spacing: .5px; }
.login-title { margin: 4px 0 20px; font-size: 1.3rem; }
.login-card .lbl { margin-top: 14px; }
.login-error {
  min-height: 1.2em; margin: 12px 0 0;
  color: var(--danger); font-size: .84rem;
  opacity: 0; transition: opacity .15s;
}
.login-error.show { opacity: 1; }

/* ─── التطبيق: الشريط العلوي ─── */
.app-screen { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}
.topbar-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-id strong { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-status {
  font-size: .74rem; font-weight: 700; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px;
  background: var(--field); color: var(--muted);
}
.top-status.status-open { background: #e6f6ec; color: var(--open); }
.top-status.status-closed { background: var(--danger-soft); color: var(--closed); }
.top-status.status-vacation { background: #efeaf9; color: var(--vacation); }

/* ─── شريط تنبيه الاشتراك ─── */
.sub-banner { display: none; }
.sub-banner.show {
  display: block; padding: 10px 16px;
  font-size: .86rem; font-weight: 600; text-align: center;
}
.sub-banner.grace { background: #fdf3e2; color: var(--grace); border-bottom: 1px solid #f0dcb4; }
.sub-banner.expired { background: var(--danger-soft); color: var(--expired); border-bottom: 1px solid #f2cfca; }

/* ─── التبويبات ─── */
.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 8px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 auto;
  font: inherit; font-weight: 600;
  background: transparent; border: none;
  color: var(--muted);
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── بطاقات ─── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card.warn { background: #fdf7ee; border-color: #f0dcb4; }
.card-title { margin: 0 0 12px; font-size: 1.15rem; }
.sub-h { margin: 0 0 10px; font-size: .95rem; color: var(--muted); }
.muted { color: var(--muted); }
.muted.sm, .sm { font-size: .82rem; }

/* ─── رأس القسم مع زرّ ─── */
.an-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.an-head .card-title { margin: 0; }

/* ─── حقل موسوم ─── */
.field-row { margin-bottom: 14px; }
.form-actions, .modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 8px; }
.modal-actions { justify-content: flex-end; }

/* ─── ثلاثيّة i18n ─── */
.i18n-grid > .field-row { margin-bottom: 8px; }
.i18n-more { margin-top: 4px; }
.i18n-more > summary {
  cursor: pointer; font-size: .8rem; color: var(--primary);
  list-style: none; padding: 4px 0;
}
.i18n-more > summary::-webkit-details-marker { display: none; }
.i18n-more[open] > summary { margin-bottom: 6px; }

/* ─── مفتاح تبديل / راديو ─── */
.switch, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input, .radio input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.radio-row { display: flex; flex-wrap: wrap; gap: 16px; }
.mode-box {
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 14px; background: var(--field);
}

/* ─── الحالة: أيّام + جلسات ─── */
.day-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.day-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; font-size: .85rem; background: var(--card);
}
.day-chip input { accent-color: var(--primary); }
.sess-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.sess-row { display: flex; align-items: center; gap: 8px; }
.sess-sep { color: var(--muted); }

/* ─── المنيو: فئات وأطباق ─── */
.cat-card { padding: 14px 16px; }
.cat-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cat-card-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-card-title strong { font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.chip { font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--field); color: var(--muted); }
.chip.off { background: var(--danger-soft); color: var(--danger); }

.dish-rows { display: flex; flex-direction: column; gap: 6px; }
.dish-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--field);
}
/* .dish-row-main يأخذ الفراغ (flex:1) فتبقى المصغّرة أوّلاً والأزرار آخراً */
.dish-row-main { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.dish-row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish-row-name.muted { text-decoration: line-through; }
.dish-row-price { color: var(--primary); font-weight: 700; white-space: nowrap; font-size: .9rem; }
.dish-row-thumb {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--card); border: 1px solid var(--line);
}
/* الفراغ محفوظ حتى بلا صورة — فلا تتراقص الأسماء بين صفٍّ وآخر */
.dish-row-thumb.empty { display: block; border-style: dashed; }

/* ─── حقل صورة (image-field.mjs) ─── */
.imgf { position: relative; display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.imgf-box {
  position: relative; width: 160px; max-width: 100%;
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  background: var(--field); overflow: hidden; flex: 0 0 auto;
}
.imgf-preview { display: block; width: 100%; height: 100%; object-fit: cover; }
/* الشعار شفّاف ⇒ contain على خلفية بيضاء (cover يقصّ شعاراً غير مربّع) */
.imgf-logo .imgf-preview { object-fit: contain; background: var(--card); }
.imgf-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted);
}
.imgf-empty-mark { font-size: 1.5rem; line-height: 1; font-weight: 300; }
.imgf-empty-text { font-size: .72rem; }
/* حقل الملفّ آليّة لا عنصر تحكّم (الزرّ هو التحكّم) — يبقى قابلاً للنقر برمجيّاً.
   لا display:none: بعض المتصفّحات لا تفتح منتقياً لعنصر مُزال من التخطيط. */
.imgf-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.imgf-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 2px; }
.imgf-status { font-size: .74rem; color: var(--muted); }
.danger-text { color: var(--danger); }

/* ─── الاشتراك ─── */
.sub-state { display: inline-flex; align-items: center; gap: 8px; font-size: 1.05rem; margin-bottom: 12px; }
.sub-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); }
.sub-active .sub-dot { background: var(--open); }
.sub-grace .sub-dot { background: var(--grace); }
.sub-expired .sub-dot { background: var(--expired); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .86rem; }
.kv dd { margin: 0; font-weight: 600; }

/* ─── التحليلات ─── */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card { background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.stat-val { font-size: 1.35rem; font-weight: 800; color: var(--primary); }
.stat-lbl { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.top-list { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; }
.top-list li { display: flex; justify-content: space-between; gap: 10px; }
.hours { display: flex; flex-direction: column; gap: 6px; }
.hour-row { display: flex; align-items: center; gap: 8px; }
.hour-lbl { font-size: .78rem; color: var(--muted); width: 48px; flex: 0 0 auto; }
.bar-track { flex: 1; height: 10px; background: var(--field); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; background: var(--primary); border-radius: 999px; }
.hour-n { font-size: .78rem; width: 28px; text-align: left; flex: 0 0 auto; }

/* ─── modal ─── */
#modal-root:empty { display: none; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,15,12,.5);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-card {
  width: 100%; max-width: 520px;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 92dvh; overflow-y: auto;
  animation: sheet-up .22s ease-out;
}
.modal-card.wide { max-width: 640px; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-head {
  position: sticky; top: 0; background: var(--card);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 16px; }
.confirm-msg { margin: 0 0 4px; font-size: .98rem; }

@media (min-width: 560px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal-card { border-radius: var(--radius); animation: pop .18s ease-out; }
  @keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}

/* ─── toast ─── */
.toast {
  position: fixed; z-index: 200;
  left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  max-width: 90vw;
  background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-err { background: var(--danger); }
.toast.toast-ok { background: #262b26; }
