/* ==========================================================================
   PosInnova - industrial treatment of the POS product browser
   Scoped to the facet bar and the product grid. Everything here is additive:
   the classes pos.js binds to are untouched, only how they look changes.
   ========================================================================== */
:root{
    --pi-primary:#4f46e5; --pi-primary-d:#4338ca; --pi-primary-l:#eef0fd;
    --pi-ink:#16222b; --pi-ink-2:#3d4f5b; --pi-muted:#687c89; --pi-faint:#8c9ca7;
    --pi-line:#c9d2d8; --pi-line-2:#dde4e8;
    --pi-surf:#ffffff; --pi-surf-2:#f2f5f6; --pi-surf-3:#e8edef;
    --pi-ok:#15803d; --pi-ok-bg:#e4f2e8;
    --pi-low:#b45309; --pi-low-bg:#fbefdb;
    --pi-out:#b91c1c; --pi-out-bg:#f9e7e6;
}

/* ---- facet bar ---------------------------------------------------------- */
/* No flex `gap` here on purpose. A collapsed panel is 0px tall but still a flex
   item, so a gap put 6px on each side of it - three gaps plus an always-present
   empty chip row left ~41px of dead space above the grid. Spacing now belongs
   to the things that are actually showing (.pi-open panels, a non-empty chip
   row), and the outer margin lives on .pi-browser-head. */
.pi-facets{ display:flex; flex-direction:column; }
.pi-facet-btns{ display:flex; gap:6px; }
.pi-facet-btn{
    flex:1; display:flex; align-items:center; gap:7px; padding:0 10px; height:34px;
    background:var(--pi-primary); border:1px solid var(--pi-primary-d); border-radius:4px;
    color:#fff; font-weight:600; font-size:13px; cursor:pointer; line-height:1;
}
.pi-facet-btn:hover{ background:var(--pi-primary-d); color:#fff; }
.pi-facet-btn:focus{ color:#fff; outline:2px solid var(--pi-primary); outline-offset:1px; }
.pi-facet-btn > span{ text-align:left; }
.pi-facet-btn .pi-cv{ margin-left:auto; transition:transform .16s ease; }
.pi-facet-btn[aria-expanded="true"]{ background:var(--pi-primary-d); box-shadow:inset 0 1px 3px rgba(0,0,0,.3); }
.pi-facet-btn[aria-expanded="true"] .pi-cv{ transform:rotate(180deg); }

.pi-facet-panel{ display:grid; grid-template-rows:0fr; transition:grid-template-rows .18s ease, margin-top .18s ease; }
.pi-facet-panel.pi-open{ grid-template-rows:1fr; margin-top:6px; }
.pi-facet-panel > div{ overflow:hidden; }
.pi-facet-panel-in{ background:var(--pi-surf); border:1px solid var(--pi-line); border-radius:4px; }

.pi-facet-head{
    display:flex; align-items:center; gap:7px; min-height:30px; padding:4px 8px;
    background:var(--pi-surf-2); border-bottom:1px solid var(--pi-line); flex-wrap:wrap;
}
.pi-facet-title{
    font-size:11px; font-weight:700; letter-spacing:.07em; text-transform:uppercase;
    color:var(--pi-muted); white-space:nowrap;
}
.pi-facet-back{
    display:inline-flex; align-items:center; gap:4px; height:22px; padding:0 7px;
    font-size:11.5px; font-weight:600; color:var(--pi-ink-2);
    background:var(--pi-surf); border:1px solid var(--pi-line); border-radius:3px; cursor:pointer;
}
.pi-facet-back:hover{ background:var(--pi-surf-3); }
.pi-facet-find{
    margin-left:auto; display:flex; align-items:center; gap:5px; height:24px; padding:0 7px;
    background:var(--pi-surf); border:1px solid var(--pi-line); border-radius:3px; max-width:180px;
    color:var(--pi-muted);
}
.pi-facet-filter{
    border:0; outline:0; width:100%; min-width:0; font-size:12px; background:none;
    color:var(--pi-ink); height:22px; padding:0;
}
.pi-facet-opts{
    display:flex; flex-wrap:wrap; gap:4px; padding:8px; max-height:190px; overflow-y:auto;
}
.all-sub-category{ display:flex; flex-wrap:wrap; gap:4px; width:100%; }
.pi-opt{
    display:inline-flex; align-items:center; gap:6px; height:26px; padding:0 9px; cursor:pointer;
    background:var(--pi-surf); border:1px solid var(--pi-line); border-radius:3px;
    font-size:12px; font-weight:600; color:var(--pi-ink); line-height:1; white-space:nowrap;
    max-width:100%;
}
.pi-opt > span{ overflow:hidden; text-overflow:ellipsis; }
.pi-opt:hover{ border-color:var(--pi-primary); color:var(--pi-primary); background:var(--pi-primary-l); }
.pi-opt.pi-opt-active{ background:var(--pi-primary); border-color:var(--pi-primary-d); color:#fff; }
.pi-opt[hidden]{ display:none !important; }
.pi-facet-empty{
    margin:8px; padding:9px 10px; background:var(--pi-surf-2);
    border:1px solid var(--pi-line-2); border-radius:3px; color:var(--pi-muted); font-size:12px;
}

/* active filters stay visible after the panel collapses */
.pi-active-row{ display:flex; align-items:center; gap:5px; flex-wrap:wrap; min-height:23px; margin-top:6px; }
/* renderChips() in pos.js calls $row.empty() first, so with no filter active
   the row really has no children and takes no space at all */
.pi-active-row:empty{ display:none; }
.pi-chip{
    display:inline-flex; align-items:center; gap:5px; height:23px; padding:0 4px 0 8px;
    font-size:11.5px; font-weight:600; color:var(--pi-primary-d);
    background:var(--pi-primary-l); border:1px solid #c3c7f5; border-radius:3px;
}
.pi-chip button{
    display:inline-flex; align-items:center; border:0; background:none; padding:0;
    cursor:pointer; color:inherit; opacity:.65;
}
.pi-chip button:hover{ opacity:1; }
.pi-chip-count{ margin-left:auto; font-size:11.5px; color:var(--pi-muted); white-space:nowrap; }

/* ---- product grid ------------------------------------------------------- */
#product_list_body.eq-height-row{
    display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px;
    align-content:start; padding:6px; background:var(--pi-surf-3);
    border:1px solid var(--pi-line); border-radius:4px;
}
#product_list_body .product_list{ width:auto; float:none; padding:0; }
#product_list_body > .col-md-12{ grid-column:1 / -1; }

.product_box.pi-prod{
    display:flex; flex-direction:column; gap:3px; min-height:84px; height:100%;
    margin:0; padding:7px 8px 6px; text-align:left; font-weight:400;
    background:var(--pi-surf); border:1px solid var(--pi-line); border-radius:4px;
    border-left-width:3px; border-left-color:var(--pi-ok);
    color:var(--pi-ink); transition:border-color .12s ease, background .12s ease;
}
.product_box.pi-prod:hover{ border-color:var(--pi-primary); border-left-color:var(--pi-primary); background:#fcfdff; }
.product_box.pi-prod-low{ border-left-color:var(--pi-low); }
.product_box.pi-prod-out{ border-left-color:var(--pi-out); opacity:.62; }
.product_box.pi-prod-out:hover{ border-color:var(--pi-out); border-left-color:var(--pi-out); background:var(--pi-surf); }
.product_box.pi-prod-none{ border-left-color:var(--pi-line); }

.product_box.pi-prod .pi-prod-img{
    height:38px; width:100%; margin:0 0 2px; background-repeat:no-repeat;
    background-position:center; background-size:contain;
}
.product_box.pi-prod .pi-prod-body{ display:flex; flex-direction:column; gap:2px; flex:1; margin:0; }
.pi-prod-name{
    font-weight:600; font-size:12px; line-height:1.25; color:var(--pi-ink);
    display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.pi-prod-sku{
    font-size:10.5px; color:var(--pi-faint); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.pi-prod-foot{
    display:flex; align-items:baseline; justify-content:space-between; gap:5px; margin-top:auto; padding-top:3px;
}
.pi-prod-price{
    font-weight:600; font-size:12.5px; color:var(--pi-ink); font-variant-numeric:tabular-nums;
}
.pi-prod-stock{
    font-size:10px; font-weight:700; padding:1px 5px; border-radius:2px; white-space:nowrap;
    background:var(--pi-ok-bg); color:var(--pi-ok); font-variant-numeric:tabular-nums;
}
.pi-prod-low .pi-prod-stock{ background:var(--pi-low-bg); color:var(--pi-low); }
.pi-prod-out  .pi-prod-stock{ background:var(--pi-out-bg); color:var(--pi-out); }
.pi-prod-none .pi-prod-stock{ background:var(--pi-surf-3); color:var(--pi-muted); }

@media (max-width: 1180px){
    #product_list_body.eq-height-row{ grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (max-width: 767px){
    #product_list_body.eq-height-row{ grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (prefers-reduced-motion: reduce){
    .pi-facet-panel, .pi-facet-btn .pi-cv, .product_box.pi-prod{ transition:none; }
}

/* ==========================================================================
   PosInnova - industrial treatment of the POS header and action bar
   Second scoped pass. Same hues the screen already used, flattened: 4px radii,
   hairline borders, solid fills, uppercase micro-labels, tabular figures.

   One hard rule runs through all of it: NOTHING here sets `display`.
   Bootstrap .hide is display:none !important so it always wins, but
   Tailwind .tw-hidden is a plain rule and this file loads last - a single
   `display` declaration on a shared button class would override
   `tw-hidden md:tw-flex` and show the mobile and desktop copies of the
   action bar at the same time. Visibility stays entirely with the markup.
   ========================================================================== */
:root{
    --pi-navy:#001f3e; --pi-navy-d:#00142a; --pi-navy-l:#032d57;
    --pi-cash:#28b77b; --pi-cash-d:#1f9a66;
    --pi-preview:#2563eb; --pi-preview-d:#1d4ed8;
    --pi-cancel:#dc2626; --pi-cancel-d:#b91c1c;
    --pi-datetime:#4f5bd5; --pi-cashier:#00935f;
    --pi-draft:#f59e0b; --pi-draft-d:#d97706;
}

/* ---- header bar --------------------------------------------------------- */
.pos-header .pi-pos-headbar{
    border-radius:4px; background:var(--pi-surf);
    border:1px solid var(--pi-line); box-shadow:none;
    margin:4px 0 0; padding:6px 8px; gap:7px;
}
.pos-header .pi-location-label{
    margin:0; font-size:11px; font-weight:700; letter-spacing:.07em;
    text-transform:uppercase; color:var(--pi-muted); white-space:nowrap;
}
/* the location picker, when the business has more than one */
.pos-header select#select_location_id.form-control{
    height:30px; padding:0 8px; border-radius:4px; border:1px solid var(--pi-line);
    background:var(--pi-surf-2); box-shadow:none; font-size:13px; font-weight:600;
    color:var(--pi-ink);
}

/* square icon buttons - the whole right-hand shortcut group */
.pos-header .pi-pos-icon-btn{
    width:30px; height:30px; padding:0; line-height:1; border-radius:4px;
    background:var(--pi-surf); border:1px solid var(--pi-line); color:var(--pi-ink-2);
    cursor:pointer; transition:background .12s ease, border-color .12s ease;
}
.pos-header .pi-pos-icon-btn:hover{ background:var(--pi-surf-3); border-color:var(--pi-muted); }
.pos-header .pi-pos-icon-btn:focus-visible{ outline:2px solid var(--pi-primary); outline-offset:1px; }
.pos-header .pi-pos-icon-btn i{ font-size:14px; }

/* labelled header buttons (Add Expense, POS Sale) */
.pos-header .pi-add-expense-btn{
    height:30px; padding:0 10px; gap:6px; border-radius:4px;
    background:var(--pi-surf); border:1px solid var(--pi-line); color:var(--pi-ink);
    font-weight:600; font-size:12px; line-height:1; box-shadow:none;
    transition:background .12s ease, border-color .12s ease;
}
.pos-header .pi-add-expense-btn:hover{
    background:var(--pi-surf-3); border-color:var(--pi-muted); box-shadow:none;
}
.pos-header .pi-add-expense-btn .fa{ color:var(--pi-cancel); }

/* status pills: date/time, cashier, shift, stock doctor, pending drafts */
.pos-header .pi-pos-tag{
    height:30px; padding:0 9px; gap:6px; border-radius:4px;
    font-weight:600; font-size:12px; line-height:1; white-space:nowrap;
    border:1px solid rgba(0,0,0,.14); color:#fff;
}
.pos-header .pi-datetime-pill{ background:var(--pi-datetime); }
.pos-header .pi-cashier-pill{ background:var(--pi-cashier); }
.pos-header .pi-datetime-pill .fa,
.pos-header .pi-cashier-pill .fa{ color:#fff; opacity:.85; }
.pos-header .pi-datetime-pill .curr_datetime{ font-variant-numeric:tabular-nums; }
.pos-header .pi-pos-tag .pi-tag-sub{ font-weight:400; opacity:.9; }

.pos-header .pi-draft-indicator{
    background:var(--pi-draft); border-color:var(--pi-draft-d); color:#fff;
    font-weight:700; cursor:pointer;
    /* the pulse stays: it is the one thing on this bar that must interrupt */
    animation:pi-draft-blink 1.4s ease-in-out infinite;
}
.pos-header .pi-draft-indicator:hover{ animation-play-state:paused; background:var(--pi-draft-d); }
.pos-header .pi-draft-indicator .pi-draft-count{
    background:#fff; color:var(--pi-draft-d); border-radius:3px;
    min-width:17px; height:17px; padding:0 4px; font-size:11px; font-weight:700;
    display:inline-flex; align-items:center; justify-content:center;
    font-variant-numeric:tabular-nums;
}
@keyframes pi-draft-blink{
    0%,100%{ box-shadow:0 0 0 0 rgba(245,158,11,.55); opacity:1; }
    50%    { box-shadow:0 0 0 6px rgba(245,158,11,0);  opacity:.78; }
}
/* hairline divider between the pills and the shortcut group */
.pos-header .pi-sep{ width:1px; height:20px; background:var(--pi-line); margin:0 2px; flex:none; }

/* ---- action bar --------------------------------------------------------- */
.pi-actbar{
    border-radius:4px 4px 0 0; background:var(--pi-surf);
    /* All four sides: the support ticker lifts this bar off the bottom edge of
       the viewport, so its lower border is actually on screen now. */
    border:1px solid var(--pi-line); box-shadow:none;
    /* app.css gives .pos-form-actions padding 12px/20px. That was sized for a
       bar sitting flush against the bottom of the window; now that it is lifted
       the 20px reads as a gap above the ticker, so the padding moves inside to
       .pi-actbar-in where it belongs. */
    padding-top:0; padding-bottom:0;
}
.pi-actbar .pi-actbar-in{ padding:6px 9px; gap:6px; }

/* Shared button shape. No `display` - see the note at the top of this block. */
.pi-act{
    align-items:center; justify-content:center; gap:7px;
    height:34px; padding:0 12px; width:auto; min-width:0; border-radius:4px;
    font-weight:600; font-size:13px; line-height:1; white-space:nowrap; cursor:pointer;
    background:var(--pi-surf); border:1px solid var(--pi-line); color:var(--pi-ink-2);
    transition:background .12s ease, border-color .12s ease;
}
.pi-act:hover{ background:var(--pi-surf-3); border-color:var(--pi-muted); color:var(--pi-ink); }
.pi-act:focus-visible{ outline:2px solid var(--pi-primary); outline-offset:1px; }
.pi-act[disabled]{ opacity:.45; cursor:not-allowed; }
.pi-act[disabled]:hover{ background:var(--pi-surf); border-color:var(--pi-line); }

/* solid variants - the hues the bar already used, flattened */
.pi-act-solid{ color:#fff; }
.pi-act-solid:hover{ color:#fff; }
.pi-act-pay{ background:var(--pi-navy); border-color:var(--pi-navy-d); min-width:132px; }
.pi-act-pay:hover{ background:var(--pi-navy-l); border-color:var(--pi-navy-d); }
.pi-act-cash{ background:var(--pi-cash); border-color:var(--pi-cash-d); min-width:118px; }
.pi-act-cash:hover{ background:var(--pi-cash-d); border-color:var(--pi-cash-d); }
.pi-act-preview{ background:var(--pi-preview); border-color:var(--pi-preview-d); }
.pi-act-preview:hover{ background:var(--pi-preview-d); border-color:var(--pi-preview-d); }
.pi-act-cancel{ background:var(--pi-cancel); border-color:var(--pi-cancel-d); }
.pi-act-cancel:hover{ background:var(--pi-cancel-d); border-color:var(--pi-cancel-d); }
.pi-act-recent{ background:var(--pi-navy); border-color:var(--pi-navy-d); color:#fff; }
.pi-act-recent:hover{ background:var(--pi-navy-l); border-color:var(--pi-navy-d); color:#fff; }

/* keyboard hint chip, rendered from the real shortcut settings of the business */
.pi-act-key{
    font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
    font-size:9.5px; font-weight:600; letter-spacing:.02em; text-transform:uppercase;
    padding:1px 4px; border:1px solid currentColor; border-radius:2px;
    opacity:.55; white-space:nowrap;
}
.pi-act-solid .pi-act-key,
.pi-act-recent .pi-act-key{ border-color:rgba(255,255,255,.6); opacity:.8; }

/* total payable - the one number on the bar that has to carry across a room */
.pi-actbar .pos-total.pi-pay{ padding:0 4px; margin:0; gap:9px; }
.pi-actbar .pi-pay .pi-pay-k{
    font-size:10.5px; font-weight:700; letter-spacing:.07em; text-transform:uppercase;
    color:var(--pi-muted); white-space:nowrap; line-height:1.15; text-align:right;
}
.pi-actbar .pi-pay span#total_payable{
    font-size:22px; font-weight:700; color:var(--pi-ink); line-height:1;
    font-variant-numeric:tabular-nums;
}
.pi-actbar .pi-pay-cur{
    font-size:10.5px; font-weight:700; letter-spacing:.07em; text-transform:uppercase;
    color:var(--pi-muted);
}

@media (max-width: 1280px){
    .pi-act{ padding:0 9px; font-size:12.5px; }
    .pi-act-pay{ min-width:0; }
    .pi-act-cash{ min-width:0; }
    .pi-act-key{ display:none; }
}
/* the phone copy of the bar is cramped, so the figure steps down there */
.pi-actbar .tw-pos-total.pi-pay{ gap:7px; }
.pi-actbar .tw-pos-total.pi-pay span#total_payable{ font-size:16px; }
@media (max-width: 767px){
    .pi-act{ height:32px; padding:0 8px; font-size:12px; gap:5px; }
}
@media (prefers-reduced-motion: reduce){
    .pi-act, .pos-header .pi-pos-icon-btn, .pos-header .pi-add-expense-btn{ transition:none; }
    .pos-header .pi-draft-indicator{ animation:none; }
}

/* ==========================================================================
   PosInnova - collapsible product browser
   body.pi-browser-collapsed is set by sale_pos/partials/pos_browser_toggle
   before the panes are parsed. Collapsed: the right pane is gone and the cart
   pane takes the full width; a "Products" tab on the right edge brings it back.
   ========================================================================== */

/* the row that holds the Category / Brands buttons and the collapse button */
.pi-browser-head{ display:flex; align-items:flex-start; gap:6px; margin-bottom:8px; }
.pi-browser-head > .pi-facets{ flex:1; min-width:0; }

/* collapse - neutral, so it never competes with Category / Brands */
.pi-browser-toggle{
    flex:none; margin-left:auto; width:34px; height:34px; padding:0;
    display:inline-flex; align-items:center; justify-content:center;
    background:var(--pi-surf); border:1px solid var(--pi-line); border-radius:4px;
    color:var(--pi-ink-2); cursor:pointer; transition:background .12s ease, border-color .12s ease;
}
.pi-browser-toggle:hover{ background:var(--pi-surf-3); border-color:var(--pi-muted); color:var(--pi-ink); }
.pi-browser-toggle:focus-visible{ outline:2px solid var(--pi-primary); outline-offset:1px; }

/* expand - a tab on the right edge of the window, only while collapsed */
.pi-browser-expand{
    display:none; position:fixed; right:0; top:50%; transform:translateY(-50%);
    /* under the action bar (1000), the support ticker (1040) and modals (1050) */
    z-index:999;
    flex-direction:column; align-items:center; gap:8px;
    width:30px; padding:12px 0;
    background:var(--pi-primary); border:1px solid var(--pi-primary-d); border-right:0;
    border-radius:4px 0 0 4px; box-shadow:-1px 0 4px rgba(0,0,0,.12);
    color:#fff; font-weight:600; font-size:12px; letter-spacing:.05em; line-height:1; cursor:pointer;
}
.pi-browser-expand:hover{ background:var(--pi-primary-d); }
.pi-browser-expand:focus-visible{ outline:2px solid var(--pi-primary-d); outline-offset:2px; }
.pi-browser-expand span{ writing-mode:vertical-rl; white-space:nowrap; text-transform:uppercase; }

body.pi-browser-collapsed .pi-browser-expand{ display:flex; }
body.pi-browser-collapsed .pi-pos-browser-pane{ display:none !important; }
/* !important because the pane carries lg:tw-w-[60%]; the right padding keeps
   the last column of the cart (the remove-line button) clear of the tab */
body.pi-browser-collapsed .pi-pos-cart-pane{ width:100% !important; padding-right:10px !important; }

@media (prefers-reduced-motion: reduce){
    .pi-browser-toggle{ transition:none; }
}
