/* ===== MA Coffee — التصميم العام ===== */
:root {
  --bg:        #ffffff;   /* أبيض */
  --bg-soft:   #f2f6fc;   /* أزرق فاتح جدًا (خلفيات ناعمة) */
  --card:      #ffffff;
  --card-2:    #e9f1fd;
  --line:      #d7e3f2;
  --text:      #0b1a2b;   /* أسود */
  --muted:     #5b6a7d;
  --blue:      #1565c0;   /* الأزرق الأساسي */
  --blue-soft: #1976d2;
  --green:     #2e9e5b;
  --red:       #d64545;
  --shadow:    0 6px 20px rgba(13,40,80,.12);
  --radius:    18px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Tajawal', 'Cairo', system-ui, sans-serif;
  direction: rtl;
  min-height: 100%;
}

body { padding-bottom: 120px; }

img { display: block; max-width: 100%; }

button { font-family: inherit; cursor: pointer; border: none; }

/* ===== الهيدر ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
}
.topbar img.logo { width: 52px; height: 52px; object-fit: contain; animation: logo-pulse 2.6s ease-in-out infinite; }
.topbar .brand { display: flex; flex-direction: column; }
.topbar .brand b { font-size: 19px; letter-spacing: .5px; }
.topbar .brand span { font-size: 12px; color: var(--muted); }
.topbar .spacer { flex: 1; }

.wrap { max-width: 760px; margin: 0 auto; padding: 18px; }

/* ===== شاشة إدخال البيانات ===== */
.gate {
  min-height: 70vh; display: flex; align-items: center; justify-content: center;
}
.gate-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 26px; width: 100%; max-width: 420px; text-align: center;
}
.gate-card img { width: 120px; height: 120px; margin: 0 auto 14px; object-fit: contain; animation: logo-pulse 2.6s ease-in-out infinite; }

@keyframes logo-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}
@media (prefers-reduced-motion: reduce) {
  .topbar img.logo, .gate-card img { animation: none; }
}
.gate-card h1 { font-size: 24px; margin-bottom: 6px; }
.gate-card p { color: var(--muted); margin-bottom: 22px; font-size: 14px; }

.field { text-align: right; margin-bottom: 16px; }
.field label { display: block; font-size: 14px; margin-bottom: 7px; color: var(--blue); }
.field input {
  width: 100%; padding: 14px 16px; font-size: 16px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
.field input:focus { border-color: var(--blue); }
.field .err { color: var(--red); font-size: 12px; margin-top: 6px; display: none; }

.btn {
  width: 100%; padding: 15px; font-size: 17px; font-weight: 700;
  background: var(--blue); color: #fff; border-radius: 12px;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); }

/* ===== أقسام المنيو ===== */
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; margin: 26px 4px 14px;
}
.section-title::before { content: ''; width: 6px; height: 22px; border-radius: 4px; background: var(--blue); }
.section-title.offers::before { background: linear-gradient(var(--blue), var(--blue-soft)); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.card.offer { border-color: var(--blue); }
.card .thumb { position: relative; aspect-ratio: 4/3; background: var(--bg-soft); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .badge {
  position: absolute; top: 10px; inset-inline-start: 10px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
}
.card .body { padding: 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card .name { font-size: 17px; font-weight: 700; }
.card .desc { font-size: 13px; color: var(--muted); }
.card .price { font-size: 16px; color: var(--blue); font-weight: 700; margin-top: auto; }
.card .price .old { color: var(--muted); text-decoration: line-through; font-size: 13px; margin-inline-start: 6px; font-weight: 400; }

/* مجموعات الخيارات */
.opt-group { margin: 2px 0; }
.opt-group .opt-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px; font-size: 13px; border-radius: 20px;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
}
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 700; }

.add-btn {
  margin-top: 4px; padding: 11px; border-radius: 12px;
  background: var(--card-2); color: var(--text); border: 1px solid var(--blue);
  font-weight: 700; font-size: 15px; transition: background .15s;
}
.add-btn:hover { background: var(--blue); color: #fff; }

/* ===== سلة الطلب (شريط سفلي) ===== */
.cartbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 40;
  background: var(--bg);
  border-top: 1px solid var(--line); padding: 14px 18px;
  box-shadow: 0 -4px 16px rgba(13,40,80,.08);
  display: none;
}
.cartbar.show { display: block; }
.cartbar .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.cartbar .count {
  background: var(--blue); color: #fff; font-weight: 700;
  min-width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px;
}
.cartbar .total { font-size: 17px; font-weight: 700; }
.cartbar .btn { width: auto; padding: 13px 26px; }
.cartbar .spacer { flex: 1; }

/* ===== نافذة منبثقة (السلة / تأكيد) ===== */
.modal-bg {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--card); width: 100%; max-width: 600px;
  border-radius: 20px 20px 0 0; border: 1px solid var(--line);
  max-height: 85vh; overflow-y: auto; padding: 20px;
}
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }
.modal h2 { font-size: 20px; margin-bottom: 16px; display: flex; justify-content: space-between; }
.modal .close { background: var(--card-2); border-radius: 10px; padding: 4px 12px; color: var(--text); }

.line {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.line .info { flex: 1; }
.line .info b { font-size: 15px; }
.line .info small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.line .qty { display: flex; align-items: center; gap: 10px; }
.line .qty button {
  width: 30px; height: 30px; border-radius: 8px; font-size: 18px; font-weight: 700;
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
}
.line .lt { font-weight: 700; color: var(--blue); min-width: 64px; text-align: left; }

.summary { display: flex; justify-content: space-between; font-size: 19px; font-weight: 700; margin: 18px 0; }

.toast {
  position: fixed; top: 18px; inset-inline: 0; margin: 0 auto; width: max-content; max-width: 90%;
  background: var(--green); color: #10220f; font-weight: 700;
  padding: 12px 22px; border-radius: 30px; z-index: 80; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-14px); transition: .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--red); color: #2a0f0f; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ===== لوحة التحكم ===== */
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  text-align: center;
}
.stat b { font-size: 26px; color: var(--blue); display: block; }
.stat span { font-size: 13px; color: var(--muted); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.order {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 14px;
}
.order .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.order .head b { font-size: 17px; }
.order .head .phone { color: var(--muted); font-size: 13px; }
.order .time { color: var(--muted); font-size: 12px; }
.order ul { list-style: none; margin: 8px 0; }
.order ul li { padding: 4px 0; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.order ul li small { color: var(--muted); }
.order .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.order .foot .ototal { font-size: 17px; font-weight: 700; color: var(--blue); }

.status-badge { font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 20px; }
.s-جديد        { background: #e3effb; color: #1565c0; }
.s-قيد         { background: #fdf0d9; color: #8a5a00; }
.s-جاهز        { background: #e3f5ea; color: #1f7a44; }
.s-مكتمل       { background: #eceff3; color: #5b6a7d; }

.status-select {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; font-family: inherit;
}

/* ===== تبويبات لوحة التحكم ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tab {
  background: transparent; color: var(--muted); font-size: 16px; font-weight: 700;
  padding: 12px 18px; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.menu-admin-head { display: flex; justify-content: flex-start; margin-bottom: 16px; }

/* عناصر إدارة المنيو */
.admin-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; margin-bottom: 10px;
}
.admin-item.off { opacity: .55; }
.admin-item img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--bg-soft); }
.admin-item .ai-info { flex: 1; }
.admin-item .ai-info b { font-size: 16px; }
.admin-item .ai-info small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.admin-item .ai-edit { width: auto; padding: 9px 18px; font-size: 14px; }

/* صفوف الأحجام/الحرارة */
.kv-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.kv-row .kv-label { flex: 2; }
.kv-row .kv-price { flex: 1; }
.kv-row input {
  padding: 11px 12px; font-size: 15px; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; outline: none; width: 100%;
}
.kv-row input:focus { border-color: var(--blue); }
.kv-row .kv-del {
  width: 38px; height: 40px; flex: none; border-radius: 10px; font-size: 15px;
  background: var(--card-2); color: var(--red); border: 1px solid var(--line);
}

.switch-row { display: flex; align-items: center; gap: 10px; font-size: 15px; margin: 6px 0; cursor: pointer; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--blue); }

.btn.ghost.danger { color: var(--red); }
