/* Application-level mobile/tablet fixes. Keep vendor styles and desktop layouts intact. */
@media (max-width: 1199.98px), (hover: none) and (pointer: coarse) {
    .pcoded-content .row > [class*="col"],
    .pcoded-content .card,
    .pcoded-content .card-body,
    .pcoded-content .card-block {
        min-width: 0;
    }

    /* Legacy list toolbars use two unqualified .col elements and percentage widths. */
    .pcoded-content .justify-contact-between {
        row-gap: .5rem;
    }
    .pcoded-content .justify-contact-between > .col {
        flex: 1 1 320px;
        max-width: 100%;
        text-align: left !important;
    }
    .pcoded-content .justify-contact-between .my-form-control {
        width: 100%;
        max-width: 100%;
        margin-right: 0;
        margin-bottom: .5rem;
    }
    .pcoded-content .justify-contact-between .input-group {
        float: none !important;
        width: 100% !important;
    }
    .pcoded-content .justify-contact-between .btn-group {
        flex-wrap: wrap;
        max-width: 100%;
        gap: .5rem;
    }
    .pcoded-content .justify-contact-between .btn-group > .btn {
        flex: 0 1 auto;
        max-width: 100%;
        margin: 0 !important;
        border-radius: .25rem !important;
        white-space: normal;
    }

    .pcoded-content .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-padding-inline: .5rem;
    }
    .pcoded-content .nav-tabs > .nav-item {
        flex: 0 0 auto;
    }
    .pcoded-content .nav-tabs .nav-link {
        min-height: 44px;
        white-space: nowrap;
    }

    /* Only the table scrolls, not its search, page-size selector or pagination. */
    .table-responsive.sterp-datatable-host {
        overflow: visible;
    }
    .sterp-table-scroll {
        width: 100%;
        max-width: 100%;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    .sterp-table-scroll:focus-visible {
        outline: 2px solid #4680ff;
        outline-offset: 2px;
    }
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        max-width: 100%;
    }
    .dataTables_wrapper .dataTables_length select {
        min-width: 5rem;
        min-height: 40px;
    }
    .dataTables_wrapper > .row:first-child,
    .dataTables_wrapper > .row:last-child {
        row-gap: .5rem;
    }
    .dataTables_wrapper > .row:first-child > [class*="col"],
    .dataTables_wrapper > .row:last-child > [class*="col"] {
        flex: 1 1 240px;
        width: auto;
        max-width: 100%;
        min-width: 0;
    }
    .dataTables_wrapper .dataTables_filter label {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        max-width: 100%;
    }
    div.dataTables_wrapper div.dataTables_filter input {
        width: 100%;
        min-width: 0;
        max-width: 20rem;
    }
    .dataTables_wrapper .dataTables_paginate .pagination {
        flex-wrap: wrap;
        gap: .25rem;
    }
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0;
        margin: 0;
        border: 0;
    }
    .dataTables_wrapper .dataTables_paginate .page-link {
        min-width: 40px;
        min-height: 40px;
        padding: .5rem .65rem;
        line-height: 1.4;
        border-radius: .25rem;
    }
    .sterp-table-menu {
        max-width: calc(100vw - 16px);
        max-height: min(65vh, 28rem);
        overflow: auto;
        overscroll-behavior: contain;
    }
    .pcoded-content .dropdown-menu .dropdown-item,
    .sterp-table-menu .dropdown-item {
        min-height: 40px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .pcoded-content .select2-container {
        max-width: 100%;
    }
    .pcoded-content .select2-selection__rendered {
        overflow-wrap: anywhere;
    }
    .pcoded-content .image-list-container {
        min-width: 0;
        max-width: 100%;
    }
    .pcoded-content .image-list-container .tile {
        width: calc(50% - 10px);
        max-width: 100%;
        margin: 10px 5px 0;
        padding: 12px;
        overflow-wrap: anywhere;
    }

    /* Large preview dialogs must fit even when callers supply a fixed pixel/em width. */
    .swal2-container {
        padding: .5rem;
    }
    .swal2-container .swal2-popup {
        min-width: 0;
        max-width: 100%;
    }
    .swal2-container .swal2-html-container {
        min-width: 0;
        overflow-wrap: anywhere;
    }
    .swal2-container .swal2-actions {
        flex-wrap: wrap;
        max-width: 100%;
    }
    .modal-dialog {
        max-width: calc(100% - 1rem);
    }
    .modal-content {
        max-height: calc(100vh - 3.5rem);
        max-height: calc(100dvh - 3.5rem);
    }
    .modal-body {
        overflow: auto;
        overscroll-behavior: contain;
    }
    .modal-header, .modal-footer {
        flex-shrink: 0;
    }
    .modal-title {
        min-width: 0;
        overflow-wrap: anywhere;
    }
    .offcanvas.offcanvas-end {
        max-width: 100%;
    }
}

@media (max-width: 767.98px) {
    .pcoded-content {
        padding: 16px 12px;
    }
    .pcoded-content .card .card-body,
    .pcoded-content .card .card-block,
    .pcoded-content .card .card-header {
        padding: 16px;
    }
    .pcoded-content .card .card .card-body,
    .pcoded-content .card .card .card-block {
        padding: 12px;
    }
    .pcoded-content .card-header h5 {
        max-width: 100%;
        overflow-wrap: anywhere;
    }
    .pcoded-content .btn,
    .modal .btn,
    .swal2-popup .swal2-styled {
        min-height: 40px;
    }
    /* Prevent iOS input-focus zoom without disabling user zoom. */
    .pcoded-content .form-control,
    .pcoded-content .form-select,
    .pcoded-content .my-form-control,
    .auth-content .form-control,
    .modal .form-control,
    .swal2-popup .form-control,
    .swal2-popup .swal2-input,
    .swal2-popup .swal2-textarea,
    .select2-container .select2-search__field {
        font-size: 16px;
    }
    .dataTables_wrapper .dataTables_filter label {
        justify-content: center;
    }
    .dataTables_wrapper .dataTables_paginate .pagination {
        justify-content: center !important;
    }
    .sterp-product-editor .form-group.row > .col-sm-10,
    .sterp-product-editor .form-group.row > .col-form-label {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
    }
    .sterp-product-editor .input-group,
    .swal2-popup .input-group {
        gap: .5rem;
    }
    .sterp-product-editor .input-group > .form-control,
    .swal2-popup .input-group > .form-control {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        border-radius: .25rem !important;
    }
    .sterp-product-editor .input-group-btn {
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
        max-width: 100%;
    }
    .sterp-product-editor .input-group .btn,
    .swal2-popup .input-group .btn {
        flex: 0 1 auto;
        max-width: 100%;
        margin: 0 !important;
        border-radius: .25rem !important;
        white-space: normal;
    }
    .pcoded-content .image-list-container .tile {
        width: 100%;
        margin-inline: 0;
    }
    .swal2-container .swal2-title {
        padding: .75rem 1rem 0;
        font-size: 1.25rem;
    }
    .swal2-container .swal2-html-container {
        margin: 1rem;
        font-size: 1rem;
    }
    .modal-dialog {
        margin: .5rem auto;
    }
    .modal-content {
        max-height: calc(100vh - 1rem);
        max-height: calc(100dvh - 1rem);
    }
    .modal-header, .modal-body, .modal-footer {
        padding: 1rem;
    }
}

@media (max-width: 991.98px) {
    .pcoded-header .mobile-menu, .pcoded-header .mob-toggler {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    /* Keep the close toggle reachable above the theme's transparent sidebar backdrop. */
    .pcoded-header #mobile-collapse {
        z-index: 2;
    }
}

@media (max-width: 575.98px) {
    .product-filter-card .product-range-filter {
        display: grid;
        grid-template-columns: max-content minmax(0, 1fr);
        row-gap: .5rem;
    }
    .product-filter-card .product-range-filter > .form-control {
        width: 100%;
        border-radius: 0 .25rem .25rem 0;
    }
    .product-filter-card .product-range-filter > .input-group-text {
        margin-left: 0;
        border-radius: .25rem 0 0 .25rem;
    }
    #product-stock-filter, #product-stock-quantity {
        flex-basis: 100%;
        width: 100%;
        margin: 0;
        border-radius: .25rem;
    }
    #product-stock-quantity {
        margin-top: .5rem;
    }
}

/* On phones the two-calendar picker otherwise puts Apply below the viewport. */
@media (max-width: 767.98px), (max-width: 991.98px) and (max-height: 500px) {
    .daterangepicker {
        position: fixed;
        top: auto !important;
        bottom: .5rem !important;
        left: .5rem !important;
        right: .5rem !important;
        width: auto;
        max-width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
        max-height: calc(100dvh - 1rem);
        margin: 0;
        overflow: auto;
        overscroll-behavior: contain;
    }
    .daterangepicker::before, .daterangepicker::after {
        display: none;
    }
    .daterangepicker .ranges, .daterangepicker .drp-calendar {
        float: none !important;
        width: 100%;
        max-width: 100%;
        margin-inline: 0 !important;
    }
    .daterangepicker .ranges ul {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }
    .daterangepicker .ranges li {
        min-height: 40px;
        display: flex;
        align-items: center;
    }
    .daterangepicker .calendar-table td, .daterangepicker .calendar-table th {
        height: 36px;
        min-width: 0;
    }
    .daterangepicker .drp-buttons {
        position: sticky;
        bottom: 0;
        z-index: 1;
        background: #fff;
        white-space: normal;
    }
    .daterangepicker .drp-buttons .btn {
        min-height: 40px;
        margin-top: .5rem;
    }
}
