/* ==========================================================================
   IDT POS — mobile enhancements
   1) Bottom navigation bar (phones only)
   2) Add Sale / POS product table -> readable cards on phones
   Loaded after the other idtpos-*.css. Everything here is gated to small
   screens, so tablet and desktop are untouched.
   ========================================================================== */

/* Hidden by default; shown only on phones */
.idt-bottom-nav {
    display: none;
}

@media (max-width: 767px) {

    /* ----------------------------------------------------------------------
       0) HEADER USER MENU — the long name wrapped and clipped off the right
       edge. Hide the name on phones and show a compact user icon instead, so
       the menu fits and the dropdown still works.
       ---------------------------------------------------------------------- */
    .main-header .navbar-custom-menu .user-menu > .dropdown-toggle > span {
        display: none !important;
    }
    .main-header .navbar-custom-menu .user-menu > .dropdown-toggle {
        padding: 0 12px !important;
        display: flex !important;
        align-items: center;
        height: 50px;
    }
    /* If a profile photo exists, keep it compact; the blade adds a stand-in icon otherwise */
    .main-header .navbar-custom-menu .user-menu > .dropdown-toggle > img.user-image {
        margin: 0 !important;
        width: 30px !important;
        height: 30px !important;
    }
    .main-header .navbar-custom-menu .user-menu > .dropdown-toggle > .idt-user-fallback {
        font-size: 24px;
        color: #ffffff;
        line-height: 1;
    }

    /* ----------------------------------------------------------------------
       1) BOTTOM NAV
       ---------------------------------------------------------------------- */
    .idt-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: flex-end;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: 58px;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.08);
        z-index: 1030;
        padding: 4px 4px 6px;
    }
    .idt-bn-item {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: #64748b;
        font-size: 10px;
        line-height: 1.1;
        text-decoration: none;
        padding: 6px 2px;
    }
    .idt-bn-item i {
        font-size: 17px;
    }
    .idt-bn-item span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .idt-bn-item:active,
    .idt-bn-item:focus,
    .idt-bn-item:hover {
        color: #2563eb;
        text-decoration: none;
    }

    /* Centre Home raised into a circle */
    .idt-bn-home {
        position: relative;
    }
    .idt-bn-home .idt-bn-home-circle {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: -26px;
        box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
        border: 3px solid #ffffff;
    }
    .idt-bn-home .idt-bn-home-circle i {
        font-size: 20px;
    }
    .idt-bn-home span:not(.idt-bn-home-circle) {
        margin-top: 2px;
        color: #2563eb;
        font-weight: 600;
    }

    /* Keep page content clear of the fixed bar */
    .content-wrapper {
        padding-bottom: 70px !important;
    }

    /* ----------------------------------------------------------------------
       2) ADD SALE / POS product table as cards
       On phones the wide product-entry table overflows; stack each row's
       cells into a labelled card. The cell's data-label (already emitted by
       the app) becomes the field name.
       ---------------------------------------------------------------------- */
    #pos_table.table-responsive,
    .pos_product_table_wrapper {
        overflow-x: visible !important;
    }

    table#pos_table thead,
    table.product_table thead {
        display: none;
    }
    table#pos_table,
    table#pos_table > tbody,
    table.product_table,
    table.product_table > tbody {
        display: block;
        width: 100%;
    }
    table#pos_table > tbody > tr.product_row,
    table.product_table > tbody > tr.product_row {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 8px 10px;
        margin-bottom: 10px;
        background: #ffffff;
        box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
        overflow: hidden;
    }
    table#pos_table > tbody > tr.product_row > td,
    table.product_table > tbody > tr.product_row > td {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
        border: 0 !important;
        border-bottom: 1px dashed #eef2f7 !important;
        padding: 6px 0 !important;
        text-align: left;
    }
    table#pos_table > tbody > tr.product_row > td:last-child,
    table.product_table > tbody > tr.product_row > td:last-child {
        border-bottom: 0 !important;
        justify-content: flex-end;
    }
    /* Field label from data-label — narrow, so the input sits close on the left */
    table#pos_table > tbody > tr.product_row > td[data-label]::before,
    table.product_table > tbody > tr.product_row > td[data-label]::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        color: #64748b;
        text-align: left;
        flex: 0 0 30%;
    }
    /* Inputs fill all the way to the right edge, right after the label */
    table#pos_table > tbody > tr.product_row > td[data-label] .form-control,
    table#pos_table > tbody > tr.product_row > td[data-label] input,
    table#pos_table > tbody > tr.product_row > td[data-label] .input-group,
    table#pos_table > tbody > tr.product_row > td[data-label] select,
    table.product_table > tbody > tr.product_row > td[data-label] .form-control,
    table.product_table > tbody > tr.product_row > td[data-label] input {
        flex: 1 1 auto;
        width: auto !important;
        max-width: none;
        box-sizing: border-box;
    }
    /* The per-line discount-type dropdown (Fixed / Percentage) gets its own full line */
    table#pos_table > tbody > tr.product_row > td[data-label] .row_discount_type {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-top: 6px !important;
    }
    /* Quantity cell: let it wrap so the unit dropdown drops to its own line
       instead of squeezing the stepper. */
    table#pos_table > tbody > tr.product_row > td[data-label] {
        flex-wrap: wrap;
    }
    /* Quantity stepper (- input +) stays inline with both buttons visible */
    table#pos_table > tbody > tr.product_row > td[data-label] .input-group.input-number {
        max-width: 60%;
        display: flex !important;
        flex-wrap: nowrap;
        flex: 0 0 auto;
    }
    table#pos_table > tbody > tr.product_row > td[data-label] .input-group.input-number .form-control {
        width: 56px !important;
        max-width: 64px;
        text-align: center;
        flex: 0 1 auto;
    }
    table#pos_table > tbody > tr.product_row > td[data-label] .input-group.input-number .input-group-btn {
        flex: 0 0 auto;
        width: auto !important;
    }
    /* The unit — dropdown or plain "Pieces" text — drops to its own full line
       under the stepper instead of crowding it. */
    table#pos_table > tbody > tr.product_row > td[data-label] select.sub_unit,
    table#pos_table > tbody > tr.product_row > td[data-label] .product-unit-label {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 6px 0 0 !important;
        text-align: left;
        color: #64748b;
        font-size: 12px;
    }
    /* The product name cell spans full width and wraps its extras (IMEI/lot) below */
    table#pos_table > tbody > tr.product_row > td.product_name_cell,
    table#pos_table > tbody > tr.product_row > td:first-child {
        display: block !important;
        text-align: left;
        font-weight: 600;
        border-bottom: 1px solid #eef2f7 !important;
        padding-bottom: 8px !important;
    }
    table#pos_table > tbody > tr.product_row > td:first-child .form-control,
    table#pos_table > tbody > tr.product_row > td:first-child input {
        width: 100% !important;
        max-width: 100%;
        margin-top: 6px;
    }
}
