/* ─── Design tokens ──────────────────────────────────── */
:root {
  --primary:       #D85A30;
  --primary-light: #FAECE6;
  --bg:            #FAF9F6;
  --card:          #FFFFFF;
  --dark:          #2C2C2A;
  --gray:          #888780;
  --gray-light:    #D3D2C7;
  --green:         #639922;
  --green-light:   #EAF3DE;
  --amber:         #BA7511;
  --amber-light:   #FAEED9;
  --navy:          #253144;
  --navy-dark:     #1a2435;
  --sidebar-w:     240px;
  --topbar-h:      60px;
}

/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--dark);
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout shell ──────────────────────────────────── */
.layout { display: block; min-height: 100vh; }

/* ─── Sidebar overlay (mobile) ──────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 199;
  animation: fadeIn .2s ease;
  /* Ensure it sits above sticky topbar */
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.show { display: block; }
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }

/* ─── Sidebar ───────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  padding: 0;
  /* Sidebar must sit above the overlay */
  z-index: 200;
  /* Off-screen by default on mobile */
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  /* Helps GPU-accelerate the slide on iOS Safari */
  will-change: transform;
  -webkit-overflow-scrolling: touch;
}
.sidebar.open { transform: translateX(0) !important; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.sidebar-logo {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #e8784e);
  display: grid; place-items: center; font-size: 16px;
}
.sidebar-brand h1 { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-brand p  { font-size: 10px; color: #a9b0bd; }

.sidebar-close {
  background: rgba(255,255,255,.07); border: none; border-radius: 8px;
  color: #a9b0bd; cursor: pointer; padding: 8px; display: flex;
  align-items: center; justify-content: center;
}
.sidebar-close:hover { background: rgba(255,255,255,.14); color: #fff; }

.sidebar nav { padding: 12px 10px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px; border-radius: 10px;
  color: #b3b9c5; text-decoration: none;
  font-size: 14px; font-weight: 500;
  margin-bottom: 2px; transition: background .15s, color .15s;
}
.sidebar nav a .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar nav a:hover  { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar-footer {
  padding: 16px; border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-footer a {
  display: flex; align-items: center; gap: 8px;
  color: #7a8291; font-size: 13px; text-decoration: none;
  padding: 10px 12px; border-radius: 8px;
}
.sidebar-footer a:hover { background: rgba(255,255,255,.07); color: #fff; }

/* ─── Main content area ─────────────────────────────── */
.content { min-width: 0; }

/* ─── Topbar ────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--gray-light);
  padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.topbar h2 { font-size: 16px; font-weight: 700; flex: 1; }

.hamburger {
  background: none; border: none; cursor: pointer; padding: 8px;
  border-radius: 8px; color: var(--dark); display: flex; flex-direction: column;
  gap: 4px; align-items: center; justify-content: center;
  transition: background .15s;
}
.hamburger:hover { background: var(--bg); }
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: var(--dark); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-badge {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
}
.topbar a.logout { color: var(--gray); font-size: 12px; text-decoration: none; white-space: nowrap; }

/* ─── Page body ─────────────────────────────────────── */
.page-body { padding: 16px; }

/* ─── Stat cards ─────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--gray-light);
  border-radius: 12px; padding: 16px;
}
.stat-card .label { font-size: 11px; color: var(--gray); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 24px; font-weight: 800; margin-top: 6px; line-height: 1; }

/* ─── Table wrapper ─────────────────────────────────── */
.card-wrap {
  background: var(--card); border: 1px solid var(--gray-light);
  border-radius: 12px; overflow: hidden;
}
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
table th {
  text-align: left; font-size: 11px; color: var(--gray);
  font-weight: 600; padding: 12px 16px;
  border-bottom: 1px solid var(--gray-light);
  white-space: nowrap; background: var(--card);
}
table td {
  padding: 14px 16px; font-size: 13px;
  border-bottom: 1px solid #f0f0ec; vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: rgba(0,0,0,.015); }

/* ─── Badges ─────────────────────────────────────────── */
.badge { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-pending, .badge-awaiting_payment { background: var(--gray-light); color: var(--dark); }
.badge-accepted { background: var(--primary-light); color: var(--primary); }
.badge-preparing { background: var(--amber-light); color: var(--amber); }
.badge-out_for_delivery { background: var(--primary-light); color: var(--primary); }
.badge-delivered { background: var(--green-light); color: var(--green); }
.badge-cancelled { background: #FBE7E2; color: #99351D; }
.badge-unassigned { background: var(--gray-light); color: var(--dark); }

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
  padding: 10px 16px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block; white-space: nowrap;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost   { background: transparent; color: var(--gray); border: 1px solid var(--gray-light); }
.btn-block   { display: block; width: 100%; text-align: center; padding: 12px; }

/* ─── Order cards (orders.php) ──────────────────────── */
.order-card {
  padding: 16px; border-bottom: 1px solid #f0f0ec;
}
.order-card:last-child { border-bottom: none; }
.order-card-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 8px; gap: 8px;
}
.order-card-title { font-size: 15px; font-weight: 700; }
.order-card-meta  { font-size: 12px; color: var(--gray); margin: 3px 0; }
.order-card-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px;
}
.order-card-actions .btn { flex: 1; min-width: 120px; text-align: center; }
.order-card-actions select {
  flex: 1; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--gray-light); font-size: 13px;
  background: var(--bg); min-width: 140px;
}

/* Filter tabs (orders.php) */
.filter-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 16px; padding-bottom: 0; scroll-snap-type: x mandatory; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tabs .btn { flex-shrink: 0; scroll-snap-align: start; }

/* ─── Inline forms ──────────────────────────────────── */
form.inline { display: inline; }

/* ─── Flash message ─────────────────────────────────── */
.flash-success {
  background: var(--green-light); border: 1px solid var(--green);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 16px;
}
.alert-error { background: #FBE7E2; color: #99351D; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }

/* ─── Auth pages ─────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card  { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--gray-light); border-radius: 16px; padding: 32px; }
.auth-card h1   { font-size: 20px; text-align: center; margin: 0 0 4px; font-weight: 800; }
.auth-card .muted { text-align: center; color: var(--gray); font-size: 13px; margin: 0 0 20px; }
form label  { display: block; font-size: 12px; font-weight: 600; color: var(--gray); margin-top: 14px; }
form input, form select { width: 100%; margin-top: 6px; padding: 12px; border: 1px solid var(--gray-light); border-radius: 8px; font-size: 14px; background: var(--card); }
form input:focus, form select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

/* ─── Section title row ──────────────────────────────── */
.section-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.section-row h3 { font-size: 15px; font-weight: 700; }

/* ─── Audit log ─────────────────────────────────────── */
.audit-card {
  padding: 12px 16px; border-bottom: 1px solid #f0f0ec; font-size: 13px;
}
.audit-card:last-child { border-bottom: none; }
.audit-card strong { display: block; font-size: 13px; font-weight: 600; }
.audit-card span { font-size: 12px; color: var(--gray); }

/* ─── Tablet (≥ 640px) ──────────────────────────────── */
@media (min-width: 640px) {
  .page-body { padding: 20px 24px; }
  .topbar { padding: 0 24px; }
  .topbar h2 { font-size: 18px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}

/* ─── Desktop (≥ 1024px) ────────────────────────────── */
@media (min-width: 1024px) {
  .layout { display: flex; }

  .sidebar-overlay { display: none !important; }

  .sidebar {
    position: sticky; top: 0;
    /* On desktop always visible — override any mobile transform */
    transform: translateX(0) !important;
    height: 100vh; flex-shrink: 0;
    /* No transition on desktop — sidebar never slides */
    transition: none !important;
  }
  .sidebar-close { display: none; }

  .content { flex: 1; min-width: 0; }

  .hamburger { display: none; }

  .page-body { padding: 28px 32px; }
  .topbar    { padding: 0 32px; }
  .topbar h2 { font-size: 20px; }

  .stat-cards { grid-template-columns: repeat(4, 1fr); }
}
