/* ============================================================
   System-wide touch / tablet: tappable action icons & controls
   Applied when html/body has .ncs-touch (set by touch-friendly.js)
   Also uses (pointer: coarse) for CSS-only devices.
   ============================================================ */

/* Icons inside controls must not steal the tap — parent receives it */
@media (hover: none), (pointer: coarse) {
    html.ncs-touch a > i,
    html.ncs-touch a > .fa,
    html.ncs-touch a > .fas,
    html.ncs-touch a > .far,
    html.ncs-touch a > .glyphicon,
    html.ncs-touch button > i,
    html.ncs-touch .btn > i,
    html.ncs-touch .btn > .fa,
    html.ncs-touch .btn > .glyphicon,
    html.ncs-touch .tw-dw-btn > i,
    html.ncs-touch .tw-dw-btn > .fa,
    html.ncs-touch [role="button"] > i,
    html.ncs-touch .dropdown-toggle > i,
    html.ncs-touch .dropdown-toggle > .fa,
    html.ncs-touch .dropdown-menu > li > a > i,
    html.ncs-touch .dropdown-menu > li > a > .fa,
    html.ncs-touch .dropdown-menu > li > a > .glyphicon,
    a > i, a > .fa, a > .fas, a > .far, a > .glyphicon,
    button > i, .btn > i, .btn > .fa, .btn > .glyphicon,
    .tw-dw-btn > i, .tw-dw-btn > .fa,
    [role="button"] > i,
    .dropdown-toggle > i, .dropdown-toggle > .fa,
    .dropdown-menu > li > a > i,
    .dropdown-menu > li > a > .fa,
    .dropdown-menu > li > a > .glyphicon {
        pointer-events: none !important;
    }

    /* Minimum touch targets for table / toolbar actions */
    table .btn-xs,
    table .btn-group > .btn,
    table a.btn,
    table .tw-dw-btn,
    table .tw-dw-btn-xs,
    .dataTables_wrapper .btn-xs,
    .dataTables_wrapper .btn-group > .btn,
    .dataTables_wrapper .tw-dw-btn,
    .dataTables_wrapper .tw-dw-btn-xs,
    .btn-group .dropdown-toggle,
    a.edit_contact_button,
    a.btn-modal,
    .box-tools .btn-xs,
    .box-tools .tw-dw-btn-xs {
        min-height: 40px !important;
        min-width: 40px !important;
        padding: 8px 10px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.08);
    }

    /* Dropdown menu rows — larger tap rows */
    .dropdown-menu > li > a {
        min-height: 40px !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        touch-action: manipulation !important;
    }

    /* iCheck — enlarge hit area (pencil/check style boxes) */
    .icheckbox_square-blue,
    .iradio_square-blue,
    .icheckbox_square-green,
    .iradio_square-green {
        transform: scale(1.35);
        transform-origin: center center;
        margin: 8px !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
    }
    .icheckbox_square-blue ins,
    .iradio_square-blue ins,
    .icheckbox_square-green ins,
    .iradio_square-green ins {
        cursor: pointer !important;
    }

    /* Labels wrapping checkboxes */
    label {
        touch-action: manipulation;
    }

    /* Prevent scroll container from eating the first tap on actions */
    .table-responsive,
    .dataTables_scrollBody {
        -webkit-overflow-scrolling: touch;
    }
    .dataTables_wrapper .btn-group,
    .dataTables_wrapper td .btn,
    .dataTables_wrapper td .tw-dw-btn {
        touch-action: manipulation !important;
        position: relative;
        z-index: 2;
    }
}

/* Always-on helpers (mouse + touch) */
a[href].btn,
button.btn,
.tw-dw-btn,
.dropdown-toggle {
    touch-action: manipulation;
}

/* ============================================================
   Business settings — mobile responsive layout
   ============================================================ */
@media (max-width: 767px) {
    section.content .pos-tab-container {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Stack: horizontal scrollable tabs on top, content full width */
    .pos-tab-container > .row,
    .pos-tab-container {
        display: block !important;
    }

    div.pos-tab-menu,
    .pos-tab-container .pos-tab-menu,
    .pos-tab-container > .col-xs-2,
    .pos-tab-container .col-lg-2,
    .pos-tab-container .col-md-2,
    .pos-tab-container .col-sm-2,
    .pos-tab-container .col-xs-2 {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        padding: 0 !important;
        margin-bottom: 12px !important;
    }

    div.pos-tab,
    .pos-tab-container .pos-tab,
    .pos-tab-container > .col-xs-10,
    .pos-tab-container .col-lg-10,
    .pos-tab-container .col-md-10,
    .pos-tab-container .col-sm-10,
    .pos-tab-container .col-xs-10 {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        padding: 0 8px 12px !important;
    }

    div.pos-tab-menu div.list-group {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 6px !important;
        padding: 8px !important;
        margin: 0 !important;
        border: none !important;
    }

    div.pos-tab-menu div.list-group > a {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        border-radius: 8px !important;
        margin: 0 !important;
        padding: 10px 14px !important;
        min-height: 42px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
    }

    div.pos-tab-menu div.list-group > a.active:after {
        display: none !important;
    }

    div.pos-tab-content {
        padding-left: 8px !important;
        padding-right: 8px !important;
        padding-top: 12px !important;
    }

    /* Forms inside settings: full-width fields */
    .pos-tab-content .form-group .col-sm-4,
    .pos-tab-content .form-group .col-sm-6,
    .pos-tab-content .form-group .col-sm-8,
    .pos-tab-content .form-group .col-md-4,
    .pos-tab-content .form-group .col-md-6,
    .pos-tab-content .form-group .col-md-8,
    .pos-tab-content .col-sm-4,
    .pos-tab-content .col-sm-6,
    .pos-tab-content .col-sm-8,
    .pos-tab-content .col-md-4,
    .pos-tab-content .col-md-6,
    .pos-tab-content .col-md-8 {
        width: 100% !important;
        float: none !important;
    }

    .pos-tab-content .form-control,
    .pos-tab-content select.form-control {
        max-width: 100% !important;
        width: 100% !important;
    }

    #save_settings_btn {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 48px !important;
    }

    section.content-header h1 {
        font-size: 1.35rem !important;
    }
}
