/* ===================== نظام التصميم الموحّد =====================
   كل الصفحات بتستخدم نفس: أحجام الخطوط، ارتفاع الحقول والأزرار، الكروت، والمسافات.
   لو عايز تغيّر شكل عام، غيّر المتغيرات اللي تحت بس. */
:root {
  --primary: #2563EB;
  --primary-dark: #1E3A8A;
  --primary-light: #DBEAFE;
  --accent: #22D3EE;
  --danger: #d9423f;
  --warn-bg: #fff6e8;
  --warn-border: #ffdca8;
  --warn-text: #8a5a00;
  --text: #0F1B3D;
  --muted: #5B6B8C;
  --bg: #F5F8FF;
  --card: #ffffff;
  --border: #DCE6F8;

  --radius: 14px;
  --radius-sm: 12px;
  --shadow: 0 2px 12px rgba(30, 58, 138, 0.08);

  /* مقياس الخطوط */
  --fs-xs: 12px;   /* ملاحظات صغيرة، شارات */
  --fs-sm: 13px;   /* عناوين الحقول، نص ثانوي */
  --fs-md: 15px;   /* النص الأساسي، الحقول، الأزرار */
  --fs-lg: 17px;   /* عناوين الأقسام والكروت */
  --fs-xl: 21px;   /* اسم التطبيق */

  --field-h: 50px; /* ارتفاع كل الحقول والأزرار */
  --gap: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  direction: rtl;
  font-family: "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
body { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: var(--fs-md); cursor: pointer; border: none; }
input, textarea, select { font-family: inherit; font-size: var(--fs-md); }

/* ===== الهيدر ===== */
/* الهيدر: padding-top بيراعي المساحة الآمنة (ساعة وبطارية وشريط حالة الموبايل)
   لما التطبيق يتثبّت على الشاشة، فما يتداخلش مع بيانات التليفون */
.app-header {
  position: relative;
  text-align: center;
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 55%, #1D4ED8 100%);
  color: #fff;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 16px 22px;
  border-radius: 0 0 28px 28px;
  box-shadow: 0 6px 20px rgba(29, 78, 216, 0.25);
}
.brand { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 38px; font-weight: 800; line-height: 1.1; letter-spacing: 0; }
.brand .logo-emoji { font-size: 26px; }
.brand-logo { width: 54px; height: 54px; border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,.22); }
.tagline { font-size: 17px; font-weight: 700; margin-top: 10px; line-height: 1.5; }
.tagline-note { font-size: 10.5px; opacity: .7; margin-top: 2px; }

/* ===== الرسالة التسويقية (أول الصفحة) ===== */
.promo {
  display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 16px; margin-bottom: var(--gap); box-shadow: var(--shadow);
}
.promo-gift {
  width: 56px; height: 56px; border-radius: 18px; flex-shrink: 0; background: var(--accent);
  display: flex; align-items: center; justify-content: center; color: var(--primary-dark);
}
.promo-gift svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.promo-text { flex: 1; min-width: 0; }
.promo-title { font-size: var(--fs-lg); font-weight: 800; line-height: 1.6; }
.promo-title b { color: var(--primary); }
.promo-note { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.promo-cta { margin-top: 10px; background: var(--primary); color: #fff; font-weight: 800; font-size: var(--fs-sm); border-radius: 12px; padding: 10px 18px; }
.promo-cta:active { background: var(--primary-dark); }
.install-btn {
  display: none; position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 12px;
  background: rgba(255,255,255,.18); color: #fff;
  border: 1px solid rgba(255,255,255,.4); border-radius: 10px; padding: 5px 10px; font-size: var(--fs-xs);
}
.install-btn.show { display: inline-flex; align-items: center; gap: 6px; }

/* ===== الحاوية ===== */
.container { padding: var(--gap); max-width: 480px; margin: 0 auto; }


/* ===== العناوين ===== */
.section-title {
  font-size: var(--fs-lg); font-weight: 800; margin: 4px 0 var(--gap);
  display: flex; justify-content: space-between; align-items: center;
}
.section-title .count { font-size: var(--fs-sm); color: var(--muted); font-weight: 400; }

/* ===== الكروت (نفس الشكل في كل مكان) ===== */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: var(--gap);
}
.card-title { font-size: var(--fs-lg); font-weight: 800; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.card-title .count { margin-inline-start: auto; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.card-hint { font-size: var(--fs-sm); color: var(--muted); margin-bottom: 12px; line-height: 1.7; }
.step {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-light); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-sm); font-weight: 800;
}
.or-divider { display: flex; align-items: center; gap: 12px; margin: 0 0 var(--gap); color: var(--muted); font-size: var(--fs-sm); font-weight: 700; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ===== الحقول (ارتفاع وخط موحّد) ===== */
.field { margin-bottom: var(--gap); }
.field label { display: block; font-size: var(--fs-sm); font-weight: 700; margin-bottom: 6px; }
.field input, .field textarea, .field select,
.search-box, .manual-input {
  width: 100%; min-height: var(--field-h); padding: 12px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; color: var(--text); box-shadow: none;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field textarea:focus, .search-box:focus, .manual-input:focus {
  outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary);
}
.field-hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 5px; }
.form-error { color: var(--danger); font-size: var(--fs-sm); margin: 4px 0 10px; min-height: 18px; }

/* ===== الأزرار (ارتفاع موحّد) ===== */
.primary-btn, .secondary-btn {
  width: 100%; min-height: var(--field-h); border-radius: var(--radius-sm);
  font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px;
}
.primary-btn { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.3); }
.primary-btn:active { background: var(--primary-dark); }
.primary-btn:disabled { opacity: .5; }
.secondary-btn { background: var(--card); color: var(--primary-dark); border: 1.5px solid var(--primary); }
.link-btn { background: none; color: var(--primary-dark); font-weight: 700; font-size: var(--fs-sm); padding: 4px 0; text-decoration: underline; }
/* الزر الرئيسي يفضل ظاهر فوق شريط التنقل */
.sticky-cta { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 90; }

/* ===== البحث والاقتراحات ===== */
.search-wrap { position: relative; }
.suggestions {
  position: absolute; top: calc(100% + 6px); right: 0; left: 0; z-index: 60;
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0,0,0,.16); max-height: 340px; overflow-y: auto;
}
.sugg-item {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.sugg-item:last-child { border-bottom: none; }
.sugg-item:active { background: var(--primary-light); }
.sugg-name { font-weight: 700; font-size: var(--fs-md); line-height: 1.5; }
.sugg-sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.sugg-price { font-weight: 800; color: var(--primary-dark); font-size: var(--fs-sm); white-space: nowrap; }
.sugg-empty { padding: 14px; font-size: var(--fs-sm); color: var(--muted); text-align: center; }

/* ===== الإضافة المباشرة ===== */
.manual-row { display: flex; gap: 8px; align-items: stretch; }
.manual-row .manual-input { flex: 1; min-width: 0; }
.mini-add {
  min-height: var(--field-h); padding: 0 16px; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-weight: 800; white-space: nowrap;
}
.mini-add:active { background: var(--primary-dark); }
.manual-box { margin-top: 12px; }
.manual-box .box-title { font-size: var(--fs-sm); font-weight: 800; color: var(--primary-dark); margin-bottom: 8px; }
.pick-list { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.pick-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: #fff;
}
.pick-item:last-child { border-bottom: none; }
.pick-info { flex: 1; min-width: 0; }
.pick-name { font-weight: 700; font-size: var(--fs-md); line-height: 1.5; }
.pick-sub { font-size: var(--fs-xs); color: var(--muted); }
.pick-price { font-size: var(--fs-sm); font-weight: 800; color: var(--primary-dark); margin-top: 2px; }
.pick-btn {
  background: var(--primary-light); color: var(--primary-dark); font-weight: 800; font-size: var(--fs-sm);
  border-radius: 10px; padding: 9px 12px; white-space: nowrap;
}
.pick-btn.plain { background: #f0f3f2; color: var(--text); }
.pick-item.as-typed { background: #fafbfb; }

/* ===== الشارات ===== */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 700; display: inline-block; line-height: 1.6; }
.badge.local { background: #DBEAFE; color: var(--primary-dark); }
.badge.imported { background: #eef0ff; color: #3b4bd1; }
.badge.unknown { background: #fff0e0; color: #9a5200; }

/* ===== عناصر القوائم (السلة + قائمة الرئيسية) ===== */
.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.li-info { flex: 1; min-width: 0; }
.li-name { font-weight: 700; font-size: var(--fs-md); line-height: 1.5; }
.li-sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 1px; }
.li-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.li-price { font-weight: 800; color: var(--primary-dark); font-size: var(--fs-sm); }
.li-price.unknown { color: #9a5200; }
.li-side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.qty-ctrl { display: flex; align-items: center; gap: 8px; background: var(--primary-light); border-radius: 10px; padding: 4px 6px; }
.qty-ctrl button {
  background: var(--primary); color: #fff; width: 28px; height: 28px; border-radius: 8px;
  font-size: 17px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.qty-ctrl .qty-num { min-width: 22px; text-align: center; font-weight: 800; font-size: var(--fs-md); }
.remove-btn { background: none; color: var(--danger); font-size: var(--fs-xs); padding: 2px 4px; font-weight: 700; }

/* ===== السلة والملخص ===== */
.chronic-box {
  background: var(--primary-light); border: 1px dashed var(--primary); border-radius: var(--radius);
  padding: 14px; margin-bottom: var(--gap); font-size: var(--fs-sm); line-height: 1.8;
}
.chronic-box label { display: flex; align-items: flex-start; gap: 10px; font-weight: 700; cursor: pointer; }
.chronic-box input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; }
.note-box {
  background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text);
  border-radius: var(--radius); padding: 10px 14px; font-size: var(--fs-sm); line-height: 1.7; margin-bottom: var(--gap);
}
.summary-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: var(--fs-md); }
.summary-row.discount { color: #1a9b6c; font-weight: 800; }
.summary-row.total { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 12px; font-size: var(--fs-lg); font-weight: 800; }
.delivery-info {
  display: flex; align-items: center; gap: 10px; background: #EAF2FF; border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: var(--gap); font-size: var(--fs-sm); line-height: 1.7;
}
.delivery-info .ic { font-size: 22px; }
.guest-hint {
  background: var(--primary-light); border-radius: var(--radius); padding: 12px 14px; margin-bottom: var(--gap);
  font-size: var(--fs-sm); display: flex; justify-content: space-between; align-items: center; gap: 10px; line-height: 1.7;
}

/* ===== الموقع ===== */
.loc-box { background: #EFF5FF; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: var(--gap); }
.loc-btn {
  width: 100%; min-height: 46px; border-radius: 10px; background: #fff; color: var(--primary-dark);
  border: 1.5px solid var(--primary); font-weight: 800; font-size: var(--fs-sm); display: flex; align-items: center; justify-content: center; gap: 8px;
}
.loc-btn:disabled { opacity: .6; }
.loc-status { font-size: var(--fs-xs); color: var(--muted); margin-top: 8px; line-height: 1.7; }
.loc-status.ok { color: #167a46; font-weight: 700; }
.loc-status.err { color: var(--danger); }

/* ===== الحساب ===== */
.auth-tabs { display: flex; gap: 8px; margin-bottom: var(--gap); }
.auth-tabs button {
  flex: 1; min-height: 46px; border-radius: 10px; font-size: var(--fs-md); font-weight: 800;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
.auth-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.profile-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark);
  font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center;
}

/* ===== التأكيد والطلبات ===== */
.confirm-wrap { text-align: center; padding: 36px 16px; }
.confirm-icon { font-size: 60px; margin-bottom: 12px; }
.confirm-wrap h2 { margin: 0 0 8px; font-size: var(--fs-xl); }
.confirm-wrap p { color: var(--muted); font-size: var(--fs-md); line-height: 1.8; margin: 0 0 12px; }
.order-id-box { background: var(--primary-light); border-radius: 10px; padding: 10px 16px; margin: 6px 0 18px; font-weight: 800; color: var(--primary-dark); display: inline-block; }
.order-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: var(--gap); }
.order-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.order-top b { font-size: var(--fs-md); }
.order-meta { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 8px; }
.order-items { font-size: var(--fs-sm); line-height: 1.8; margin-bottom: 10px; }
.order-total { font-weight: 800; font-size: var(--fs-md); }
.bill-box {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #EFF5FF; border: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: var(--fs-sm);
}
.bill-box.paid { background: #eaf8f0; border-color: #bfe8d0; }
.bill-box b { font-size: var(--fs-md); }
.pay-pill { font-size: var(--fs-xs); padding: 4px 10px; border-radius: 20px; font-weight: 800; white-space: nowrap; }
.pay-pill.paid { background: #d9f5e4; color: #167a46; }
.pay-pill.due { background: #fff3cd; color: #8a6d00; }
.status-pill { font-size: var(--fs-xs); padding: 4px 10px; border-radius: 20px; font-weight: 800; white-space: nowrap; }
.status-pill.pending { background: #fff3cd; color: #8a6d00; }
.status-pill.preparing { background: #e3f0ff; color: #1557b0; }
.status-pill.on_the_way { background: #ffe8d6; color: #a04d00; }
.status-pill.delivered { background: #d9f5e4; color: #167a46; }
.status-pill.cancelled { background: #fde2e2; color: #a12c2c; }
.empty-state { text-align: center; color: var(--muted); padding: 36px 10px; font-size: var(--fs-md); line-height: 1.9; }
.cat-chip { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 8px 14px; font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.cat-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== شريط التنقل السفلي ===== */
.bottom-nav {
  position: fixed; bottom: 0; right: 0; left: 0; z-index: 100; display: flex; max-width: 480px; margin: 0 auto;
  background: var(--card); box-shadow: 0 -2px 14px rgba(0,0,0,.08);
  padding-bottom: env(safe-area-inset-bottom, 0px); /* مؤشر الرجوع في أسفل الموبايل */
}
.nav-item { flex: 1; text-align: center; padding: 8px 0 8px; font-size: var(--fs-xs); color: var(--muted); position: relative; }
.nav-item .nav-ic {
  display: flex; align-items: center; justify-content: center; width: 52px; height: 30px; margin: 0 auto 3px;
  border-radius: 15px; transition: background .2s, color .2s;
}
.nav-item .nav-ic svg {
  width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  transition: fill .2s, stroke-width .2s;
}
.nav-item.active { color: var(--primary-dark); font-weight: 800; }
.nav-item.active .nav-ic { background: var(--primary-light); color: var(--primary); }
.nav-item.active .nav-ic svg { fill: rgba(37,99,235,.16); stroke-width: 2.1; }
.nav-badge {
  position: absolute; top: 4px; left: calc(50% + 4px); box-shadow: 0 0 0 2px var(--card);
  background: var(--danger); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* ===== الصفحات ===== */
.view { display: none; }
.view.active { display: block; }

.toast {
  position: fixed; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); right: 50%; transform: translateX(50%); z-index: 200;
  background: var(--primary-dark); color: #fff; padding: 12px 20px; border-radius: 30px; font-size: var(--fs-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,.25); opacity: 0; transition: opacity .25s; max-width: 90%; text-align: center;
  pointer-events: none; /* الرسالة الشفافة ما تبلعش ضغطات الأزرار اللي تحتها */
}
.toast.show { opacity: 1; }

.notif-banner {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: var(--gap);
  display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: var(--fs-sm); box-shadow: var(--shadow);
}
.notif-banner button { background: var(--primary); color: #fff; border-radius: 8px; padding: 8px 14px; font-size: var(--fs-sm); font-weight: 800; white-space: nowrap; }
