/* =========================================================
   Mobile layout for the whole software (2026-10)
   Loaded from includes/head.php after theme-standard.css.
   Works together with assets/js/mobile.js.
   ========================================================= */

#pos-tabbar { display: none; } /* only on small screens (below) */

/* ---------- phones and small tablets ---------- */
@media (max-width: 991px) {
    /* POS header: wrap instead of overlapping the bill */
    body .pos-main-header { display: flex !important; height: auto !important; min-height: 0 !important; flex-shrink: 0 !important; flex-wrap: wrap; gap: 8px; padding: 8px 10px !important; position: sticky; top: 0; }
    body .pos-main-header .pos-header-search { order: 1; flex: 1 1 100%; margin: 0 !important; }
    body .pos-main-header .pos-header-search-box, body .pos-main-header #product_search_side { width: 100% !important; }
    body .pos-main-header .pos-header-left { order: 2; flex: 1 1 auto; min-width: 0; margin: 0 !important; }
    body .pos-main-header .pos-header-logo { width: 34px !important; height: 34px !important; }
    body .pos-main-header .pos-business-name .main-name { font-size: 15px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    body .pos-main-header .pos-business-name .sub-name { display: none !important; }
    body .pos-main-header .pos-header-left + .pos-header-left { order: 4; flex: 1 1 100%; display: flex; gap: 6px; overflow-x: auto; white-space: nowrap; padding-bottom: 2px; }
    body .pos-main-header .pos-header-left + .pos-header-left { padding-top: 10px; }
    body .pos-main-header .pos-header-left + .pos-header-left > * { flex: 0 0 auto; margin: 0 !important; }
    body .pos-main-header .pos-header-left + .pos-header-left .btn { height: auto !important; min-height: 36px; padding: 6px 12px !important; font-size: 13px !important; line-height: 1.3 !important; display: inline-flex !important; align-items: center; }
    body .pos-main-header .pos-header-left + .pos-header-left #dinein_model { padding: 0 !important; min-height: 0; }
    body .pos-main-header .pos-header-right { display: none !important; } /* date/time + user box: not needed on a phone */
    body .pos-main-header .pos-date-time, body .pos-main-header .pos-user-info, body .pos-main-header .pos-user-arrow { display: none !important; }
    body .pos-main-header .pos-user-icon { width: 36px !important; height: 36px !important; font-size: 18px !important; margin: 0 !important; }
    body .contentPOS { margin-top: 0 !important; padding-top: 8px !important; }

    /* POS: one tab at a time + bottom bar */
    body.pos-mobile-ready { padding-bottom: 78px !important; }
    body.pos-mobile-ready.pos-tab-items .m-bill { display: none !important; }
    body.pos-mobile-ready.pos-tab-bill .m-items { display: none !important; }
    body.pos-mobile-ready .m-items, body.pos-mobile-ready .m-bill { flex: 0 0 100% !important; max-width: 100% !important; }
    body.pos-mobile-ready .product-items { height: auto !important; max-height: none !important; }
    body.pos-mobile-ready .product-grid { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    body.pos-mobile-ready .product-grid .product-card-wrapper { width: auto !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
    body.pos-mobile-ready .table-datapos { height: auto !important; min-height: 90px; max-height: none !important; }
    body.pos-mobile-ready .cart-div .card-body > div:last-of-type { display: flex; gap: 8px; }
    body.pos-mobile-ready .cart-div .card-body > div:last-of-type .btn { flex: 1 1 0; margin: 0 !important; height: 50px; }

    #pos-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 99990; display: flex; background: #1b2a49; box-shadow: 0 -4px 16px rgba(0,0,0,.18); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
    #pos-tabbar button { flex: 1 1 0; border: 0; border-radius: 10px; background: rgba(255,255,255,.08); color: #c9d2e3; font: 700 15px/1.2 -apple-system, "Segoe UI", Roboto, sans-serif; padding: 10px 6px; display: flex; align-items: center; justify-content: center; gap: 6px; }
    #pos-tabbar button.active { background: #f28c28; color: #fff; }
    #pos-tabbar .t-ico { font-size: 18px; }
    #pos-tabbar .t-count { background: #fff; color: #1b2a49; border-radius: 999px; padding: 0 7px; margin-left: 2px; font-size: 13px; }
    #pos-tabbar .t-total { font-weight: 800; margin-left: 4px; }
    #pos-tabbar button.bump { animation: posBump .45s ease; }
    @keyframes posBump { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
    body.pos-mobile-ready #voiceAssistantBtn { bottom: 90px !important; }
    body.pos-mobile-ready #voiceStatus { bottom: 156px !important; }
    body.pos-mobile-ready #offline-badge { bottom: 90px !important; }

    /* Tables (View Table Status) and other big pop-ups: full screen */
    body .modal-dialog.custom-modal, body #dinein_items .modal-dialog { max-width: 100% !important; width: 100% !important; margin: 0 !important; }
    body #dinein_items .modal-content { min-height: 100vh; border-radius: 0; }
    body #dinein_items .modal-title { font-size: 18px !important; flex-wrap: wrap; gap: 6px; }
    body #dinein_items .modal-title .btn { margin: 0 !important; }
    body #content .col-md-6 { flex: 0 0 100%; max-width: 100%; border-right: 0 !important; box-shadow: none !important; }
}

/* ---------- phones ---------- */
@media (max-width: 767px) {
    body { -webkit-text-size-adjust: 100%; }
    #main-content { padding-left: 6px !important; padding-right: 6px !important; }
    #main-content .container-fluid { padding-left: 4px !important; padding-right: 4px !important; }
    .block-header h2 { font-size: 18px !important; }
    .block-header .breadcrumb { display: none; }

    /* bigger touch targets */
    #main-content .btn { min-height: 38px; }
    #main-content .form-control, #main-content select { min-height: 42px; font-size: 16px !important; } /* 16px stops iOS zoom */

    /* top bar: keep it to one clean line */
    nav.navbar .navbar-brand span { font-size: 15px !important; padding: 8px !important; }

    /* dashboard: two small cards per row */
    .dashboard .row > [class*="col-lg-2"] { flex: 0 0 50% !important; max-width: 50% !important; padding-left: 5px !important; padding-right: 5px !important; }
    .dashboard-card { padding: 10px 10px 6px !important; margin-bottom: 10px !important; border-radius: 12px !important; }
    .dashboard-card .card-header { flex-direction: column; align-items: flex-start !important; gap: 6px !important; }
    .dashboard-card .icon-box { width: 32px !important; height: 32px !important; font-size: 14px !important; border-radius: 9px !important; }
    .dashboard-card .card-content { text-align: left !important; }
    .dashboard-card .card-title { font-size: 11.5px !important; }
    .dashboard-card .card-value { font-size: 16px !important; }
    .dashboard-card .card-graph, .dashboard-card .miniChart, .dashboard-card .card-note { height: 40px !important; }
    .dashboard .sale-chart-wrap { height: 300px !important; }
    .dashboard .current-status { justify-content: flex-start !important; flex-wrap: wrap; gap: 6px; }
    .dashboard .chart-heading { flex-direction: column; align-items: flex-start !important; }
    .dashboard .row[style*="display:flex"] { display: block !important; }
    .dashboard .card[style*="height"] { height: auto !important; max-height: 420px; }

    /* wide tables -> one card per row (labels added by mobile.js) */
    table.m-cards, table.m-cards tbody, table.m-cards tr, table.m-cards td { display: block; width: 100% !important; }
    table.m-cards { min-width: 0 !important; border: 0 !important; }
    table.m-cards thead, table.m-cards tr:has(> th) { display: none !important; }
    table.m-cards tr { background: #fff; border: 1px solid #e3e8f1 !important; border-radius: 12px; margin: 0 0 10px; padding: 8px 10px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
    table.m-cards td { border: 0 !important; padding: 4px 0 !important; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: right !important; font-size: 14px; white-space: normal !important; }
    table.m-cards td::before { content: attr(data-label); color: #6b7a90; font-weight: 600; font-size: 12px; text-align: left; flex: 0 0 auto; max-width: 45%; }
    table.m-cards td[data-label=""]::before { content: none; }
    table.m-cards td.m-empty { display: none !important; }
    table.m-cards td:last-child { flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding-top: 8px !important; border-top: 1px dashed #e3e8f1 !important; margin-top: 4px; }
    table.m-cards td:last-child::before { display: none; }
    table.m-cards td .btn { margin: 0 !important; }
    .table-responsive { border: 0 !important; }

    /* filter blocks folded behind a button (mobile.js) */
    .m-folded { display: none !important; }
    .m-folded.m-open { display: block !important; }
    .m-folded.m-open.row { display: flex !important; }
    .m-filter-toggle { width: 100%; margin: 6px 0 10px; padding: 10px 14px; border: 1px solid #d3dae8; border-radius: 10px; background: #fff; color: #1b2a49; font-weight: 700; text-align: left; }

    /* offline bills box: compact */
    #offline-bills { margin: 8px 4px !important; padding: 10px !important; }
    #offline-bills table.m-cards tr { border-left: 4px solid #f28c28 !important; }

    /* POS: 2 product columns on very small phones */
    @media (max-width: 360px) {
        body.pos-mobile-ready .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
}