/* =========================================================
   POSLINE-style theme (light, blue accent, soft cards).
   Bootstrap 5.1 is the base; this file overrides its look.
   ========================================================= */
:root {
    --pl-primary: #4d7cf0;
    --pl-primary-600: #3a68dc;
    --pl-primary-50: #eef3fe;
    --pl-bg: #f4f5f7;
    --pl-surface: #ffffff;
    --pl-border: #e7e9ee;
    --pl-border-soft: #f0f1f4;
    --pl-text: #1f2633;
    --pl-text-2: #4b5363;
    --pl-muted: #6b7280;
    --pl-success: #16a34a;
    --pl-success-50: #e9f8ef;
    --pl-danger: #dc2626;
    --pl-danger-50: #fdecec;
    --pl-warning: #c2410c;
    --pl-warning-50: #fff1e6;
    --pl-teal: #16a394;
    --pl-orange: #e8890c;
    --pl-radius: 14px;
    --pl-radius-sm: 10px;
    --pl-sidebar: 264px;
    --pl-topbar: 68px;
    --pl-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

html { font-size: 15px; }
body {
    background: var(--pl-bg);
    color: var(--pl-text);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--pl-primary); }
a:hover { color: var(--pl-primary-600); }
.min-w-0 { min-width: 0; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.text-muted { color: var(--pl-muted) !important; }
.icon { flex-shrink: 0; vertical-align: -0.2em; }

/* ---------- Bootstrap overrides ---------- */
.btn { border-radius: var(--pl-radius-sm); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary { background: var(--pl-primary); border-color: var(--pl-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--pl-primary-600); border-color: var(--pl-primary-600); }
.btn-primary:disabled { background: var(--pl-primary); border-color: var(--pl-primary); opacity: .45; }
.btn-outline-primary { color: var(--pl-primary); border-color: var(--pl-primary); }
.btn-outline-primary:hover { background: var(--pl-primary); border-color: var(--pl-primary); }
.btn-light { background: var(--pl-surface); border-color: var(--pl-border); color: var(--pl-text-2); }
.btn-light:hover { background: var(--pl-bg); border-color: var(--pl-border); }
.btn-soft { background: var(--pl-primary-50); color: var(--pl-primary); border: 0; }
.btn-soft:hover { background: #dfe8fd; color: var(--pl-primary-600); }
.form-control, .form-select { border-radius: var(--pl-radius-sm); border-color: var(--pl-border); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--pl-primary); box-shadow: 0 0 0 3px rgba(77, 124, 240, .18); }
.form-check-input:checked { background-color: var(--pl-primary); border-color: var(--pl-primary); }
.form-label { font-weight: 500; color: var(--pl-text-2); margin-bottom: 4px; }
.alert { border-radius: var(--pl-radius-sm); border: 0; }
.modal-content { border: 0; border-radius: var(--pl-radius); }
.modal-header, .modal-footer { border-color: var(--pl-border-soft); }
.badge { font-weight: 600; border-radius: 6px; }
code { color: var(--pl-text-2); }

/* Soft status pills */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pill-success { background: var(--pl-success-50); color: var(--pl-success); }
.pill-danger { background: var(--pl-danger-50); color: var(--pl-danger); }
.pill-warning { background: var(--pl-warning-50); color: var(--pl-warning); }
.pill-primary { background: var(--pl-primary-50); color: var(--pl-primary-600); }
.pill-muted { background: var(--pl-border-soft); color: var(--pl-muted); }

/* ---------- App shell ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--pl-sidebar); z-index: 1040;
    background: var(--pl-surface); border-right: 1px solid var(--pl-border);
    display: flex; flex-direction: column; padding: 0 14px 14px; overflow-y: auto;
    transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 12px; height: var(--pl-topbar); margin: 0 -14px 14px; padding: 0 8px 0 22px; border-bottom: 1px solid var(--pl-border); text-decoration: none; color: var(--pl-text); flex-shrink: 0; }
.brand:hover { color: var(--pl-text); }
.brand-mark { width: 36px; height: 36px; color: var(--pl-primary); flex-shrink: 0; }
.brand-name { display: block; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; line-height: 1.15; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-tag { display: block; font-size: .8rem; color: var(--pl-muted); }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-heading { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pl-muted); padding: 18px 12px 6px; border-top: 1px solid var(--pl-border-soft); margin-top: 10px; }
.side-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--pl-radius-sm);
    color: var(--pl-text-2); text-decoration: none; font-weight: 500; background: none; border: 0; text-align: left;
}
.side-link:hover { background: var(--pl-bg); color: var(--pl-text); }
.side-link.active { background: var(--pl-primary); color: #fff; box-shadow: 0 4px 12px rgba(77, 124, 240, .28); }
.side-link .icon { width: 20px; height: 20px; }

.side-user { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--pl-border); border-radius: var(--pl-radius-sm); margin-top: 16px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--pl-primary-50); color: var(--pl-primary); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.side-user-name { font-weight: 600; font-size: .9rem; }
.side-user-role { font-size: .78rem; color: var(--pl-muted); }
.side-actions { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.side-actions .side-link { padding: 8px 14px; font-size: .9rem; }

.app-main { margin-left: var(--pl-sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; height: var(--pl-topbar);
    display: flex; align-items: center; gap: 14px; padding: 0 28px;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--pl-border);
}
.page-title { font-size: 1.45rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.topbar-date { color: var(--pl-muted); font-size: .9rem; white-space: nowrap; }
.btn-icon { border: 1px solid var(--pl-border); background: var(--pl-surface); border-radius: var(--pl-radius-sm); width: 40px; height: 40px; display: grid; place-items: center; color: var(--pl-text-2); }
.content { padding: 24px 28px 32px; flex: 1; }

.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
    .sidebar-open .sidebar { transform: none; }
    .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 1030; }
    .app-main { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .content { padding: 16px; }
}

/* ---------- Section headings ("Monitoring / You can see your performance here") ---------- */
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.section-title { font-size: 1.2rem; font-weight: 700; margin: 0; }
.section-sub { color: var(--pl-muted); margin: 2px 0 0; }

/* ---------- Cards ---------- */
.pl-card { background: var(--pl-surface); border: 1px solid var(--pl-border); border-radius: var(--pl-radius); box-shadow: var(--pl-shadow); }
.pl-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--pl-border-soft); }
.pl-card-title { font-weight: 600; margin: 0; font-size: 1rem; }
.pl-card-body { padding: 20px; }

.stat-card { display: flex; flex-direction: column; }
.stat-body { padding: 18px 20px; flex: 1; }
.stat-title { color: var(--pl-text-2); font-weight: 500; }
.stat-value { font-size: 1.85rem; font-weight: 700; margin: 6px 0 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-trend { display: flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 500; }
.stat-trend.good { color: var(--pl-success); }
.stat-trend.bad { color: var(--pl-danger); }
.stat-note { font-size: .88rem; color: var(--pl-muted); }
.stat-link { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-top: 1px solid var(--pl-border-soft); font-weight: 600; text-decoration: none; font-size: .92rem; }
.stat-link:hover { background: var(--pl-primary-50); border-radius: 0 0 var(--pl-radius) var(--pl-radius); }

.icon-chip { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.tone-primary { background: var(--pl-primary-50); color: var(--pl-primary); }
.tone-success { background: var(--pl-success-50); color: var(--pl-success); }
.tone-warning { background: var(--pl-warning-50); color: var(--pl-warning); }
.tone-danger { background: var(--pl-danger-50); color: var(--pl-danger); }

/* ---------- Tables ---------- */
.pl-table { margin: 0; --bs-table-hover-bg: #f8f9fb; }
.pl-table > :not(caption) > * > * { padding: 12px 16px; border-bottom-color: var(--pl-border-soft); }
.pl-table thead th { background: #fafbfc; color: var(--pl-muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--pl-border); white-space: nowrap; }
.pl-table tfoot td { font-weight: 700; border-top: 1px solid var(--pl-border); border-bottom: 0; }
.pl-table tbody tr:last-child td { border-bottom: 0; }
.pl-table .num { white-space: nowrap; }
.pl-table .empty { text-align: center; color: var(--pl-muted); padding: 32px 16px; }
.table-link { text-decoration: none; font-weight: 600; }

/* ---------- Donut (revenue by payment method) ---------- */
.donut-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; flex-shrink: 0; }
.donut-center { font-variant-numeric: tabular-nums; }
.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 170px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 4px 10px; align-items: center; }
.legend .swatch { width: 10px; height: 10px; border-radius: 50%; }
.legend .lbl { color: var(--pl-text-2); }
.legend .val { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.legend .sub { grid-column: 2 / 4; font-size: .8rem; color: var(--pl-muted); margin-top: -4px; }
.sw-cash { background: var(--pl-primary); }
.sw-card { background: var(--pl-teal); }
.sw-account { background: var(--pl-orange); }
.seg { transition: opacity .15s; }
.donut:hover .seg { opacity: .55; }
.donut .seg:hover { opacity: 1; }

/* Progress-style revenue rows */
.rev-row + .rev-row { border-top: 1px solid var(--pl-border-soft); }
.rev-row { padding: 14px 0; }
.rev-row .amt { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--pl-border-soft); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--pl-primary); }

/* Lists (top debtors, low stock) */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; text-decoration: none; color: var(--pl-text); }
.list-row + .list-row { border-top: 1px solid var(--pl-border-soft); }
a.list-row:hover { background: #f8f9fb; color: var(--pl-text); }
.list-row .amt { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Sign-in ---------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--pl-bg); }
.auth-wrap { width: 100%; padding: 16px; display: flex; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand-mark { width: 44px; height: 44px; }

/* ---------- Till ---------- */
.till { display: grid; grid-template-columns: 1fr 420px; gap: 20px; height: calc(100vh - var(--pl-topbar) - 48px); }
.till-products, .till-cart { min-height: 0; display: flex; flex-direction: column; }
/* Let the product column shrink (wide rows such as Popular scroll inside it) so the order panel always fits */
.till-products, .till-cart { min-width: 0; }
.till-search { position: relative; margin-bottom: 12px; }
.till-search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--pl-muted); pointer-events: none; }
.till-search input { padding-left: 44px; height: 50px; background: var(--pl-surface); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { border: 1px solid var(--pl-border); background: var(--pl-surface); color: var(--pl-text-2); border-radius: 999px; padding: 6px 16px; font-weight: 500; }
.chip:hover { border-color: var(--pl-primary); color: var(--pl-primary); }
.chip.active { background: var(--pl-primary); border-color: var(--pl-primary); color: #fff; }
.till-grid { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; align-content: start; padding-bottom: 8px; }
.product-tile { border: 1px solid var(--pl-border); background: var(--pl-surface); border-radius: var(--pl-radius); padding: 14px; text-align: left; min-height: 104px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; transition: border-color .1s, box-shadow .1s; }
.product-tile:hover { border-color: var(--pl-primary); box-shadow: 0 0 0 3px rgba(77, 124, 240, .15); }
.product-tile:active { transform: scale(.98); }
.product-tile .name { font-weight: 600; line-height: 1.25; color: var(--pl-text); }
.product-tile .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.product-tile .price { color: var(--pl-primary); font-weight: 700; font-variant-numeric: tabular-nums; }
.product-tile .stock { font-size: .75rem; color: var(--pl-muted); }
.product-tile .stock.low { color: var(--pl-danger); font-weight: 600; }

.till-cart .pl-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cart-lines { flex: 1; overflow-y: auto; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--pl-border-soft); }
.cart-line .qty { display: flex; align-items: center; gap: 6px; }
.cart-line .qty button { width: 30px; height: 30px; padding: 0; border-radius: 8px; }
.cart-line .qty span { min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.cart-line .line-total { min-width: 80px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.cart-foot { padding: 16px 20px 20px; border-top: 1px solid var(--pl-border); background: #fafbfc; border-radius: 0 0 var(--pl-radius) var(--pl-radius); }
.cart-total { font-size: 1.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-btn { padding: 12px 6px; font-size: 1rem; font-weight: 600; flex-direction: column; gap: 4px; }
.btn-success { background: var(--pl-success); border-color: var(--pl-success); }
.btn-success:hover, .btn-success:focus { background: #12873d; border-color: #12873d; }
.pay-btn:disabled { opacity: .45; }
.btn-account { background: var(--pl-warning-50); color: var(--pl-warning); border: 1px solid #fbd9bd; }
.btn-account:hover { background: #ffe4cf; color: var(--pl-warning); }
.btn-account:disabled { background: var(--pl-warning-50); color: var(--pl-warning); }

.customer-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--pl-border); border-radius: var(--pl-radius-sm); }
.customer-opt { display: flex; width: 100%; align-items: center; gap: 12px; padding: 10px 14px; border: 0; background: var(--pl-surface); text-align: left; }
.customer-opt + .customer-opt { border-top: 1px solid var(--pl-border-soft); }
.customer-opt:hover { background: #f8f9fb; }
.customer-opt.selected { background: var(--pl-primary-50); }
.customer-opt .amt { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }
.account-summary { background: var(--pl-bg); border-radius: var(--pl-radius-sm); padding: 12px 14px; }
.account-summary .row-line { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }

@media (max-width: 991.98px) {
    .till { grid-template-columns: 1fr; height: auto; }
    .till-grid { max-height: 50vh; }
}

/* ---------- Account statement ---------- */
.balance-hero { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.amt-credit { color: var(--pl-success); }

/* ---------- Receipt (80mm slip printers) ---------- */
.receipt { max-width: 340px; margin: 0 auto; background: #fff; padding: 16px; font-family: "Courier New", monospace; font-size: 13px; border-radius: 6px; color: #000; }
.receipt table { width: 100%; }
.receipt td { padding: 1px 0; vertical-align: top; }
.receipt .r { text-align: right; white-space: nowrap; }
.receipt hr { border-top: 1px dashed #000; opacity: 1; margin: 8px 0; }
/* Slip header like the client's old slips: big order number between double lines, business name in capitals */
.receipt .slip-order { text-align: center; border-top: 3px double #000; border-bottom: 3px double #000; padding: 4px 0 6px; margin-bottom: 10px; font-size: 15px; }
.receipt .slip-order-no { font-size: 30px; font-weight: 700; line-height: 1.1; }
.receipt .slip-name { font-size: 15px; font-weight: 700; }
/* Printer test slip: a box from edge to edge of the printable width; if a side is missing, the slip is too wide */
.receipt .slip-width-box { border: 2px solid #000; text-align: center; padding: 2px 0; margin: 2px 0 4px; }

/* Hidden frame the till prints slips from (print.js): off-screen but rendered at slip width */
.receipt-frame { position: fixed; left: -10000px; top: 0; width: 80mm; height: 200mm; border: 0; }

@media print {
    /* No browser margins = no header/footer (date, URL) on the slip */
    @page { margin: 0; }
    body { background: #fff; }
    .app-main { margin-left: 0; }
    .content { padding: 0 !important; }
    .pl-card { box-shadow: none; }
    /* 80 mm thermal roll (Xprinter XP-K260L / XP-Q200): the print head covers 72 mm (576 dots) */
    .receipt {
        width: 72mm; max-width: 72mm; margin: 0; border-radius: 0;
        padding: 1mm 1mm 8mm;          /* room at the end so the cutter doesn't clip the last line */
        font-size: 12.5px; line-height: 1.3; box-shadow: none !important;
    }
    /* Thermal printers have no grey: everything solid black, kept even when "print backgrounds" is off */
    .receipt, .receipt * { color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .receipt hr { border-top: 1px dashed #000 !important; }
}
