/* ==========================================================================
   Restaurant Pager — dashboard styles (RTL, no build step needed)
   ========================================================================== */
:root {
    --brand: #e11d48;
    --brand-soft: #ffe4ea;
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --line: #e5e7eb;
    --ok: #16a34a;
    --ok-soft: #dcfce7;
    --warn: #d97706;
    --warn-soft: #fef3c7;
    --bad: #dc2626;
    --bad-soft: #fee2e2;
    --info: #2563eb;
    --info-soft: #dbeafe;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
small, .muted { color: var(--muted); }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; text-align: left; }
pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; }
code.inline { background: #f1f5f9; padding: 2px 6px; border-radius: 6px; font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

/* ---------- Top bar ---------- */
.topbar {
    background: #111827; color: #fff; position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 58px; flex-wrap: wrap;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: #fff; font-size: 1.05rem; }
.topbar .brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: #fff; }
.topbar .brand .dot { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topbar nav a {
    color: #cbd5e1; padding: 8px 12px; border-radius: 8px; font-size: .92rem; white-space: nowrap;
}
.topbar nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.topbar nav a.active { background: var(--brand); color: #fff; }
.topbar .user { display: flex; align-items: center; gap: 8px; color: #9ca3af; font-size: .85rem; }
.topbar .user form { margin: 0; }
.topbar .menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }
.admin-banner { background: #fbbf24; color: #111; text-align: center; padding: 6px; font-size: .9rem; }
.admin-banner form { display: inline; }

@media (max-width: 900px) {
    .topbar .menu-toggle { display: block; margin-inline-start: auto; }
    .topbar nav, .topbar .user { display: none; width: 100%; }
    .topbar.open nav { display: flex; flex-direction: column; padding-bottom: 8px; }
    .topbar.open .user { display: flex; padding-bottom: 12px; }
}

/* ---------- Layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.container.wide { max-width: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.text-center { text-align: center; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line); }
.card h2 { font-size: 1.05rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- Stat tiles ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.7rem; font-weight: 800; margin-top: 2px; }
.stat .value small { font-size: .9rem; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--line); background: #fff; color: var(--text);
    padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
    text-decoration: none !important; white-space: nowrap; transition: transform .05s, background .15s;
}
.btn:hover { background: #f9fafb; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand); filter: brightness(.93); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: var(--ok); filter: brightness(.93); }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-danger { background: #fff; color: var(--bad); border-color: #fecaca; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-dark { background: #111827; color: #fff; border-color: #111827; }
.btn-sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: 13px 20px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=url], select, textarea {
    width: 100%; border: 1px solid #d1d5db; border-radius: 10px; padding: 10px 12px; font: inherit;
    background: #fff; color: var(--text); transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=color] { width: 60px; height: 40px; border: 1px solid #d1d5db; border-radius: 10px; padding: 2px; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.error { color: var(--bad); font-size: .85rem; margin-top: 4px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters .field { margin: 0; min-width: 140px; }

/* ---------- Alerts / badges ---------- */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert-ok { background: var(--ok-soft); border-color: #bbf7d0; color: #14532d; }
.alert-bad { background: var(--bad-soft); border-color: #fecaca; color: #7f1d1d; }
.alert-info { background: var(--info-soft); border-color: #bfdbfe; color: #1e3a8a; }
.alert ul { margin: 0; padding-inline-start: 18px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: #f3f4f6; color: #374151; white-space: nowrap; }
.badge-preparing { background: var(--warn-soft); color: #92400e; }
.badge-ready { background: var(--ok-soft); color: #166534; }
.badge-collected { background: var(--info-soft); color: #1e40af; }
.badge-cancelled { background: var(--bad-soft); color: #991b1b; }
.badge-bad { background: var(--bad-soft); color: #991b1b; }
.badge-ok { background: var(--ok-soft); color: #166534; }
.tag { display: inline-block; background: var(--bad-soft); color: #991b1b; padding: 1px 8px; border-radius: 6px; font-size: .8rem; margin: 2px 0 2px 4px; }
.stars { color: #f59e0b; letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: #d1d5db; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.table th { font-size: .82rem; color: var(--muted); font-weight: 700; background: #fafafa; white-space: nowrap; }
.table tr:hover td { background: #fcfcfd; }

.bar { height: 8px; background: #f1f5f9; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar.ok > span { background: var(--ok); } .bar.warn > span { background: var(--warn); } .bar.bad > span { background: var(--bad); }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; list-style: none; padding: 0; }
.pagination a, .pagination span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
.pagination .active span { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled span { opacity: .45; }

/* ---------- Kitchen board ---------- */
.board-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.board-stats .stat { flex: 1; min-width: 150px; padding: 10px 14px; }
.board-stats .stat .value { font-size: 1.4rem; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .board { grid-template-columns: 1fr 1fr; } .board .col-collected { grid-column: 1 / -1; } }
@media (max-width: 700px) { .board { grid-template-columns: 1fr; } }
.col { background: #e9ebef; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; font-weight: 800; }
.col-head .count { background: #fff; border-radius: 99px; padding: 0 10px; font-size: .9rem; }
.col-preparing .col-head { color: #92400e; }
.col-ready .col-head { color: #166534; }
.col-collected .col-head { color: #1e40af; }
.col .empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: .9rem; }

.ticket { background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); border-inline-start: 5px solid var(--warn); }
.ticket.ready { border-inline-start-color: var(--ok); }
.ticket.collected { border-inline-start-color: var(--info); opacity: .85; }
.ticket.late { border-inline-start-color: var(--bad); background: #fffafa; }
.ticket.flash { animation: flash 1s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 4px var(--brand-soft); } }
.ticket .t-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.ticket .t-num { font-size: 1.35rem; font-weight: 900; letter-spacing: .5px; }
.ticket .t-name { font-weight: 700; }
.ticket .t-meta { font-size: .8rem; color: var(--muted); }
.ticket .t-items { margin: 8px 0; padding: 0; list-style: none; font-size: .95rem; }
.ticket .t-items li { padding: 2px 0; border-bottom: 1px dashed #eee; }
.ticket .t-items li:last-child { border-bottom: 0; }
.ticket .t-items .qty { font-weight: 800; color: var(--brand); margin-inline-end: 4px; }
.ticket .t-items .note { display: block; font-size: .8rem; color: var(--warn); }
.ticket .t-notes { background: var(--warn-soft); color: #78350f; padding: 6px 8px; border-radius: 8px; font-size: .85rem; margin-bottom: 8px; }
.ticket .timer { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.05rem; white-space: nowrap; }
.ticket .timer.late { color: var(--bad); }
.ticket .t-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ticket .t-actions .btn-ok { flex: 1; }
.scan-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d1d5db; margin-inline-end: 4px; }
.scan-dot.on { background: var(--ok); }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
.live-dot.off { background: var(--bad); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .6); } 70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.open { display: flex; }
.modal-box { background: #fff; border-radius: 18px; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-box.sm { max-width: 420px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-close { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--muted); line-height: 1; }

/* ---------- Order entry ---------- */
.menu-picks { display: flex; flex-wrap: wrap; gap: 6px; max-height: 190px; overflow-y: auto; padding: 2px; }
.menu-picks button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: .88rem; }
.menu-picks button:hover { border-color: var(--brand); color: var(--brand); }
.item-row { display: grid; grid-template-columns: 70px 1fr 1fr 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
@media (max-width: 600px) { .item-row { grid-template-columns: 60px 1fr 36px; } .item-row .item-note { grid-column: 1 / -1; grid-row: 2; } }
.item-row .remove { background: var(--bad-soft); color: var(--bad); border: 0; border-radius: 8px; height: 40px; cursor: pointer; font-size: 1.1rem; }
.qr-box { display: flex; justify-content: center; }
.qr-box svg { width: 260px; height: 260px; max-width: 100%; }
.big-number { font-size: 2.6rem; font-weight: 900; text-align: center; letter-spacing: 1px; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #111827, #1f2937 60%, var(--brand)); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--brand); margin: 0 auto 12px; display: grid; place-items: center; font-size: 2rem; }

/* ---------- Charts ---------- */
.dist-row { display: grid; grid-template-columns: 50px 1fr 40px; gap: 8px; align-items: center; margin-bottom: 6px; font-size: .9rem; }
.trend { display: flex; align-items: end; gap: 4px; height: 120px; padding-top: 10px; }
.trend .b { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; opacity: .85; }
.trend .b:hover { opacity: 1; }
.trend .b span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: .7rem; color: var(--muted); }

.fb-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.fb-card.problem { border-inline-start: 4px solid var(--bad); }
.fb-card.reviewed { opacity: .7; }
.fb-items { margin: 8px 0 0; padding: 0; list-style: none; }
.fb-items li { padding: 6px 0; border-top: 1px dashed var(--line); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px); background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 200; transition: transform .25s; max-width: 92vw; }
.toast.show { transform: translateX(-50%) translateY(0); }

@media print { .no-print, .topbar { display: none !important; } body { background: #fff; } }

/* ---------- Quick entry (cashier number) ---------- */
.quick-bar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; background: #fff; border: 2px solid var(--brand); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.quick-bar label { margin-bottom: 4px; }
.quick-main { flex: 1.2; min-width: 180px; }
.quick-main input { font-size: 1.8rem; font-weight: 800; padding: 10px 14px; letter-spacing: 1px; }
.quick-opt { flex: 1; min-width: 160px; }
.quick-min { flex: .5; min-width: 110px; }
.quick-bar .btn-lg { padding: 16px 22px; font-size: 1.1rem; }
@media (max-width: 680px) { .quick-bar .btn-lg { width: 100%; } }
