/* MB Cloud POS — minimal Phase 1 styling. Kept plain on purpose: this
   is scaffolding to build and test the flow, not the final visual
   design (the POS screen shown in the reference screenshot is the
   target for the pos/ pages once Phase 1 sales logic is built). */

:root {
    --green: #17a673;
    --green-dark: #0f7a56;
    --ink: #1a2332;
    --muted: #6b7684;
    --border: #e2e6ea;
    --bg: #f6f8f9;
    --danger: #d64545;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a { color: var(--green-dark); }

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 420px;
}

.card h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

.card p.subtitle {
    color: var(--muted);
    margin: 0 0 24px;
    font-size: 14px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 16px 0 6px;
}

input[type=text], input[type=email], input[type=password], input[type=tel], select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.btn {
    display: inline-block;
    background: var(--green);
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
    text-align: center;
    text-decoration: none;
}

.btn:hover { background: var(--green-dark); }

.btn-secondary {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--border);
}

.helper-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--muted);
}

.flash {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.flash-success { background: #e6f7f0; color: var(--green-dark); }
.flash-error { background: #fdecec; color: var(--danger); }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: #16221c;
    color: #fff;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar .brand { padding: 0 20px 20px; font-weight: 700; font-size: 18px; }
.sidebar a {
    display: block;
    padding: 12px 20px;
    color: #cbd3ce;
    text-decoration: none;
    font-size: 14px;
}
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,0.08); color: #fff; }

.main { flex: 1; padding: 28px 32px; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #fafbfb; font-weight: 600; color: var(--muted); }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-pending { background: #fff4e0; color: #a3690b; }
.badge-active { background: #e6f7f0; color: var(--green-dark); }
.badge-suspended, .badge-rejected { background: #fdecec; color: var(--danger); }

/* ---- POS screen ---- */
.pos-layout { display: flex; gap: 20px; align-items: flex-start; }
.pos-left { flex: 1; min-width: 0; }
.pos-right {
    width: 360px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    position: sticky;
    top: 20px;
}
.pos-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.pos-toolbar input[type=text] { flex: 1; }
.pos-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.pos-tab {
    padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
    background: #fff; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--ink);
}
.pos-tab.active { background: var(--green); border-color: var(--green); color: #fff; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.product-card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px; cursor: pointer; transition: box-shadow .15s;
}
.product-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.product-card .icon { font-size: 28px; margin-bottom: 8px; }
.product-card .pname { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.product-card .pmeta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.product-card .pprice { font-weight: 700; color: var(--ink); }
.product-card.out-of-stock { opacity: 0.45; cursor: not-allowed; }

.source-toggle, .fulfil-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.toggle-btn {
    flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; text-align: center;
}
.toggle-btn.active { border-color: var(--green); color: var(--green-dark); background: #e6f7f0; }

.cart-line { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.cart-line .cname { font-size: 14px; font-weight: 600; }
.cart-line .cmeta { font-size: 12px; color: var(--muted); }
.qty-control { display: flex; align-items: center; gap: 8px; }
.qty-control button { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; line-height: 1; }
.cart-empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; }

.totals-row { display: flex; justify-content: space-between; font-size: 14px; margin: 6px 0; color: var(--muted); }
.totals-row.grand { font-size: 18px; font-weight: 700; color: var(--ink); margin-top: 10px; }

.row-btns { display: flex; gap: 8px; margin-top: 12px; }
.row-btns .btn, .row-btns .btn-secondary { margin-top: 0; padding: 10px; font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 360px; max-width: 92vw; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.held-order-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    background: #fff;
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

/* ---- Public ordering page (public/order.php) ----
   Its own mobile-first components, deliberately not shared with the
   staff POS screen's .pos-layout/.product-grid above — a customer
   browsing on their phone and a cashier working a till have different
   needs, and trying to force one layout to serve both is what made the
   original version hard to order from. */
.pub-topline { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.pub-status { font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-pill {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
    background: #fff; border: 1px solid var(--border); border-radius: 999px;
    padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--ink);
    cursor: pointer; white-space: nowrap;
}
.cart-pill.pulse { animation: cartPulse .35s ease; }
@keyframes cartPulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.12); background: #e6f7f0; border-color: var(--green); }
    100% { transform: scale(1); }
}

.fulfil-pills { display: flex; gap: 8px; margin-bottom: 14px; }
.fulfil-pill {
    flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 999px;
    background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; text-align: center; color: var(--ink);
}
.fulfil-pill.active { background: var(--green); border-color: var(--green); color: #fff; }

.pub-toolbar { margin-bottom: 14px; }

.cat-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 16px; scrollbar-width: none; }
.cat-scroll::-webkit-scrollbar { display: none; }
.cat-chip {
    flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
    background: #fff; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.cat-chip.active { background: #e6f7f0; border-color: var(--green); color: var(--green-dark); }

.product-list { display: flex; flex-direction: column; gap: 10px; }
.product-row {
    display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px; cursor: pointer; transition: box-shadow .15s;
}
.product-row:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.prow-avatar {
    width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; color: var(--ink); flex-shrink: 0; overflow: hidden;
}
.prow-avatar-img img { width: 100%; height: 100%; object-fit: cover; }
.prow-info { flex: 1; min-width: 0; }
.prow-name { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.prow-price { font-size: 13px; color: var(--muted); }
.prow-add {
    width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--green); color: #fff;
    font-size: 18px; font-weight: 600; cursor: pointer; flex-shrink: 0; line-height: 1;
}
.prow-add:hover { background: var(--green-dark); }

.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 14px rgba(0,0,0,0.08); z-index: 40; }
.cart-bar-inner { max-width: 1100px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cart-bar-info { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); line-height: 1.5; }
.cart-bar-info strong { font-size: 16px; color: var(--ink); }
.cart-bar .btn { width: auto; margin-top: 0; padding: 11px 20px; font-size: 14px; white-space: nowrap; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.review-sheet { background: #fff; width: 100%; max-width: 480px; max-height: 88vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.review-sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.review-sheet-head h2 { margin: 0; font-size: 17px; flex: 1; }
.sheet-back { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink); padding: 4px 8px; line-height: 1; }
.fulfil-summary {
    font-size: 12px; font-weight: 600; color: var(--green-dark); background: #e6f7f0;
    border-radius: 999px; padding: 5px 12px; cursor: pointer; white-space: nowrap;
}
.review-sheet-body { padding: 16px; overflow-y: auto; flex: 1; }
.totals-block { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.review-sheet-foot { padding: 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.review-sheet-foot .btn { margin-top: 0; }

@media (min-width: 640px) {
    .sheet-backdrop { align-items: center; }
    .review-sheet { border-radius: var(--radius); max-height: 85vh; }
}

/* ---- Mobile responsiveness ---- */
/* .pos-layout is shared by the staff POS screen (pos/index.php, built
   for a wide till/tablet) and the customer-facing public ordering page
   (public/order.php, opened directly on a customer's phone via the
   shared link/QR/WhatsApp share). Below this width there's no room for
   a 360px-wide cart column next to the product grid, so stack them
   instead of letting them collide — cart/checkout form moves below the
   menu rather than overlapping it. */
@media (max-width: 880px) {
    .pos-layout { flex-direction: column; }
    .pos-right {
        width: 100%;
        position: static;
        top: auto;
    }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .public-shell { padding: 16px 14px 40px; }
    .public-topbar h1 { font-size: 19px; }
}
