@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #dcfce7;
  --accent: #f59e0b;
  --danger: #ef4444;
  --blue: #3b82f6;
  --bg: #f1f5f0;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { direction: rtl; }

body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 15px; }
a { text-decoration: none; color: inherit; }

.hidden { display: none !important; }

/* ===== شاشة الزبون ===== */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 90px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, #16a34a, #15803d 55%, #0f6b33);
  color: #fff;
  padding: 14px 16px 12px;
  box-shadow: 0 3px 14px rgba(22, 163, 74, 0.35);
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.logo-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 26px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.logo-icon.lg { width: 60px; height: 60px; font-size: 34px; border-radius: 18px; }

.logo-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 12px;
  opacity: 0.85;
}

.search-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 9px 12px;
  gap: 8px;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 15px;
}

.search-box input::placeholder { color: rgba(255, 255, 255, 0.75); }

/* ===== أقسام ===== */
.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px 4px;
  scrollbar-width: none;
}
.categories::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

/* ===== المنتجات ===== */
.section-title {
  padding: 14px 16px 6px;
  font-size: 17px;
  font-weight: 800;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 8px 16px 16px;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s;
}

.product-card:active { transform: scale(0.97); }

.dropzone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  color: #6b7280;
  cursor: pointer;
  background: #fafbfa;
  transition: border-color .2s, background .2s, color .2s;
}
.dropzone:hover, .dropzone.dragging {
  border-color: #16a34a;
  background: #f0fdf4;
  color: #16a34a;
}

.product-img {
  height: 90px;
  display: grid;
  place-items: center;
  font-size: 52px;
  background: #fff;
  padding: 6px;
}

.product-img img {
  max-width: 100%;
  max-height: 62px;
  object-fit: contain;
}

.product-info { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }

.product-name { font-size: 14px; font-weight: 700; line-height: 1.4; }
.product-unit { font-size: 12px; color: var(--muted); }

.product-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; }

.price { font-size: 15px; font-weight: 800; color: var(--primary-dark); }
.price small { font-size: 11px; font-weight: 500; color: var(--muted); }

.add-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 8px rgba(22, 163, 74, 0.35);
}

.add-btn:hover { background: var(--primary-dark); }

.qty-box {
  display: flex;
  align-items: center;
  gap: 2px;
}

.qty-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 16px;
}

.qty-num { min-width: 26px; text-align: center; font-weight: 700; font-size: 15px; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state .big-emoji { font-size: 56px; display: block; margin-bottom: 10px; }

/* ===== السلة ===== */
.page-title {
  padding: 16px;
  font-size: 20px;
  font-weight: 800;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  margin: 0 16px 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.cart-item .mini-img {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #f0fdf4;
  display: grid;
  place-items: center;
  font-size: 26px;
  overflow: hidden;
  flex-shrink: 0;
}

.cart-item .mini-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item .mid { flex: 1; min-width: 0; }
.cart-item .mid .nm { font-weight: 700; font-size: 14px; }
.cart-item .mid .pr { font-size: 13px; color: var(--primary-dark); font-weight: 700; }

.cart-total {
  margin: 14px 16px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 16px;
}

.cart-total .val { color: var(--primary-dark); font-size: 20px; }

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: var(--card); border: 1.5px solid var(--border); color: var(--text); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-sm { width: auto; padding: 8px 16px; font-size: 14px; }

.btn-row { display: flex; gap: 10px; padding: 0 16px; }
.btn-row .btn { flex: 1; }

/* ===== نموذج الزبون ===== */
.customer-form { padding: 0 16px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.field input, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  outline: none;
  transition: border 0.15s;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }

/* ===== الطلبات ===== */
.order-card {
  background: var(--card);
  margin: 0 16px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-top: 4px solid var(--accent);
}

.order-card .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px 8px;
}

.order-card .num { font-weight: 800; font-size: 15px; }
.edit-order-btn { margin: 0 14px 12px; width: calc(100% - 28px); }

.cart-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.cart-edit-bar .ceb-text {
  line-height: 1.5;
  color: #92400e;
}
.order-card .date { font-size: 12px; color: var(--muted); }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.status-new { background: #fee2e2; color: #b91c1c; }
.status-preparing { background: #fef3c7; color: #b45309; }
.status-delivering { background: #dbeafe; color: #1d4ed8; }
.status-delivered { background: #dcfce7; color: #15803d; }

.order-items { padding: 4px 14px 8px; }
.order-item-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 3px 0;
  color: #374151;
  gap: 8px;
}
.order-item-line .oitem-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
}
.order-item-line .oitem-emoji { font-size: 20px; width: 32px; height: 32px; display: grid; place-items: center; background: #f3f4f6; border-radius: 8px; flex-shrink: 0; }
.order-item-line .q { color: var(--muted); }

.order-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f9fafb;
  border-top: 1px solid var(--border);
  font-weight: 800;
  font-size: 15px;
}
.order-foot .total { color: var(--primary-dark); font-size: 17px; }

/* شريط حالات الطلب */
.status-bar {
  display: flex;
  align-items: center;
  padding: 0 14px 12px;
  gap: 0;
}

.status-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  color: var(--muted);
  position: relative;
}

.status-step .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e5e7eb;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #e5e7eb;
  z-index: 1;
}

.status-step.done .dot { background: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.status-step.current .dot { background: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.status-step.current { color: var(--accent); font-weight: 700; }
.status-step.done { color: var(--primary); }

.status-bar .line {
  flex: 1;
  height: 3px;
  background: #e5e7eb;
  margin-top: -17px;
  position: relative;
  z-index: 0;
}

.status-bar .line.done { background: var(--primary); }

/* ===== الإشعارات ===== */
.notif-item {
  display: flex;
  gap: 12px;
  background: var(--card);
  margin: 0 16px 10px;
  padding: 13px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  align-items: flex-start;
}

.notif-item.unread { border-right: 4px solid var(--primary); background: #f7fef9; }

.notif-item .ni { font-size: 26px; flex-shrink: 0; }

.notif-item .tx { flex: 1; min-width: 0; }
.notif-item .tx .tt { font-weight: 700; font-size: 14.5px; }
.notif-item .tx .mm { font-size: 13px; color: var(--muted); margin-top: 2px; }
.notif-item .tx .tm { font-size: 11px; color: #9ca3af; margin-top: 5px; }

/* ===== الحساب ===== */
.account-card {
  background: var(--card);
  margin: 0 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a, #84cc16);
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

/* ===== شريط التنقل السفلي ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  padding: 9px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  position: relative;
}

.nav-item .ic { font-size: 21px; position: relative; }

.nav-item.active { color: var(--primary); font-weight: 800; }

.badge {
  position: absolute;
  top: -4px;
  left: -7px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

/* ===== Toast ===== */
.toast-wrap {
  position: fixed;
  top: 16px;
  right: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #111827;
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.25s ease;
  max-width: 90vw;
  text-align: center;
}

@keyframes slideDown {
  from { transform: translateY(-16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  z-index: 150;
  padding: 20px;
}

.modal {
  background: var(--card);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
  animation: pop 0.2s ease;
}

@keyframes pop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h3 { margin-bottom: 16px; font-size: 18px; font-weight: 800; }

/* ===== لوحة أبو ليث ===== */
.admin-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, #1f2937, #111827);
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-top .logo-title { font-size: 17px; }

.admin-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }

.admin-tab {
  flex-shrink: 0;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
}

.admin-tab.active { background: #1f2937; color: #fff; border-color: #1f2937; }

.admin-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 0 16px 20px;
}

@media (min-width: 900px) {
  .admin-layout { grid-template-columns: 1fr 340px; align-items: start; }
}

.order-card.admin { border-top: none; border-right: 5px solid var(--accent); }

.order-card.admin.status-new { border-right-color: var(--danger); }
.order-card.admin.status-preparing { border-right-color: var(--accent); }
.order-card.admin.status-delivering { border-right-color: var(--blue); }
.order-card.admin.status-delivered { border-right-color: var(--primary); }

.admin-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.admin-card h3 { font-size: 16px; font-weight: 800; margin-bottom: 12px; }

.cust-info { background: #f8fafc; border-radius: 10px; padding: 10px 12px; margin: 0 14px 10px; font-size: 13px; }
.cust-info div { padding: 2px 0; }
.cust-info .lb { color: var(--muted); font-size: 12px; }

.status-buttons { display: flex; gap: 8px; padding: 0 14px 14px; flex-wrap: wrap; }

.status-btn {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  border: 1.5px solid var(--border);
  background: var(--card);
}

.status-btn.active-sb { color: #fff; }
.status-btn[data-s="new"].active-sb { background: #dc2626; border-color: #dc2626; }
.status-btn[data-s="preparing"].active-sb { background: #d97706; border-color: #d97706; }
.status-btn[data-s="delivering"].active-sb { background: #2563eb; border-color: #2563eb; }
.status-btn[data-s="delivered"].active-sb { background: #16a34a; border-color: #16a34a; }

.product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.cats-manager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.cats-manager .cm-label { font-size: 13px; font-weight: 700; color: #374151; }
.cats-manager .cm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  color: #1f2937;
}
.cats-manager .cm-del {
  cursor: pointer;
  color: #ef4444;
  font-size: 13px;
  padding: 0 2px;
  border-radius: 50%;
}
.cats-manager .cm-del:active { background: #fee2e2; }

.product-row .pe {
  font-size: 26px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #f3f4f6;
  flex-shrink: 0;
}

.product-row .pe img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-row .mid { flex: 1; min-width: 0; }
.product-row .mid .nm { font-weight: 700; font-size: 14px; }
.product-row .mid .ct { font-size: 12px; color: var(--muted); }
.product-row .mid .pr { font-size: 13px; color: var(--primary-dark); font-weight: 700; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.icon-btn.edit { background: var(--primary-light); color: var(--primary-dark); }
.icon-btn.del { background: #fee2e2; color: var(--danger); }

/* ===== شاشة الدخول ===== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(160deg, #f0fdf4, #dcfce7);
}

.login-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px 26px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card .logo-icon { margin: 0 auto 14px; }
.login-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .field { text-align: right; }

.login-error {
  background: #fee2e2;
  color: #b91c1c;
  font-size: 13px;
  padding: 9px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-weight: 600;
}

.hint { margin-top: 14px; font-size: 12px; color: #9ca3af; }

/* ===== فلترة طلبات الإدارة ===== */
.filter-row { display: flex; gap: 8px; padding: 4px 16px 12px; flex-wrap: wrap; }
.filter-chip {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--muted);
}
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* نافذة إضافة منتج */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* شريط تنقل الإدارة للجوال */
.admin-nav {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 60;
}
.admin-nav .nav-item { padding: 9px 4px 10px; }
.admin-shell { padding-bottom: 80px; }

@media (min-width: 900px) {
  .admin-nav { display: none; }
  .admin-shell { padding-bottom: 24px; }
  .admin-top { border-bottom: 1px solid #374151; }
}

.login-link {
  text-align: center;
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
}
.login-link a { color: var(--primary); font-weight: 700; }

.money-msg { text-align: center; padding: 18px; font-size: 14px; }

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f87171;
  position: absolute;
  top: 0;
  left: -2px;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0); }
}
