/* ============================================================
   جرسي: نظام التصميم
   مبني على المواصفة المعتمدة: خلفية بيضاء، خط Noto Sans Arabic،
   لون رئيسي واحد (#6b4aff)، زوايا مستديرة، وحدة مسافة 16px،
   وظلال ملوّنة. بدون عناصر زخرفية.
   ============================================================ */

:root {
  /* الألوان */
  --color-primary: #6b4aff;
  --color-primary-hover: #5a3be6;
  --color-primary-tint: rgba(107, 74, 255, 0.08);
  --color-primary-ring: rgba(107, 74, 255, 0.28);
  --color-bg: #ffffff;
  --color-surface-2: #f3f3f3;
  --color-text: #000000;
  --color-text-body: #111113;
  --color-text-secondary: #697586;   /* رمادي المواصفة الأغمق، لتباين مقروء */
  --color-placeholder: #879aa2;
  --color-border: #e5e7eb;
  --color-navy: #15295a;
  --color-danger: #b42318;

  /* الخطوط */
  --font: "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;

  /* المسافات: مضاعفات 16px */
  --u: 16px;
  --max: 1120px;

  /* الزوايا */
  --r-btn: 12px;
  --r-card: 32px;
  --r-card-sm: 24px;
  --r-pill: 9999px;

  /* الظلال الملوّنة */
  --shadow-deep: rgba(17, 17, 19, 0.22) 0 26px 70px -48px;
  --shadow-mid: rgba(107, 74, 255, 0.18) 0 12px 32px -16px;
  --shadow-low: rgba(17, 17, 19, 0.06) 0 1px 2px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  color: var(--color-text-body);
  background: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font);
  font-weight: 500;
  color: var(--color-text);
  margin: 0 0 var(--u);
}
h1 { font-size: 48px; line-height: 64px; }
h2 { font-size: 32px; line-height: 44px; }
h3 { font-size: 20px; line-height: 32px; font-weight: 600; }

p { margin: 0 0 var(--u); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: 24px;
}

.note {
  font-size: 14px;
  line-height: 24px;
  color: var(--color-text-secondary);
}

/* ---------- الشريط العلوي ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--u);
  padding-block: 24px;
}

.brand {
  font-weight: 700;
  font-size: 24px;
  line-height: 32px;
  color: var(--color-primary);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand .note {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-inline-start: 8px;
}

/* ---------- الأزرار ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  border-radius: var(--r-btn);
  padding: 12px 24px;
  min-height: 48px;
  text-decoration: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 3px solid var(--color-primary-ring); outline-offset: 2px; }
.btn svg { flex: none; }

/* زر رئيسي: لون واحد، زوايا 32 */
.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-radius: 32px;
  padding: 14px 32px;
  box-shadow: var(--shadow-mid);
}
.btn-primary:hover { background: var(--color-primary-hover); }

/* زر ثانوي: ممتلئ بخفة */
.btn-dark {
  background: var(--color-primary-tint);
  color: var(--color-primary);
  border-radius: 32px;
}
.btn-dark:hover { background: rgba(107, 74, 255, 0.14); }

.btn-ghost {
  background: #ffffff;
  color: var(--color-text-body);
  border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-2); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-block { width: 100%; }

/* ---------- البطاقات ---------- */

.card {
  background: #ffffff;
  border-radius: var(--r-card);
  padding: 32px;
  border: 1px solid #eef0f3;
  box-shadow: var(--shadow-deep);
}
.card > :last-child { margin-bottom: 0; }

.card-deep { box-shadow: var(--shadow-deep); }

.card-title {
  font-size: 20px;
  line-height: 32px;
  font-weight: 600;
  margin-bottom: 24px;
}

/* ---------- النماذج ---------- */

.field { margin-bottom: 24px; }

.field label {
  display: block;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text-body);
}

.input {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  color: var(--color-text-body);
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--r-btn);
  padding: 12px 16px;
  min-height: 48px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-ring);
}
.input::placeholder { color: var(--color-placeholder); }

/* ---------- شارات الحالة ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-pill);
  padding: 4px 16px;
  font-size: 14px;
  line-height: 24px;
  font-weight: 700;
  white-space: nowrap;
}
.pill-preparing {
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
}
.pill-ready {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

/* ---------- صفحة الكاشير ---------- */

.cashier-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: start;
  padding-bottom: 64px;
}
@media (min-width: 1024px) {
  .cashier-grid { grid-template-columns: 5fr 7fr; }
}
.stack { display: flex; flex-direction: column; gap: 32px; }

.login-wrap {
  max-width: 480px;
  margin: 48px auto 96px;
}
.login-wrap h2 { margin-bottom: 8px; }
.login-wrap .note { margin-bottom: 32px; }

.new-order-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.new-order-row .field { margin-bottom: 0; }

.order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}
.order-item:first-child { padding-top: 0; }
.order-item:last-child { border-bottom: none; padding-bottom: 0; }

.order-main { min-width: 0; }
.order-num {
  font-weight: 700;
  font-size: 24px;
  line-height: 32px;
  color: var(--color-text);
}
.order-meta {
  font-size: 14px;
  line-height: 20px;
  color: var(--color-text-secondary);
}
.order-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.order-actions .btn { min-height: 40px; padding: 8px 16px; font-size: 14px; }

.empty {
  text-align: center;
  padding: 32px 0 16px;
  color: var(--color-text-secondary);
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 24px;
  background: var(--color-surface-2);
  border-radius: var(--r-card-sm);
  text-align: center;
}
.qr-box img, .qr-box canvas {
  width: 224px;
  height: 224px;
  border-radius: 16px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow-low);
}
.qr-link {
  direction: ltr;
  word-break: break-all;
  font-size: 12px;
  line-height: 20px;
  color: var(--color-text-secondary);
  max-width: 100%;
}

.banner {
  border-radius: var(--r-card-sm);
  background: var(--color-primary-tint);
  color: var(--color-navy);
  padding: 16px 24px;
  font-size: 14px;
  line-height: 24px;
  margin-bottom: 32px;
}

/* ---------- صفحة العميل ---------- */

.live-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 24px;
  text-align: center;
}
.live-head { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.live-card {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 32px;
  text-align: center;
  transition: background 0.3s ease, color 0.3s ease;
}
.live-card.is-ready {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: rgba(107, 74, 255, 0.45) 0 26px 60px -32px;
  color: #ffffff;
}
.live-card.is-ready .note,
.live-card.is-ready .order-big { color: #ffffff; }
.live-card.is-ready .pill-ready { background: rgba(255, 255, 255, 0.18); color: #ffffff; }

.order-big {
  font-weight: 700;
  font-size: 96px;
  line-height: 104px;
  color: var(--color-text);
}

.status-ring {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-tint);
  color: var(--color-primary);
}
.status-ring.ready {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.live-actions { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 12px; }
.live-card.is-ready ~ .live-actions .btn-dark { background: var(--color-text-body); color: #fff; }

.hint {
  max-width: 440px;
  font-size: 14px;
  line-height: 24px;
  color: var(--color-text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--color-primary-tint);
  border-top-color: var(--color-primary);
  animation: spin 0.9s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* وميض ملء الشاشة لحظة الجاهزية */
.flash {
  position: fixed;
  inset: 0;
  background: var(--color-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 50;
}
.flash.on { opacity: 0.3; }

/* ---------- الصفحة التعريفية ---------- */

.hero {
  padding-block: 96px 64px;
  text-align: center;
}
.hero h1 { max-width: 760px; margin-inline: auto; margin-bottom: 24px; }
.hero .lead {
  font-size: 20px;
  line-height: 32px;
  color: var(--color-text-secondary);
  max-width: 640px;
  margin: 0 auto 32px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-block: 32px;
}
.steps h3 { margin-bottom: 8px; }
.steps .note { margin: 0; }

.step-num {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 16px;
}

.section { margin-block: 96px 0; }
.section-title { text-align: center; margin-bottom: 48px; }

.features {
  background: var(--color-surface-2);
  border-radius: var(--r-card);
  padding: 64px 48px;
}
.features .steps { margin-block: 0; text-align: right; }

.footer {
  margin-top: 96px;
  padding-block: 48px;
  background: var(--color-surface-2);
  text-align: center;
}

/* ---------- تنبيهات داخل الصفحة ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  inset-inline: 24px;
  max-width: 480px;
  margin-inline: auto;
  background: var(--color-text-body);
  color: #ffffff;
  border-radius: 16px;
  padding: 16px 24px;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  box-shadow: rgba(17, 17, 19, 0.3) 0 16px 40px -16px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: translateY(0); }
.toast.bad { background: var(--color-danger); }

/* ---------- تجاوب ---------- */

@media (max-width: 1023px) {
  .features { padding: 48px 32px; }
}

@media (max-width: 639px) {
  h1 { font-size: 36px; line-height: 48px; }
  h2 { font-size: 28px; line-height: 40px; }
  .container { padding-inline: 16px; }
  .topbar { padding-block: 16px; }
  .hero { padding-block: 48px 32px; }
  .hero .lead { font-size: 18px; line-height: 28px; }
  .steps { grid-template-columns: 1fr; gap: 24px; }
  .section { margin-top: 64px; }
  .features { padding: 32px 24px; border-radius: var(--r-card-sm); }
  .card { padding: 24px; border-radius: var(--r-card-sm); }
  .live-card { padding: 40px 24px; }
  .order-big { font-size: 72px; line-height: 80px; }
  .brand .note { display: none; }
  .order-item { flex-direction: column; align-items: stretch; gap: 12px; }
  .order-actions { justify-content: space-between; }
  .order-actions .btn { flex: 1; }
  .login-wrap { margin-top: 16px; }
}

/* ---------- تنظيم لوحة الكاشير ---------- */
.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.group-head .card-title { margin: 0; }
.count-badge { min-width: 32px; height: 32px; padding: 0 10px; border-radius: 9999px; background: var(--color-primary); color: #fff; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.count-badge.soft { background: var(--color-primary-tint); color: var(--color-primary); }
.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stats-strip b { display: block; font-size: 28px; line-height: 36px; font-weight: 800; color: var(--color-primary); }
.stats-strip small { display: block; font-size: 12px; line-height: 16px; color: var(--color-text-secondary); }
.order-item.is-done .order-num { color: var(--color-text-secondary); font-size: 20px; }
@media (min-width: 1024px) {
  #orders-list, #ready-list { max-height: 520px; overflow-y: auto; }
}

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- شعار جرسي ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { width: 44px; height: 44px; margin-block: -6px; flex: none; display: block; }
.ph-brand { display: flex; align-items: center; justify-content: center; gap: 6px; }
.ph-brand .brand-mark { width: 28px; height: 28px; }
