:root {
  --maroon: #7a1220;
  --maroon-dark: #55020e;
  --gold: #d9a441;
  --cream: #fdf6ec;
  --ink: #241b16;
  --gray: #6b6058;
  --border: #e8ddce;
  --success: #2e7d46;
  --danger: #b93b3b;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  padding-bottom: 60px;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--maroon);
  color: white;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 52px; width: 52px; object-fit: contain; border-radius: 50%; background: white; padding: 4px; }
.brand h1 { font-size: 1.15rem; margin: 0; line-height: 1.2; }
.tagline { margin: 0; font-size: .8rem; opacity: .85; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.phone-pill {
  background: rgba(255,255,255,.15);
  color: white;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: .85rem;
  white-space: nowrap;
}
.cart-btn {
  background: var(--gold);
  color: var(--maroon-dark);
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: .9rem;
  position: relative;
}
.cart-count {
  background: var(--maroon-dark);
  color: white;
  border-radius: 50%;
  padding: 1px 7px;
  font-size: .75rem;
  margin-left: 4px;
}
.cat-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 20px;
  background: var(--maroon-dark);
  scrollbar-width: none;
}
.cat-nav::-webkit-scrollbar { display: none; }
.cat-nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .85rem;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 16px;
}
.cat-nav a:hover { background: rgba(255,255,255,.15); }

/* ---------- Menu ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 20px; }
.category-block { margin-bottom: 36px; }
.category-title {
  font-size: 1.3rem;
  color: var(--maroon);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.product-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.product-card img { width: 100%; height: 150px; object-fit: cover; background: #eee; }
.product-info { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-name { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.product-price { color: var(--maroon); font-weight: 700; }
.add-row { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.add-btn {
  background: var(--maroon);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  flex: 1;
}
.add-btn:hover { background: var(--maroon-dark); }
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--maroon);
  border-radius: 8px;
  padding: 4px 8px;
  flex: 1;
  justify-content: space-between;
}
.qty-stepper button {
  background: none; border: none; color: white; font-size: 1.1rem; cursor: pointer; padding: 0 6px;
}
.qty-stepper span { color: white; font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1100px;
  margin: 40px auto 0;
  padding: 20px;
  text-align: center;
  color: var(--gray);
  font-size: .9rem;
  border-top: 1px solid var(--border);
}
.track-link a { color: var(--maroon); }

/* ---------- Overlay / Drawer / Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90;
}
.hidden { display: none !important; }
.cart-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw;
  background: white; z-index: 100; display: flex; flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,.15);
}
.drawer-header, .modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.icon-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--gray); }
.cart-items { flex: 1; overflow-y: auto; padding: 12px 20px; }
.cart-line {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px dashed var(--border); gap: 10px;
}
.cart-line-name { font-weight: 600; font-size: .9rem; flex: 1; }
.cart-line-price { color: var(--gray); font-size: .85rem; }
.cart-summary { padding: 16px 20px; border-top: 1px solid var(--border); }
.cart-total-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 1.1rem; margin-bottom: 12px; }
.btn-primary {
  width: 100%; background: var(--maroon); color: white; border: none; padding: 12px;
  border-radius: 8px; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.btn-primary:hover { background: var(--maroon-dark); }
.btn-primary:disabled { background: #bbb; cursor: not-allowed; }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: white; z-index: 110; width: 420px; max-width: 92vw;
  border-radius: var(--radius); max-height: 88vh; overflow-y: auto;
}
.modal form { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; color: var(--ink); }
.modal input, .modal textarea, .modal select {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; font-size: .95rem; font-family: inherit;
}
.order-type-toggle { display: flex; gap: 20px; flex-direction: row !important; align-items: center; font-weight: 600; }
.order-type-toggle label { flex-direction: row !important; align-items: center; gap: 6px !important; font-weight: 500; }
.checkout-summary { background: var(--cream); border-radius: 8px; padding: 10px 12px; font-size: .9rem; }
.checkout-summary .line { display: flex; justify-content: space-between; }
.order-no { font-size: 1.4rem; font-weight: 800; color: var(--maroon); text-align: center; padding: 8px 20px; }
#confirmModal, #trackModal { padding-bottom: 20px; }
#confirmModal p, #trackModal p { padding: 0 20px; }
#trackResult { padding: 0 20px 16px; }

.empty-cart { text-align: center; color: var(--gray); padding: 40px 0; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 10px 18px; border-radius: 20px;
  z-index: 200; font-size: .9rem; opacity: 0; transition: opacity .2s ease;
}
.toast.show { opacity: 1; }

.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: .8rem; font-weight: 700;
}
.status-pending { background: #fff3cd; color: #856404; }
.status-confirmed { background: #cfe2ff; color: #084298; }
.status-preparing { background: #e2d9f3; color: #4a2a82; }
.status-out_for_delivery { background: #d1ecf1; color: #0c5460; }
.status-completed { background: #d4edda; color: #155724; }
.status-cancelled { background: #f8d7da; color: #721c24; }

/* ================= ADMIN ================= */
.admin-body { background: #f4f1ea; }
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px; background: var(--maroon-dark); color: white; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 20px 0;
}
.admin-sidebar .brand-mini { display: flex; align-items: center; gap: 10px; padding: 0 20px 20px; }
.admin-sidebar .brand-mini img { width: 36px; height: 36px; border-radius: 50%; background: white; }
.admin-sidebar .brand-mini span { font-weight: 700; font-size: .95rem; }
.admin-nav { display: flex; flex-direction: column; }
.admin-nav button {
  background: none; border: none; color: rgba(255,255,255,.8); text-align: left;
  padding: 12px 20px; cursor: pointer; font-size: .95rem;
}
.admin-nav button:hover, .admin-nav button.active { background: rgba(255,255,255,.1); color: white; }
.admin-main { flex: 1; padding: 30px; max-width: 1200px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.admin-topbar h1 { margin: 0; font-size: 1.5rem; color: var(--maroon); }
.logout-btn { background: none; border: 1px solid var(--maroon); color: var(--maroon); border-radius: 8px; padding: 8px 14px; cursor: pointer; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 30px; }
.stat-card { background: white; border-radius: var(--radius); padding: 18px; border: 1px solid var(--border); }
.stat-card .num { font-size: 1.8rem; font-weight: 800; color: var(--maroon); }
.stat-card .label { color: var(--gray); font-size: .85rem; }

.admin-table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem; }
.admin-table th { background: var(--cream); color: var(--maroon-dark); }
.admin-table img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.admin-table input[type=number], .admin-table input[type=text] {
  width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: .9rem;
}
.row-actions { display: flex; gap: 8px; }
.btn-sm { padding: 6px 10px; border-radius: 6px; border: none; cursor: pointer; font-size: .8rem; font-weight: 600; }
.btn-save { background: var(--success); color: white; }
.btn-delete { background: var(--danger); color: white; }
.btn-add { background: var(--maroon); color: white; padding: 10px 16px; border-radius: 8px; border: none; cursor: pointer; font-weight: 700; margin-bottom: 16px; }
.pill-toggle { cursor: pointer; }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--maroon); }
.login-card { background: white; border-radius: var(--radius); padding: 32px; width: 340px; max-width: 90vw; text-align: center; }
.login-card img { width: 60px; margin-bottom: 12px; }
.login-card h2 { margin-top: 0; color: var(--maroon); }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-card input { border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: .95rem; }
.login-error { color: var(--danger); font-size: .85rem; min-height: 18px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }

@media (max-width: 700px) {
  .admin-sidebar { width: 60px; }
  .admin-sidebar .brand-mini span, .admin-nav button span.label { display: none; }
  .admin-main { padding: 16px; }
}
