/* SmartPOS - responsive point of sale */
:root {
    --pos-bar: #1f2937;
    --pos-bg: #f3f4f6;
    --pos-card: #ffffff;
    --pos-border: #e5e7eb;
    --pos-accent: #0d6efd;
    --st-available: #198754;
    --st-occupied: #dc3545;
    --st-reserved: #fd7e14;
    --st-cleaning: #6c757d;
    --pos-font: "Noto Sans", "Noto Sans Lao", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-font-sans-serif: var(--pos-font);
    --bs-body-font-family: var(--pos-font);
}

body {
    font-family: var(--pos-font);
    background: var(--pos-bg);
}

/* ---------------- Sign in ---------------- */
.auth-page .auth-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.auth-card { width: 100%; max-width: 400px; border: 0; border-radius: 1rem; }
.auth-logo {
    width: 64px; height: 64px; margin: 0 auto 12px;
    display: grid; place-items: center;
    border-radius: 50%; background: var(--pos-bar); color: #fff; font-size: 28px;
}

/* ---------------- App frame ---------------- */
.pos-app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.pos-topbar { background: var(--pos-bar); flex: 0 0 auto; position: sticky; top: 0; z-index: 1030; flex-wrap: nowrap; }
.pos-topbar .navbar-brand { font-weight: 600; font-size: 1.05rem; }
.pos-body { flex: 1 1 auto; min-height: 0; }

/* ---------------- Menu ---------------- */
.pos-menu { padding: 12px 12px 96px; }
.pos-menu-tools {
    position: sticky; top: 56px; z-index: 5;
    background: var(--pos-bg);
    padding-bottom: 8px; margin-bottom: 4px;
}
.pos-cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.pos-cats .btn { white-space: nowrap; flex: 0 0 auto; border-radius: 999px; }

.menu-card {
    position: relative;
    width: 100%; height: 100%; min-height: 128px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 12px;
    text-align: left;
    background: var(--pos-card);
    border: 1px solid var(--pos-border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease;
    touch-action: manipulation;
    -webkit-user-select: none; user-select: none;
}
.menu-card:hover { border-color: var(--pos-accent); box-shadow: 0 4px 12px rgba(13, 110, 253, .12); }
.menu-card:active { transform: scale(.97); }
.menu-card.is-added { animation: pos-pulse .35s ease; }
.menu-card.is-soldout { opacity: .5; cursor: not-allowed; }
.menu-card-icon {
    width: 34px; height: 34px; display: grid; place-items: center;
    border-radius: 8px; background: #eef2ff; color: #4338ca; font-size: 18px;
}
.menu-card-name { font-weight: 600; line-height: 1.2; }
.menu-card-desc {
    font-size: .75rem; color: #6b7280; line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.menu-card-price { margin-top: auto; font-weight: 700; color: #111827; }
.menu-card-badge { position: absolute; top: 10px; right: 10px; }
.menu-card-qty { position: absolute; top: 8px; right: 8px; font-size: .8rem; min-width: 24px; }

@keyframes pos-pulse {
    0% { box-shadow: 0 0 0 0 rgba(13, 110, 253, .5); }
    100% { box-shadow: 0 0 0 12px rgba(13, 110, 253, 0); }
}

/* ---------------- Cart ---------------- */
.pos-cart-body { display: flex; flex-direction: column; padding: 0; min-height: 0; }
.pos-cart-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--pos-border);
}
.pos-cart-items { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.pos-cart-items .list-group-item { padding: 10px 16px; }
.pos-cart-empty { flex: 1 1 auto; padding: 48px 16px; }
.cart-line { display: flex; gap: 10px; align-items: center; }
.cart-line-main { flex: 1 1 auto; min-width: 0; }
.cart-line-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line-note { font-size: .75rem; color: #b45309; }
.cart-line-total { font-weight: 600; white-space: nowrap; }
.qty-ctrl { display: inline-flex; align-items: center; gap: 2px; }
.qty-ctrl .btn { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
.qty-ctrl .qty { min-width: 28px; text-align: center; font-weight: 600; }
.pos-cart-foot { border-top: 1px solid var(--pos-border); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--pos-card); }
.pos-totals { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin-bottom: 12px; }
.pos-totals dt { font-weight: 400; color: #6b7280; }
.pos-totals dd { margin: 0; text-align: right; }
.pos-totals .pos-grand { font-size: 1.25rem; font-weight: 700; color: #111827; padding-top: 4px; }

/* Mobile floating button */
.pos-fab {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 1020;
    border-radius: 999px; padding: 12px 22px; font-weight: 600;
    box-shadow: 0 8px 24px rgba(13, 110, 253, .35);
    white-space: nowrap;
}

/* Phone: cart is an offcanvas drawer */
@media (max-width: 767.98px) {
    .pos-cart.offcanvas-md { width: min(420px, 100vw); }
    .pos-cart .pos-cart-head .js-ctx-title { font-size: .95rem; }
}

/* Tablet / desktop: fixed-height split screen */
@media (min-width: 768px) {
    body.pos-page { overflow: hidden; }
    .pos-app { height: 100vh; height: 100dvh; }
    .pos-body { overflow: hidden; }
    .pos-menu { height: 100%; overflow-y: auto; padding-bottom: 16px; }
    .pos-menu-tools { top: 0; }
    .pos-cart-col { height: 100%; border-left: 1px solid var(--pos-border); background: var(--pos-card); }
    .pos-cart.offcanvas-md { height: 100%; display: flex; flex-direction: column; }
    .pos-cart.offcanvas-md .pos-cart-body { display: flex; flex-direction: column; flex: 1 1 auto; overflow: hidden; padding: 0; }
}

/* ---------------- Tables modal ---------------- */
.pos-legend .dot, .table-tile .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.st-available { background: var(--st-available); }
.st-occupied { background: var(--st-occupied); }
.st-reserved { background: var(--st-reserved); }
.st-cleaning { background: var(--st-cleaning); }

.table-zone { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; margin: 12px 0 6px; }
.table-zone:first-child { margin-top: 0; }
.table-tile {
    width: 100%; height: 100%; min-height: 96px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 10px; text-align: left;
    background: #fff; border: 2px solid var(--pos-border); border-left-width: 6px; border-radius: 10px;
}
.table-tile.is-available { border-left-color: var(--st-available); }
.table-tile.is-occupied { border-left-color: var(--st-occupied); background: #fff5f5; }
.table-tile.is-reserved { border-left-color: var(--st-reserved); }
.table-tile.is-cleaning { border-left-color: var(--st-cleaning); background: #f8f9fa; }
.table-tile.is-current { border-color: var(--pos-accent); }
.table-tile-label { font-size: 1.15rem; font-weight: 700; }
.table-tile-meta { font-size: .8rem; color: #6b7280; }

/* Hidden frame used for 80mm browser printing */
.pos-print-frame { position: absolute; width: 0; height: 0; border: 0; left: -9999px; top: 0; }

.menu-card-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #f3f4f6; }

/* ---------------- Navigation ---------------- */
.app-sidebar { --bs-offcanvas-width: 260px; background: var(--pos-bar); color: #e5e7eb; }
.app-sidebar .offcanvas-body { display: flex; flex-direction: column; padding: 12px; }
.app-sidebar .nav-link {
    display: flex; align-items: center; gap: 10px;
    color: #d1d5db; border-radius: 8px; padding: 9px 12px; margin-bottom: 2px;
}
.app-sidebar .nav-link .bi { font-size: 1.1rem; width: 20px; text-align: center; }
.app-sidebar .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.app-sidebar .nav-link.active { background: var(--pos-accent); color: #fff; }
.app-nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #9ca3af; margin: 16px 12px 6px; }
.app-nav-user {
    margin-top: auto; padding: 12px; border-top: 1px solid rgba(255, 255, 255, .1);
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

/* ---------------- Back-office shell ---------------- */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.app-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--pos-border);
}
.app-main { padding: 16px; flex: 1 1 auto; }
@media (min-width: 992px) {
    .app-shell > .app-sidebar.offcanvas-lg {
        width: 260px; flex: 0 0 260px;
        position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
        background: var(--pos-bar) !important;
    }
    .app-shell > .app-sidebar.offcanvas-lg .offcanvas-body { padding: 16px 12px; height: 100%; }
    .app-main { padding: 24px; }
}
.card-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.table > :not(caption) > * > * { vertical-align: middle; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #f3f4f6; display: inline-grid; place-items: center; color: #9ca3af; }
.form-switch .form-check-input { cursor: pointer; }

/* ---------------- Kitchen display ---------------- */
body.kds-page { background: #111827; color: #f9fafb; }
.kds-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.kds-zones .btn { border-radius: 999px; }
.kds-board { padding: 12px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-items: start; }
.kds-ticket { background: #1f2937; border-radius: 12px; overflow: hidden; border-top: 6px solid #6b7280; }
.kds-ticket.age-ok { border-top-color: #22c55e; }
.kds-ticket.age-warn { border-top-color: #f59e0b; }
.kds-ticket.age-late { border-top-color: #ef4444; animation: kds-blink 1.5s ease-in-out infinite; }
.kds-ticket.is-new { box-shadow: 0 0 0 3px #60a5fa; }
.kds-ticket-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px; background: rgba(255, 255, 255, .04); }
.kds-ticket-where { font-size: 1.3rem; font-weight: 700; }
.kds-ticket-meta { font-size: .8rem; color: #9ca3af; }
.kds-line { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-top: 1px solid rgba(255, 255, 255, .06); cursor: pointer; user-select: none; }
.kds-line:hover { background: rgba(255, 255, 255, .04); }
.kds-qty { font-size: 1.2rem; font-weight: 700; min-width: 36px; }
.kds-name { flex: 1 1 auto; font-weight: 600; }
.kds-note { display: block; font-weight: 400; font-size: .85rem; color: #fbbf24; }
.kds-line.st-preparing .kds-name { color: #93c5fd; }
.kds-line.st-ready .kds-name { color: #86efac; text-decoration: line-through; }
.kds-ticket-foot { padding: 10px 12px; display: flex; gap: 8px; }
.kds-empty { grid-column: 1 / -1; text-align: center; color: #6b7280; padding: 80px 16px; }
@keyframes kds-blink { 50% { border-top-color: #7f1d1d; } }

/* ---------------- Reports ---------------- */
.kpi { background: #fff; border: 1px solid var(--pos-border); border-radius: 12px; padding: 14px 16px; height: 100%; }
.kpi-label { font-size: .8rem; color: #6b7280; }
.kpi-value { font-size: 1.4rem; font-weight: 700; }
.bar { height: 8px; border-radius: 4px; background: #e5e7eb; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--pos-accent); border-radius: 4px; }
.hour-chart { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.hour-chart .col-bar { flex: 1 1 0; background: var(--pos-accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.hour-labels { display: flex; gap: 3px; font-size: .65rem; color: #6b7280; }
.hour-labels span { flex: 1 1 0; text-align: center; }

@media print {
    .app-sidebar, .app-topbar, .no-print { display: none !important; }
    .app-main { padding: 0; }
}

/* ---------------- Language ---------------- */
body.lang-lao { font-family: "Noto Sans Lao", "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.6; }
.app-nav-lang { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .1); }
.app-nav-lang + .app-nav-user { margin-top: 0; }
.lang-switch .btn { min-width: 44px; }
.auth-lang { position: absolute; top: 16px; right: 16px; }

/* ---------------- Back office: documents & financial statements (erp) ---------------- */
.fin-table td, .fin-table th { border-color: #f1f3f5; }
.fin-table .fin-head th { padding-top: 14px; text-transform: uppercase; font-size: .75rem; letter-spacing: .05em; color: #6b7280; border-bottom: 1px solid var(--pos-border); }
.fin-table .fin-total td { font-weight: 600; border-top: 1px solid #d1d5db; }
.fin-table .fin-grand td { font-weight: 700; font-size: 1.05rem; border-top: 2px solid #111827; border-bottom: 3px double #111827; }
.js-lines .table td { padding-top: 4px; padding-bottom: 4px; }
@media print {
    .doc-sheet { border: 0 !important; box-shadow: none !important; max-width: none !important; }
    .doc-sheet .card-body { padding: 0 !important; }
    .app-main a { color: inherit; text-decoration: none; }
}

/* ---------------- Minimart checkout (erp) ---------------- */
.mart-body { background: var(--pos-card); }
.mart-scan { position: relative; border-bottom: 1px solid var(--pos-border); background: var(--pos-bg); }
.mart-scan #martScan { font-size: 1.25rem; letter-spacing: .02em; }
.mart-results { position: absolute; left: 16px; right: 16px; z-index: 30; max-height: 50vh; overflow-y: auto; }
.mart-lines { overflow-y: auto; min-height: 0; }
.mart-lines tr.mart-last > td { background: #e7f1ff; }
.mart-side { background: var(--pos-bg); border-left: 1px solid var(--pos-border); min-height: 0; }
.mart-total { font-size: 2.6rem; font-weight: 800; text-align: right; line-height: 1.1; margin: 8px 0 14px; color: #111827; }
.mart-quick { overflow-y: auto; min-height: 0; }
.mart-quick-btn {
    width: 100%; min-height: 64px; display: flex; flex-direction: column; justify-content: center; gap: 2px;
    padding: 8px 10px; text-align: left; background: #fff; border: 1px solid var(--pos-border); border-radius: 10px;
}
.mart-quick-btn:hover { border-color: var(--pos-accent); }
.mart-quick-btn:disabled { opacity: .45; }
.mart-cats .btn { border-radius: 999px; }
.mart-app kbd { font-size: .7rem; }
@media (min-width: 992px) {
    .mart-page { overflow: hidden; }
    .mart-app { height: 100vh; height: 100dvh; }
    .mart-body { overflow: hidden; }
    .mart-main, .mart-side { height: 100%; }
}
.pay-total-box { background: var(--pos-bg); border-radius: 12px; padding: 12px 16px; }
.pay-methods .btn { border-radius: 10px; }
.pay-customer-results { z-index: 20; max-height: 240px; overflow-y: auto; }
.receipt-logo { display: block; margin: 0 auto 6px; max-width: 70%; max-height: 120px; }

/* ---------------- Bill designer (erp) ---------------- */
.bd-preview-card { position: sticky; top: 76px; }
.bd-preview-body { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 10px, #eceef1 10px, #eceef1 20px); max-height: calc(100vh - 160px); overflow: auto; }
#bdFrame { display: block; width: 100%; max-width: 340px; min-height: 520px; margin: 0 auto; border: 0; background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .15); }
#bdFrame.is-58 { max-width: 250px; }
#ktFrame { display: block; width: 100%; max-width: 340px; min-height: 520px; margin: 0 auto; border: 0; background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .15); }
#ktFrame.is-58 { max-width: 250px; }

/* Toppings / options under an item (POS cart, kitchen display) */
.cart-line-opts { color: var(--bs-primary-text-emphasis); line-height: 1.25; }
.kds-opts { display: block; font-weight: 600; font-size: .9rem; color: #7dd3fc; }

/* User manual (Help) */
.manual { line-height: 1.65; }
.manual h2 { font-size: 1.25rem; margin-top: 1.75rem; }
.manual h3 { font-size: 1.05rem; margin-top: 1.25rem; }
.manual ol, .manual ul { padding-left: 1.4rem; }
.manual li { margin-bottom: .25rem; }
.manual code { background: var(--bs-tertiary-bg); color: inherit; padding: .05rem .3rem; border-radius: .25rem; }
.manual-card:hover { border-color: var(--bs-primary); }
