/* =====================================================================
   WeloDesk — Mobile & small-device responsive fixes
   Loaded AFTER Bootstrap + AdminLTE (+ page CSS) so these rules win
   wherever specificity ties occur.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Global guards
--------------------------------------------------------------------- */
.content-wrapper { min-width: 0; }

/* ---------------------------------------------------------------------
   2. Header polish on phones (AdminLTE stacks logo above the navbar)
--------------------------------------------------------------------- */
@media (max-width: 767px) {
    html, body { overflow-x: hidden !important; }

    /* Keep long hotel names from pushing the header icons off-screen */
    .hotel-name-label {
        display: inline-block;
        max-width: calc(100vw - 260px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: middle;
    }

    .navbar-custom-menu > .navbar-nav > li > a {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

/* ---------------------------------------------------------------------
   3. Content header: stack page title and breadcrumb on phones
--------------------------------------------------------------------- */
@media (max-width: 767px) {
    .content-header { padding: 12px 15px 4px !important; }
    .content-header > h1 {
        float: none !important;
        width: 100% !important;
        font-size: 20px !important;
        line-height: 1.25 !important;
        margin: 0 0 2px !important;
    }
    .content-header .breadcrumb {
        float: none !important;
        margin: 0 !important;
        padding: 2px 0 0 !important;
        white-space: nowrap;
        overflow-x: auto;
    }
}

/* ---------------------------------------------------------------------
   4. Box headers: let title + action buttons wrap instead of overlapping
--------------------------------------------------------------------- */
@media (max-width: 767px) {
    .box-header.with-border {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }
    .box-header.with-border .box-title { flex: 1 1 auto; min-width: 0; }
    .box-header.with-border .pull-right,
    .box-header.with-border .box-tools { float: none !important; }
    .box-header.with-border .btn { flex: 0 0 auto; }
}

/* ---------------------------------------------------------------------
   5. Forms: comfortable touch sizes; 16px text stops iOS focus-zoom
--------------------------------------------------------------------- */
@media (max-width: 767px) {
    .form-control { font-size: 16px !important; height: 40px; }
    select.form-control { height: 40px; }
    .input-group-addon { padding: 8px 10px; }
}

/* Full-width action buttons at the bottom of forms on narrow phones */
@media (max-width: 480px) {
    .box-footer { display: flex; flex-direction: column-reverse; }
    .box-footer .btn { width: 100%; margin-top: 8px; }
    .box-footer .pull-right { float: none !important; }
}

/* Stack the two payment-method columns on narrow phones */
@media (max-width: 575px) {
    #paymentMethodContainer .col-xs-6 {
        width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* ---------------------------------------------------------------------
   6. DataTables controls: keep search/length/pagination inside the box
--------------------------------------------------------------------- */
.dataTables_wrapper .row { margin-left: -5px; margin-right: -5px; }
.dataTables_wrapper [class*="col-"] { padding-left: 5px; padding-right: 5px; }

@media (max-width: 767px) {
    .dataTables_wrapper .dataTables_filter { text-align: left !important; }
    .dataTables_wrapper .dataTables_filter label { white-space: normal; }
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: none !important;
        margin: 4px 0 0 !important;
        display: block;
    }
    .dataTables_wrapper .dataTables_length { margin-bottom: 6px; }
    .dataTables_wrapper .dataTables_info { float: none !important; text-align: left !important; }
    .dataTables_wrapper .dataTables_paginate {
        white-space: nowrap;
        overflow-x: auto;
        max-width: 100%;
    }
}

/* ---------------------------------------------------------------------
   7. Horizontal-scroll helper for wide tables (e.g. POS product picker)
--------------------------------------------------------------------- */
.pos-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.pos-table-scroll .table { min-width: 620px; margin-bottom: 0; }
.pos-table-scroll .dataTables_wrapper { min-width: 620px; }

/* Scrollable tables should pan smoothly on touch devices */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ---------------------------------------------------------------------
   8. Modals: near full-screen and scrollable on phones
--------------------------------------------------------------------- */
@media (max-width: 767px) {
    .modal-dialog { width: auto; margin: 8px; max-width: none; }
    .modal-body {
        max-height: calc(100vh - 160px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-footer { display: flex; flex-wrap: wrap; gap: 8px; }
    .modal-footer .btn { flex: 1 1 auto; }
}

/* ---------------------------------------------------------------------
   9. Sticky cart bar for the POS (create/edit sale) on small screens.
      Hidden on desktop (>= 1200px) where the two-column layout fits.
--------------------------------------------------------------------- */
.mobile-cart-bar { display: none; }

@media (max-width: 1199px) {
    .mobile-cart-bar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        /* Above page content (800) but below the sidebar (810) and modals (1040),
           so the off-canvas mobile sidebar can slide over the bar. */
        z-index: 805;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 10px 14px;
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    }
    /* On tablets the sidebar is permanently visible: keep the bar
       only over the content area, respecting the collapsed width too. */
    @media (min-width: 768px) {
        body:not(.sidebar-collapse) .mobile-cart-bar { left: 230px; }
        body.sidebar-collapse .mobile-cart-bar { left: 50px; }
    }
    .mobile-cart-bar .mcb-info {
        font-size: 14px;
        color: #475569;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mobile-cart-bar .mcb-info .fa { margin-right: 4px; color: #4f46e5; }
    .mobile-cart-bar .mcb-count { font-weight: 700; color: #1e293b; }
    .mobile-cart-bar .mcb-total { font-weight: 700; font-size: 15px; color: #16a34a; }
    .mobile-cart-bar .mcb-btn { min-width: 130px; flex: 0 0 auto; }

    /* Room so the bar never covers the page content / footer */
    body.cart-bar-active .content-wrapper { padding-bottom: 70px !important; }
    body.cart-bar-active .main-footer { margin-bottom: 58px; }
}
@media (min-width: 1200px) {
    body.cart-bar-active .content-wrapper { padding-bottom: 0 !important; }
    body.cart-bar-active .main-footer { margin-bottom: 0; }
}

/* ---------------------------------------------------------------------
   10. Touch enhancements
--------------------------------------------------------------------- */
@media (pointer: coarse) {
    .btn-xs { padding: 5px 8px !important; }
    table .btn { margin: 1px 0; }
    .sidebar-menu > li > a, .treeview-menu > li > a { min-height: 42px; }
}

/* ---------------------------------------------------------------------
   10b. POS product tile grid (create-sale page)
   All products as touch-friendly tiles + category filter chips.
--------------------------------------------------------------------- */
.pos-chips { margin-bottom: 4px; }
.pos-chips .pos-chip { margin: 0 6px 6px 0; }

#posProductGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}
#posProductGrid .pos-tile {
    position: relative;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 6px 6px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: border-color .12s, box-shadow .12s, transform .06s;
}
#posProductGrid .pos-tile:hover {
    border-color: #4f46e5;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
#posProductGrid .pos-tile:active { transform: scale(.96); }
#posProductGrid .pos-tile img {
    width: 56px; height: 56px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 6px;
    background: #f1f5f9;
}
#posProductGrid .pos-tile-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.25;
    height: 32px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 3px;
}
#posProductGrid .pos-tile-price {
    font-size: 12px;
    font-weight: 700;
    color: #16a34a;
}
/* Already in the cart */
#posProductGrid .pos-tile.pos-added {
    border-color: #16a34a;
    background: #f0fdf4;
}
/* Cart quantity badge on tiles */
#posProductGrid .pos-qty-badge {
    position: absolute;
    top: 4px; left: 4px;
    background: #16a34a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
}
/* Out of stock */
#posProductGrid .pos-tile.pos-out {
    opacity: .45;
    cursor: not-allowed;
    filter: grayscale(.6);
}
#posProductGrid .pos-out-badge {
    position: absolute;
    top: 4px; right: 4px;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    text-transform: uppercase;
}
@media (max-width: 768px) {
    #posProductGrid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
    #posProductGrid .pos-tile img { width: 44px; height: 44px; }
}

/* ---------------------------------------------------------------------
   11. Footer: centre text on very small screens
--------------------------------------------------------------------- */
@media (max-width: 480px) {
    .main-footer { text-align: center; }
}
/* ---------------------------------------------------------------------
   12. Professional POS — FULL-SCREEN layout (create-sale page)
   The whole viewport is used: fixed order ticket on the left, product
   catalog filling the rest. Both columns scroll independently; the
   ticket footer with the grand total is always visible.
--------------------------------------------------------------------- */

/* --- Page shell: kill the normal AdminLTE scroll, go full height --- */
.pos-page-wrapper .pos-page-header { display: flex; align-items: center; justify-content: space-between; }
.pos-page-wrapper .pos-page-header h1 { font-size: 22px; margin: 6px 0; }
.pos-page-wrapper .pos-page-content { padding: 0 12px 12px; }
.pos-page-wrapper .main-footer { display: none; }

.pos-stage {
    display: flex;
    gap: 14px;
    align-items: stretch;
    height: calc(100vh - 108px);
    min-height: 540px;
}

/* --- Left: order ticket (fixed width, own scroll) --- */
.pos-ticket {
    flex: 0 0 380px;
    width: 380px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .07);
    overflow: hidden;
}
.pos-ticket-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pos-ticket-head {
    flex: 0 0 auto;
    background: #1e293b;
    color: #e2e8f0;
    font-weight: 700;
    font-size: 14px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pos-ticket-head .fa { color: #4ade80; }
.pos-ticket-head-code {
    margin-left: auto;
    background: rgba(255,255,255,.12);
    border-radius: 10px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #cbd5e1;
}
.pos-ticket-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 14px;
    min-height: 0;
}
.pos-ticket-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #1e293b;
    padding: 12px 16px;
    border-top: 1px solid #0f172a;
}

/* --- Right: product catalog (fills remaining width, own scroll) --- */
.pos-catalog {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .07);
    overflow: hidden;
}
.pos-catalog-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.pos-catalog-title { margin: 0; font-size: 17px; font-weight: 700; color: #1e293b; }
.pos-catalog-title .fa { color: #4f46e5; margin-right: 6px; }
.pos-catalog-title small { font-weight: 400; color: #94a3b8; font-size: 12.5px; }
.pos-catalog-search { flex: 0 0 300px; }
.pos-catalog .pos-chips {
    flex: 0 0 auto;
    padding: 10px 16px 0;
}
#posProductGrid {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 16px 16px;
    align-content: start;
    grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
}
.pos-grid-empty {
    flex: 1 1 auto;
    display: none;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 14px;
    margin: 0;
}

/* Bigger, richer product tiles for the full-height catalog */
#posProductGrid .pos-tile {
    border-radius: 10px;
    padding: 10px 8px 8px;
}
#posProductGrid .pos-tile img { width: 64px; height: 64px; }
#posProductGrid .pos-tile-name { font-size: 13px; }
#posProductGrid .pos-tile-price { font-size: 13px; }

/* Section label inside the ticket */
.pos-ticket-sec {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #94a3b8;
    margin: 14px 0 6px;
}
.pos-ticket-sec .fa { margin-right: 4px; }

/* Header badges */
.pos-meta-badge {
    font-size: 12.5px;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 4px 12px;
    vertical-align: middle;
    margin-left: 8px;
}
.pos-meta-badge .fa { margin-right: 3px; color: #4f46e5; }
.pos-meta-code .fa { color: #16a34a; }

/* Segmented order-type buttons */
.pos-seg {
    display: flex;
    gap: 6px;
    margin: 2px 0 10px;
}
.pos-seg-btn {
    flex: 1 1 0;
    min-height: 48px;
    border: 2px solid #e2e8f0;
    background: #fff;
    color: #475569;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .12s;
    padding: 5px 2px;
}
.pos-seg-btn .fa { display: block; font-size: 17px; margin-bottom: 3px; }
.pos-seg-btn:hover { border-color: #94a3b8; }
.pos-seg-btn.active {
    border-color: #4f46e5;
    background: #eef2ff;
    color: #4f46e5;
}

.pos-meta-row { margin: 0 0 8px; }
.pos-scan-row { margin-bottom: 10px; }
.pos-scan-row input { font-family: monospace; }

/* Cart rows */
.pos-cart-row {
    display: flex;
    align-items: center;
    padding: 7px 2px;
    border-bottom: 1px dashed #e2e8f0;
    margin-left: 0 !important;
    margin-right: 0 !important;
}
.pos-cart-row .pos-cart-name { display: flex; align-items: center; gap: 6px; padding-right: 4px; }
.pos-cart-row .pos-cart-name input { min-width: 0; }
.pos-cart-row .pos-cart-qty { display: flex; align-items: center; gap: 4px; padding: 0 4px; }
.pos-cart-row .pos-cart-qty input {
    text-align: center;
    width: 44px;
    -moz-appearance: textfield;
}
.pos-cart-row .pos-cart-qty input::-webkit-outer-spin-button,
.pos-cart-row .pos-cart-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pos-cart-row .pos-qty-dec, .pos-cart-row .pos-qty-inc { min-width: 30px; }
.pos-cart-row .newProductPrice { text-align: right; font-weight: 600; }

/* Empty cart hint */
.pos-cart-empty {
    text-align: center;
    color: #94a3b8;
    padding: 22px 8px;
    font-size: 13px;
    border: 2px dashed #e2e8f0;
    border-radius: 9px;
    margin: 8px 0;
}
.pos-cart-empty .fa { display: block; font-size: 22px; margin-bottom: 6px; }

/* Totals block */
.pos-totals {
    margin: 12px 0 4px;
    border-top: 2px solid #e2e8f0;
    padding-top: 8px;
}
.pos-totals-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 2px;
    font-size: 13.5px;
    color: #475569;
}
.pos-totals-row b { color: #1e293b; font-variant-numeric: tabular-nums; }
.pos-totals-tax .pos-tax-input {
    width: 60px;
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    text-align: right;
}
.pos-totals-row.pos-grand {
    border-top: 2px solid #1e293b;
    margin-top: 6px;
    padding-top: 8px;
    font-size: 15px;
    color: #1e293b;
}
.pos-totals-row.pos-grand b {
    font-size: 26px;
    color: #16a34a;
    font-weight: 800;
}

/* Big payment method buttons */
.pos-pay-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}
.pos-pay-btn {
    min-height: 54px;
    border: 2px solid #e2e8f0;
    background: #fff;
    border-radius: 9px;
    font-size: 11.5px;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all .12s;
    padding: 5px 2px;
    line-height: 1.2;
}
.pos-pay-btn .fa { display: block; font-size: 17px; margin-bottom: 3px; }
.pos-pay-btn:hover { border-color: #94a3b8; }
.pos-pay-btn.active { border-color: #4f46e5; background: #eef2ff; color: #4f46e5; }
.pos-pay-cash.active { border-color: #16a34a; background: #f0fdf4; color: #15803d; }
.pos-pay-cc.active, .pos-pay-dc.active { border-color: #2563eb; background: #eff6ff; color: #2563eb; }
.pos-pay-momo.active { border-color: #d97706; background: #fffbeb; color: #d97706; }
.pos-pay-room.active { border-color: #7c3aed; background: #f5f3ff; color: #7c3aed; }

/* Quick cash tender + change due */
.pos-cash-tender {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    padding: 8px 10px;
    margin-bottom: 10px;
}
.pos-tender-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pos-tender-chip { min-width: 74px; }
.pos-change-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #475569;
}
.pos-change-row b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* Advanced collapse */
.pos-advanced { margin: 4px 0 8px; box-shadow: none; }
.pos-advanced .panel { border-radius: 9px; margin-bottom: 0; }

/* Footer total + save */
.pos-footer-total { color: #cbd5e1; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.pos-footer-total b {
    display: block;
    color: #4ade80;
    font-size: 24px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}
.pos-ticket-footer .pos-save-btn {
    min-width: 160px;
    min-height: 50px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.pos-ticket-footer .pos-save-btn:active { transform: scale(.97); }

/* --- Responsive: below 1200px fall back to stacked layout --- */
@media (max-width: 1199px) {
    .pos-stage { display: block; height: auto; min-height: 0; }
    .pos-ticket { width: 100%; flex: none; margin-bottom: 14px; }
    .pos-ticket-scroll { max-height: none; }
    .pos-catalog { min-height: 60vh; }
    #posProductGrid { overflow: visible; }
    .pos-catalog-search { flex: 1 1 auto; }
}
