/* Mobile layout (owner 2026-11-17). Desktop is unchanged: everything here is inside the phone/tablet media query.
   Works with app/static/Views/Scripts/mobile.js (menu button, tap-to-open menus, table cards). */

.m-menu-btn { display: none; }

@media (max-width: 991.98px) {
    html, body { overflow-x: hidden; }          /* never scroll sideways on a phone */
    body { font-size: 14px; }

    /* ---- top menu: ☰ button, links stacked, submenus open on tap */
    .navbar-primary { flex-wrap: wrap; padding: 6px 12px; }
    .m-menu-btn { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; width: 44px; height: 40px;
                  border: 1px solid rgba(255,255,255,.6); border-radius: 6px; background: transparent; color: #fff; font-size: 20px; }
    #navbarNav { width: 100%; }
    #navbarNav.m-open { display: block !important; }
    #navbarNav .navbar-nav { flex-direction: column; width: 100%; }
    .navbar-primary .navbar-nav .nav-link { flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 16px; padding: 10px 6px; }
    .nav-item.dropdown:hover .dropdown-menu { display: none; }           /* no hover on phones */
    .nav-item.dropdown.m-sub-open .dropdown-menu { display: block; position: static; }
    .dropdown-menu .dropdown-item { padding: 10px 18px; font-size: 15px; }

    /* ---- filter bar: hidden until "Filters" is tapped */
    #filters.m-filters-closed { display: none; }
    .show-hide-btn { position: static; width: 100%; clip-path: none; border-radius: 0; padding: 8px; }
    .filter-controls .row > [class*="col"] { width: 100% !important; flex: 0 0 100%; max-width: 100%; margin-bottom: 6px; }
    .filter-controls .select2-container { width: 100% !important; }

    /* ---- left status list -> a row of chips you can swipe */
    .main-row, .add-main-row, .sub-main-row { display: block !important; height: auto !important; overflow: visible !important; }
    .sidebar { height: auto; width: 100% !important; padding: 6px 8px; }
    .sidebar .sidebutton { display: none; }
    .status-filters { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
    .status-filters a { flex: 0 0 auto; }
    .status-filters .d-flex { white-space: nowrap; padding: 6px 10px; border-radius: 16px; background: rgba(255,255,255,.08); }
    .main-content-wrapper, .add-left-margin, .sub-left-margin { width: 100% !important; margin: 0 !important; }
    .main-content { padding: 6px; }
    .button_row .col-md-12 { display: flex; flex-wrap: wrap; gap: 6px; }

    /* ---- buttons and boxes big enough for fingers */
    .btn, .form-control, .form-select, select, input[type="text"], input[type="number"], input[type="search"] { min-height: 38px; font-size: 15px; }
    input[type="checkbox"] { width: 22px; height: 22px; }

    /* ---- popups use the whole screen */
    .modal-dialog { max-width: 100% !important; min-width: 0 !important; width: 100% !important; margin: 0 !important; }
    .modal-content { min-height: 100vh; border-radius: 0; }
    .modal-body { overflow-x: hidden; }
    .modal-body .row > [class*="col"] { width: 100%; flex: 0 0 100%; max-width: 100%; }

    /* ---- tables become cards (labels come from the column headers, see 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 thead, table.m-cards tfoot { display: none; }
    table.m-cards tr { background: #fff; border: 1px solid #ddd; border-radius: 10px; margin: 10px 0; padding: 6px 8px;
                       box-shadow: 0 1px 3px rgba(0,0,0,.06); }
    /* label in a fixed left column, the cell's own content flows normally on the right */
    table.m-cards td { position: relative; border: none !important; padding: 5px 2px 5px 36% !important; min-height: 26px;
                       text-align: left !important; white-space: normal !important; word-break: break-word; height: auto !important; }
    table.m-cards td::before { content: attr(data-label); position: absolute; left: 2px; top: 6px; width: 33%;
                               font-weight: 600; color: #6c757d; font-size: 12px; line-height: 1.25; }
    table.m-cards td[data-label=""] { padding-left: 2px !important; }
    table.m-cards td[data-label=""]::before { content: none; }
    table.m-cards td > * { max-width: 100%; }
    table.m-cards td input[type="text"], table.m-cards td input[type="number"], table.m-cards td select { width: 100% !important; }
    table.m-cards td.dataTables_empty::before { content: none; }
    table.m-cards tr.child, table.m-cards tr:empty { display: none; }
    /* DataTables' fixed-height scrolling area and duplicate header table */
    .dataTables_scrollHead, .dataTables_scrollFoot { display: none !important; }
    .dataTables_scrollBody { height: auto !important; max-height: none !important; overflow: visible !important; }
    .dataTables_scroll, .dataTables_wrapper, .dataTables_scrollBody > table { width: 100% !important; }
    .table-responsive { overflow-x: visible; }
    .m-sort { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
    .m-sort select { flex: 1; }

    /* Bootstrap rows stick out by half a gutter on each side; on phones that pushes cards past the screen edge */
    .main-content .row, .main-content-wrapper .row, .tab-content .row, .container-fluid > .row {
        --bs-gutter-x: 0; margin-left: 0 !important; margin-right: 0 !important; }
    .main-content [class*="col-"], .tab-content [class*="col-"] { padding-left: 0; padding-right: 0; }
    table.m-cards { max-width: 100%; table-layout: auto; }
    /* DataTables' own CSS makes cells content-box: the 36% label padding then came on top of 100% width */
    table.m-cards td, table.m-cards tr { box-sizing: border-box !important; }
    /* desktop fixed widths / no-wrap bits inside cards */
    table.m-cards .order-id-col { width: auto !important; max-width: 100%; }
    table.m-cards .ret-stage, table.m-cards .case-type, table.m-cards .case-can-esc { white-space: normal; }
    table.m-cards td img { max-width: 100%; height: auto; }
    table.m-cards tr { max-width: 100%; overflow: hidden; }

    /* fixed footers must not cover the last card */
    body { padding-bottom: 48px; }
}

/* =====================================================================================================================
   Phone lists v2 (owner: "awful, set it out cleaner"). Each page's rows get a purpose-made layout: an inbox-style list,
   full-width rows split by hairlines, the order number and price as the only bold things, everything else small.
   mobile.js adds .m-list-orders / -messages / -cases / -products by looking at the column names (td[data-label]).
   ===================================================================================================================== */
@media (max-width: 991.98px) {
    :root { --m-ink: #1d2125; --m-muted: #6f767d; --m-line: #e7e3e0; --m-brand: #f68c6a; --m-brand-deep: #e2643c; --m-link: #1f7a79; }

    .main-content { padding: 0; background: #fff; }
    .main-content .button_row { padding: 8px 10px 0; }
    .m-sort { padding: 0 10px; }

    /* list tables: no card boxes, no per-field labels */
    table.m-cards.m-list { border-collapse: collapse; margin: 0 !important; background: #fff; }
    table.m-cards.m-list tr { margin: 0; border: none; border-bottom: 1px solid var(--m-line); border-radius: 0; box-shadow: none;
                              padding: 12px 12px 12px 14px; background: #fff !important; position: relative; color: var(--m-ink); }
    table.m-cards.m-list tr:has(input[type="checkbox"]:checked) { background: #fff7f3 !important; }
    table.m-cards.m-list tr:has(input[type="checkbox"]:checked)::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0;
                              width: 4px; background: var(--m-brand); }
    table.m-cards.m-list td { padding: 0 !important; min-height: 0; position: static; font-size: 13px; line-height: 1.35;
                              color: var(--m-muted); background: transparent !important; box-shadow: none !important; }
    table.m-cards.m-list td::before { content: none; }
    table.m-cards.m-list a { color: var(--m-link); text-decoration: none; }
    table.m-cards.m-list td .btn, table.m-cards.m-list td .badge { min-height: 0; padding: 2px 9px; font-size: 11px; line-height: 1.4;
                              border-radius: 10px; font-weight: 600; }
    table.m-cards.m-list td img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: #f1eeec; }

    /* ---- orders (Awaiting / Pending / All / Shipped / Cancelled) */
    table.m-list-orders tr { display: grid !important; grid-template-columns: 26px 48px minmax(0, 1fr) auto; column-gap: 10px; row-gap: 3px;
        grid-template-areas: "chk pic main total" "chk pic main status" "chk pic buyer when" "chk pic method store" "track track track track"; }
    table.m-list-orders td { display: block; width: auto !important; }
    table.m-list-orders td:first-child[data-label=""] { grid-area: chk; align-self: start; padding-top: 2px !important; }
    table.m-list-orders td[data-label="Picture"] { grid-area: pic; }
    table.m-list-orders td[data-label="Order ID / Product"] { grid-area: main; color: var(--m-ink); }
    table.m-list-orders td[data-label="Order ID / Product"] .order-id-col { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
        overflow: hidden; font-size: 13px; }
    table.m-list-orders td[data-label="Order ID / Product"] a:first-child { display: block; font-size: 15px; font-weight: 700; color: var(--m-ink); }
    table.m-list-orders td[data-label="Total"] { grid-area: total; font-size: 15px; font-weight: 700; color: var(--m-ink); text-align: right !important; }
    table.m-list-orders td[data-label="Status"] { grid-area: status; text-align: right !important; }
    table.m-list-orders td[data-label="Buyer"] { grid-area: buyer; white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; }
    table.m-list-orders td[data-label="Ordered"], table.m-list-orders td[data-label="Shipped"] { grid-area: when; text-align: right !important; font-size: 12px; }
    table.m-list-orders tr:has(td[data-label="Shipped"]) td[data-label="Ordered"] { display: none; }
    table.m-list-orders td[data-label="Shipping Method"] { grid-area: method; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap !important; }
    table.m-list-orders td[data-label="Account"] { grid-area: store; text-align: right !important; font-size: 12px; }
    table.m-list-orders td[data-label="Subject"] { display: none; }
    table.m-list-orders td[data-label="Tracking Details"] { grid-area: track; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
    table.m-list-orders td[data-label="Tracking Details"] br { display: none; }
    table.m-list-orders td[data-label="Tracking Details"] select { flex: 0 0 38%; width: auto !important; }
    table.m-list-orders td[data-label="Tracking Details"] input { flex: 1 1 50%; width: auto !important; }
    table.m-list-orders td[data-label="Tracking Details"] .errorSpan { flex-basis: 100%; }
    table.m-list-orders td[data-label="Tracking Details"]:empty, table.m-list-orders td[data-label="Tracking Details"]:not(:has(*)) { display: none; }

    /* ---- messages (New / Resolved) */
    table.m-list-messages tr { display: grid !important; grid-template-columns: 26px minmax(0, 1fr) auto; column-gap: 10px; row-gap: 3px;
        grid-template-areas: "chk name date" "chk subject subject" "chk product product" "chk store status"; }
    table.m-list-messages td { display: block; width: auto !important; }
    table.m-list-messages td:first-child[data-label=""] { grid-area: chk; padding-top: 2px !important; }
    table.m-list-messages td[data-label="Customer Name"] { grid-area: name; font-size: 15px; font-weight: 700; color: var(--m-ink);
        white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; }
    table.m-list-messages td[data-label="Date Created"] { grid-area: date; font-size: 12px; text-align: right !important; }
    table.m-list-messages td[data-label="Date Updated"] { display: none; }
    table.m-list-messages td[data-label="Subject"] { grid-area: subject; color: var(--m-ink); }
    table.m-list-messages td[data-label="Subject"] .order-id-col, table.m-list-messages td[data-label="Subject"] > a { display: -webkit-box;
        -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    table.m-list-messages td[data-label="Subject"] a { color: var(--m-ink); }
    table.m-list-messages td[data-label="Product"] { grid-area: product; font-size: 12px; white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; }
    table.m-list-messages td[data-label="Product"] .order-id-col { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    table.m-list-messages td[data-label="Account"] { grid-area: store; font-size: 12px; }
    table.m-list-messages td[data-label="Status"] { grid-area: status; text-align: right !important; }

    /* ---- cases */
    table.m-list-cases tr { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; row-gap: 4px; cursor: pointer;
        grid-template-areas: "type amount" "buyer due" "item item" "reason deliv" "status status" "order store"; }
    table.m-list-cases td { display: block; width: auto !important; }
    table.m-list-cases td[data-label="Type"] { grid-area: type; }
    table.m-list-cases td[data-label="Type"] .ret-stage { display: inline; margin-left: 6px; }
    table.m-list-cases td[data-label="Amount"] { grid-area: amount; font-size: 15px; font-weight: 700; color: var(--m-ink); text-align: right !important; }
    table.m-list-cases td[data-label="Buyer"] { grid-area: buyer; font-size: 15px; font-weight: 700; color: var(--m-ink); }
    table.m-list-cases td[data-label="Respond by"] { grid-area: due; text-align: right !important; font-size: 12px; }
    table.m-list-cases td[data-label="Item / SKU"] { grid-area: item; color: var(--m-ink); }
    table.m-list-cases td[data-label="Item / SKU"] div { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    table.m-list-cases td[data-label="Reason"] { grid-area: reason; }
    table.m-list-cases td[data-label="Delivered"] { grid-area: deliv; text-align: right !important; }
    table.m-list-cases td[data-label="Delivered"] i { font-size: 16px !important; }
    table.m-list-cases td[data-label="Status"] { grid-area: status; font-size: 12px; }
    table.m-list-cases td[data-label="Order"] { grid-area: order; font-size: 12px; }
    table.m-list-cases td[data-label="Store"] { grid-area: store; font-size: 12px; text-align: right !important; }
    table.m-list-cases td[data-label="Opened"] { display: none; }

    /* ---- products: picture + name, then stock / prices / package fields as small labelled boxes in a row */
    table.m-list-products tr { display: flex !important; flex-wrap: wrap; gap: 8px 8px; align-items: flex-start; }
    table.m-list-products td { display: block; width: auto !important; }
    table.m-list-products td[data-label="Picture"] { flex: 0 0 48px; }
    table.m-list-products td[data-label="Product Name"] { flex: 1 1 calc(100% - 60px); order: 1; color: var(--m-ink); font-size: 14px; font-weight: 600;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    table.m-list-products td[data-label="SKU"] { flex: 0 0 100%; order: 2; margin: -6px 0 0 56px; font-size: 12px; }
    table.m-list-products td[data-label="Picture"] { order: 0; }
    table.m-list-products td.m-field { order: 3; flex: 1 1 0; min-width: 64px; }
    table.m-list-products td.m-field::before { content: attr(data-label); display: block; position: static; width: auto; font-size: 11px;
        font-weight: 500; color: var(--m-muted); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    table.m-list-products td.m-field input, table.m-list-products td.m-field select { width: 100% !important; min-height: 36px; padding: 4px 6px;
        border: 1px solid #d5d0cc; border-radius: 6px; font-size: 15px; }
    table.m-list-products td.m-field i.fa-window-close { font-size: 20px !important; opacity: .35; }
}
@media (max-width: 991.98px) {
    /* product description on order rows: up to 2 lines under the order number (desktop styling kept it on one line) */
    table.m-list-orders td[data-label="Order ID / Product"] .order-id-col { display: block; -webkit-line-clamp: unset; overflow: visible; }
    table.m-list-orders td[data-label="Order ID / Product"] .order-id-col * { white-space: normal !important; }
    table.m-list-orders td[data-label="Order ID / Product"] .order-id-col > *:not(:first-child) { display: -webkit-box; -webkit-line-clamp: 2;
        -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
    #filters.m-filters-off { display: none !important; }
}
@media (max-width: 991.98px) {
    /* keep the right-hand column narrow (price / status / date) so the product text gets the width */
    table.m-list-orders tr { grid-template-areas: "chk pic main total" "chk pic main status" "chk pic buyer when" "chk pic method method"
                                                  "chk pic store store" "track track track track"; }
    table.m-list-orders td[data-label="Account"] { text-align: left !important; }
}
@media (max-width: 991.98px) {
    /* v2.1: price top-right beside the order number; product text gets the full width */
    table.m-list-orders tr { grid-template-columns: 26px 48px minmax(0, 1fr) auto;
        grid-template-areas: "chk pic main main" "chk pic buyer status" "chk pic method when" "chk pic store store" "track track track track"; }
    table.m-list-orders td[data-label="Total"] { position: absolute; top: 12px; right: 12px; }
    table.m-list-orders td[data-label="Order ID / Product"] a:first-child { padding-right: 70px; }
    table.m-list-orders td[data-label="Status"] { align-self: center; }
}
