/* Dairy POS — application styles (Bootstrap 5 based, brand-neutral for white-labelling) */
[hidden] { display: none !important; }
:root {
    --app-primary: #0d6efd;
    --app-sidebar-bg: #0f1b2d;
    --app-sidebar-fg: #c6d0de;
    --app-sidebar-active: #ffffff;
    --app-sidebar-width: 248px;
    --app-topbar-height: 60px;
    --app-body-bg: #f4f6f9;
}

body.app-body { background: var(--app-body-bg); }
.min-w-0 { min-width: 0; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--app-sidebar-width); background: var(--app-sidebar-bg); color: var(--app-sidebar-fg);
    position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040;
    transition: transform .2s ease;
}
.app-main { flex: 1; margin-left: var(--app-sidebar-width); min-width: 0; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: .6rem; height: var(--app-topbar-height); padding: 0 1rem; color: #fff; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: var(--app-primary); color: #fff; flex: none; }
.brand-mark-lg { width: 52px; height: 52px; font-size: 1.5rem; border-radius: 14px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }
.sidebar-nav .nav-heading { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; opacity: .55; margin: 1rem .6rem .35rem; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--app-sidebar-fg); padding: .55rem .7rem; border-radius: 8px; font-size: .925rem; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--app-primary); color: var(--app-sidebar-active); }
.sidebar-nav .nav-link.locked { opacity: .65; }
.sidebar-nav .nav-link .bi:first-child { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar-footer { padding: .75rem 1rem; opacity: .5; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-backdrop { display: none; }

.app-topbar { height: var(--app-topbar-height); background: #fff; border-bottom: 1px solid #e5e8ee; display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 1020; }
.page-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.app-content { padding: 1.25rem; flex: 1; }
.btn-icon { padding: .25rem .4rem; line-height: 1; }

.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: #e7efff; color: var(--app-primary); font-size: .75rem; font-weight: 600; flex: none; }

/* ---------- cards / stats ---------- */
.card { border: 1px solid #e5e8ee; border-radius: 12px; }
.card-header:first-child { border-radius: 12px 12px 0 0; }
.card-footer:last-child { border-radius: 0 0 12px 12px; }
.stat-card { transition: box-shadow .15s ease; color: inherit; }
a.stat-card:hover { box-shadow: 0 4px 14px rgba(15,27,45,.08); }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; }
.stat-value { font-size: 1.75rem; font-weight: 600; line-height: 1.2; margin-top: .25rem; }
.stat-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: #f0f4fa; font-size: 1.1rem; flex: none; }

.empty-state .empty-icon { display: inline-flex; width: 56px; height: 56px; border-radius: 50%; background: #f0f4fa; align-items: center; justify-content: center; font-size: 1.5rem; color: #6c7a91; }
.role-option { cursor: pointer; }
.role-option:has(input:checked) { border-color: var(--app-primary) !important; background: #f3f7ff; }
.table > :not(caption) > * > * { padding-top: .65rem; padding-bottom: .65rem; }

/* ---------- auth ---------- */
body.auth-body { background: linear-gradient(135deg, #eef3fb 0%, #f7f9fc 100%); min-height: 100vh; }
.auth-wrapper { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 420px; border-radius: 16px; }

/* ---------- responsive: off-canvas sidebar ---------- */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0; }
    body.sidebar-open .app-sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.25); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,27,45,.45); z-index: 1030; }
    .app-content { padding: .9rem; }
    .app-topbar { padding: 0 .75rem; }
}
@media (max-width: 575.98px) {
    .stat-value { font-size: 1.4rem; }
    .form-control, .form-select { font-size: 16px; } /* avoids zoom-on-focus on mobile */
}
@media print {
    .app-sidebar, .app-topbar { display: none !important; }
    .app-main { margin: 0; }
}

/* =====================================================================
   POS screen (Phase 2)
   ===================================================================== */
body.pos-mode .app-content { padding: .75rem; }
.pos-shell { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: .75rem; height: calc(100vh - var(--app-topbar-height) - 1.5rem); }
.pos-catalog, .pos-cart { background: #fff; border: 1px solid #e5e8ee; border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
.pos-search { position: relative; padding: .75rem .75rem .5rem; }
.pos-search .bi { position: absolute; left: 1.6rem; top: 50%; transform: translateY(-35%); color: #6c757d; font-size: 1.2rem; }
.pos-search input { padding-left: 2.6rem; }
.pos-categories { display: flex; gap: .4rem; overflow-x: auto; padding: 0 .75rem .6rem; flex: none; scrollbar-width: thin; }
.pos-categories .btn { white-space: nowrap; border-radius: 999px; padding: .35rem .9rem; }
.pos-products { flex: 1; overflow-y: auto; padding: .75rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; align-content: start; border-top: 1px solid #eef0f4; }
.pos-product { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; text-align: left; border: 1px solid #e5e8ee; border-radius: 10px; background: #fff; padding: .6rem; min-height: 120px; transition: border-color .1s, box-shadow .1s; }
.pos-product:hover, .pos-product:focus { border-color: var(--app-primary); box-shadow: 0 2px 8px rgba(13,110,253,.12); outline: none; }
.pos-product:active { transform: scale(.98); }
.pos-product.out { opacity: .55; }
.pos-product img, .pos-product-initial { width: 100%; height: 56px; object-fit: cover; border-radius: 6px; background: #f0f4fa; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: #6c7a91; font-weight: 600; }
.pos-product-name { font-weight: 600; font-size: .9rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pos-product-price { color: var(--app-primary); font-weight: 600; font-size: .9rem; }
.pos-product-stock { font-size: .75rem; color: #6c757d; }

.pos-cart-header { display: flex; gap: .5rem; padding: .75rem; border-bottom: 1px solid #eef0f4; }
.pos-cart-header .btn-light { border: 1px solid #e5e8ee; line-height: 1.2; }
.pos-lines { flex: 1; overflow-y: auto; }
.pos-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .5rem; padding: .55rem .75rem; border-bottom: 1px solid #f1f3f6; }
.pos-line-main { border: 0; background: none; text-align: left; padding: 0; min-width: 0; }
.pos-line-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-line-meta { display: block; font-size: .8rem; color: #6c757d; }
.pos-line-qty { display: flex; align-items: center; }
.pos-line-qty .btn { width: 36px; height: 36px; padding: 0; font-size: 1.1rem; }
.pos-line-qty input { width: 58px; height: 36px; padding: .2rem; border-radius: 0; }
.pos-line-total { font-weight: 600; min-width: 84px; text-align: right; }
.pos-totals { padding: .75rem; border-top: 1px solid #eef0f4; background: #fafbfd; border-radius: 0 0 12px 12px; }
.pos-total { font-size: 1.5rem; font-weight: 700; margin-top: .25rem; }
.pos-pay { font-weight: 600; }
.pay-row { display: flex; gap: .5rem; align-items: center; }
.pay-row-method { min-width: 90px; font-weight: 600; }
.pay-method { min-width: 90px; }
.pos-mobile-bar { display: none; }

@media (max-width: 991.98px) {
    .pos-shell { grid-template-columns: 1fr; height: auto; padding-bottom: 76px; }
    .pos-catalog { min-height: calc(100vh - var(--app-topbar-height) - 100px); }
    .pos-products { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .pos-cart { position: fixed; inset: 0; z-index: 1045; border-radius: 0; transform: translateY(100%); transition: transform .2s ease; }
    body.pos-cart-open .pos-cart { transform: translateY(0); }
    .pos-totals { border-radius: 0; }
    .pos-mobile-bar { display: flex; position: fixed; left: .5rem; right: .5rem; bottom: .5rem; z-index: 1035; justify-content: space-between; align-items: center;
        gap: .5rem; padding: .9rem 1rem; border: 0; border-radius: 12px; background: var(--app-primary); color: #fff; font-size: 1rem; box-shadow: 0 6px 20px rgba(13,110,253,.35); }
    .pos-mobile-bar.pulse { transform: scale(1.03); }
    .pos-line { grid-template-columns: minmax(0, 1fr) auto; }
    .pos-line-total { grid-column: 2; grid-row: 1; }
    .pos-line-qty { grid-column: 1 / -1; justify-content: flex-start; }
    .pos-line-qty .btn, .pos-line-qty input { height: 44px; }
    .pos-line-qty .btn { width: 48px; }
}

/* =====================================================================
   Receipts & statements (print)
   ===================================================================== */
body.receipt-body { background: #e9ecef; }
.receipt { background: #fff; margin: 1rem auto; padding: 1rem; color: #000; font-size: 13px; }
.receipt.thermal { width: 80mm; font-family: "Courier New", ui-monospace, monospace; font-size: 12px; }
.receipt.a4 { width: 210mm; max-width: 100%; padding: 15mm; font-size: 13px; }
.receipt h1 { font-size: 1.15rem; margin: 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt th, .receipt td { padding: 2px 0; vertical-align: top; }
.receipt.a4 th, .receipt.a4 td { padding: 4px 6px; border-bottom: 1px solid #ddd; }
.receipt .rule { border-top: 1px dashed #000; margin: 6px 0; }
.receipt .num { text-align: right; white-space: nowrap; }
.receipt .grand { font-size: 1.15em; font-weight: 700; }
.receipt-logo { max-height: 60px; max-width: 160px; }
.receipt-actions { text-align: center; margin: 1rem; }
@media print {
    @page { margin: 6mm; }
    body.receipt-body { background: #fff; }
    .receipt-actions, .no-print { display: none !important; }
    .receipt { margin: 0; padding: 0; box-shadow: none; }
    .receipt.thermal { width: 72mm; }
    .receipt.a4 { width: auto; padding: 0; }
    .app-sidebar, .app-topbar, .alert, .btn, form, .pagination { display: none !important; }
    .app-content { padding: 0 !important; }
    .card { border: 0 !important; }
}
