/* BBQ Express Franchise Store - admin panel styles */
:root {
  --brand: #880000;
  --ink: #1d1b1a;
  --muted: #6c6762;
  --line: #e9e4df;
  --bg: #f6f4f2;
  --card: #fff;
  --side: 236px;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
code { background: #f3efeb; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; word-break: break-all; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 40; height: 56px; background: var(--brand); color: #fff; display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.topbar .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand small { font-weight: 400; opacity: .8; font-size: 12px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar-right a { color: #fff; text-decoration: none; }
.me { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.menu-toggle { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; display: grid; place-items: center; }
.hide-sm { display: none; }

/* Sidebar */
.sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: var(--side); background: #fff; border-right: 1px solid var(--line); padding: 12px 10px; overflow-y: auto; z-index: 35; transform: translateX(-100%); transition: transform .2s; display: flex; flex-direction: column; }
.sidebar.open { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.12); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a, .nav-btn { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: var(--ink); text-decoration: none; font: inherit; font-weight: 500; background: none; border: 0; width: 100%; cursor: pointer; text-align: left; }
.sidebar a:hover, .nav-btn:hover { background: #f6f2ef; }
.sidebar a.active { background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); }
.sidebar .pill { margin-left: auto; background: var(--brand); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 8px; }
.role-tag { margin-top: auto; font-size: 12px; color: var(--muted); padding: 10px 12px 0; border-top: 1px solid var(--line); }
.backdrop { position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.35); z-index: 30; display: none; }
.backdrop.show { display: block; }

/* Content */
.content { padding: 16px 14px 80px; max-width: 1280px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head p { margin: 0; }
.back { font-size: 13px; text-decoration: none; color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.cols { display: grid; gap: 14px; }
.cols > * { min-width: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat b { font-size: 20px; }
a.stat:hover { border-color: var(--brand); }
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { border-bottom: 1px solid var(--line); }
.status-list li:last-child { border: 0; }
.status-list li > a, .status-list li > span:first-child { display: flex; }
.status-list a, .status-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; text-decoration: none; color: var(--ink); gap: 10px; }
.status-list a { padding: 0; width: 100%; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eee; color: #444; white-space: nowrap; }
.badge-new { background: #e7f0ff; color: #1d4ed8; }
.badge-confirmed { background: #ede9fe; color: #6d28d9; }
.badge-processing { background: #fff4d6; color: #92600a; }
.badge-dispatched { background: #e0f2fe; color: #0369a1; }
.badge-delivered, .badge-paid { background: #e6f6ea; color: #17602b; }
.badge-cancelled, .badge-failed { background: #fdecea; color: #a1231a; }
.badge-pending { background: #fff4d6; color: #92600a; }
.badge-refunded { background: #f1f0ee; color: #555; }
.badge-role-super_admin { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); }
.badge-role-manager { background: #e0f2fe; color: #0369a1; }
.badge-role-staff { background: #f1f0ee; color: #555; }

/* Tables (become cards on phones) */
.table-wrap { width: 100%; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.row-link { cursor: pointer; }
.row-link:hover td { background: #fbf9f7; }
.actions { white-space: nowrap; text-align: right; }
.actions form { display: inline; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; display: grid; place-items: center; background: #f3efeb; color: var(--muted); font-weight: 700; }
.thumb-lg { max-width: 160px; border-radius: 10px; margin-top: 6px; }
.price-input { width: 100px; }
.perm-table td, .perm-table th { font-size: 12.5px; text-align: center; padding: 6px; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }

@media (max-width: 759px) {
  .table:not(.perm-table) thead { display: none; }
  .table:not(.perm-table), .table:not(.perm-table) tbody, .table:not(.perm-table) tr, .table:not(.perm-table) td { display: block; width: 100%; }
  .table:not(.perm-table) tr { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; }
  .table:not(.perm-table) td { border: 0; padding: 5px 0; text-align: right; overflow: hidden; }
  .table:not(.perm-table) td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; float: left; margin-right: 14px; }
  .table:not(.perm-table) td.thumb-cell { display: none; }
  .table:not(.perm-table) td.actions { padding-top: 8px; white-space: normal; }
  .table:not(.perm-table) td.actions .btn { margin: 2px 0 2px 4px; }
}

/* Forms */
.form { display: grid; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
.form-2col { grid-template-columns: 1fr; }
.narrow-form { max-width: 520px; }
input, select, textarea { font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid #d8d0c8; border-radius: 9px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input[type=checkbox] { width: 17px; height: 17px; padding: 0; accent-color: var(--brand); flex: none; }
input[type=color] { height: 40px; padding: 3px; }
input[type=file] { padding: 7px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 25%, transparent); border-color: var(--brand); }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters > * { flex: 1 1 160px; width: auto; }
.filters .btn { flex: 0 0 auto; }
.filters .inline { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); background: #fff; white-space: nowrap; }
.settings-form section { scroll-margin-top: 70px; }
.logo-preview { background: var(--brand); padding: 10px; border-radius: 10px; display: inline-block; }
.logo-preview img { max-height: 60px; display: block; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 6px; display: flex; justify-content: flex-end; z-index: 5; }
.card .sticky-save { background: linear-gradient(transparent, #fff 30%); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 9px; padding: 8px 14px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 38px; white-space: nowrap; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 85%, #000); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: #fff; color: #b3261e; border-color: #f2c9c5; }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: 12.5px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-group form { display: inline; }

/* Order view */
.info-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.info-grid div { display: flex; flex-direction: column; }
.info-grid span { font-size: 12px; color: var(--muted); }
.info-grid b { font-weight: 500; word-break: break-word; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; max-width: 320px; margin: 12px 0 0 auto; }
.totals dt, .totals dd { margin: 0; }
.totals dd { text-align: right; }
.totals .total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--line); padding-top: 8px; }
.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

/* Veg dot */
.dot { display: inline-block; width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 3px; position: relative; vertical-align: -1px; }
.dot::after { content: ''; position: absolute; inset: 2px; border-radius: 50%; background: currentColor; }
.dot.veg { color: #1d8a3a; }
.dot.nonveg { color: #b3261e; }

/* Alerts & pagination */
.alert { border-radius: 9px; padding: 10px 14px; margin: 0 0 12px; }
.alert-success { background: #e6f6ea; color: #17602b; }
.alert-error { background: #fdecea; color: #8a1c14; }
.alert-info { background: #fff6e0; color: #7a5200; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.pagination a, .pagination span { padding: 5px 11px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: #fff; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Login / install */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #000)); }
.auth-box { background: #fff; border-radius: 16px; padding: 28px 24px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-box h1 { font-size: 22px; }
.auth-logo { max-height: 56px; margin-bottom: 12px; background: var(--brand); padding: 8px; border-radius: 10px; }

/* ---------- Tablet & up ---------- */
@media (min-width: 760px) {
  .content { padding: 22px 24px 60px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-2col { grid-template-columns: 1fr 1fr; }
  .form-2col .span-2, .form-2col h2, .form-2col > p { grid-column: span 2; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .info-grid .span-2 { grid-column: span 2; }
  .hide-sm { display: inline; }
}

/* ---------- Laptop / desktop: fixed sidebar ---------- */
@media (min-width: 1024px) {
  .menu-toggle { display: none; }
  .sidebar { transform: none; }
  .backdrop { display: none !important; }
  .content { margin-left: var(--side); padding: 24px 28px 60px; }
  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); align-items: start; }
}
