/*
 * PLACENTRAL — responsive safety layer (mobile + tablet)
 *
 * Loaded after style.bundle.css / developer.css on every frontend layout.
 * Purpose: nothing may be wider than the screen. Content that is genuinely wide
 * (tables) scrolls inside its own box instead of pushing the whole page sideways.
 * Desktop (>= 992px) is not touched, except the harmless min-width/max-width guards.
 */

/* ── 1. Flex/grid children must be allowed to shrink ────────────────────────
   The classic cause of "page wider than the screen": a flex child whose
   min-width defaults to its content width. */
.app-wrapper,
.app-main,
.app-container,
.app-content,
.app-page,
.app-toolbar,
.card,
.card-body,
.card-header,
.modal-content,
.tab-content,
.row > [class*="col"] {
    min-width: 0;
}

/* Media never wider than its container (height is left as authored, so logos/icons
   that rely on a height attribute are not distorted). */
img,
video,
iframe,
canvas {
    max-width: 100%;
}

.card-body,
.modal-body,
.menu-title,
.form-label,
.text-gray-800,
.text-gray-900 {
    overflow-wrap: break-word;
}

/* ── 2. Tablet and below (< 992px) ───────────────────────────────────────── */
@media (max-width: 991.98px) {

    /* DataTables and plain tables: scroll inside the card, never the page */
    .dataTables_wrapper,
    .table-responsive,
    .card-body > .table,
    .card-body > form > .table {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Tables that have no .table-responsive / DataTables wrapper around them */
    *:not(.table-responsive):not(.dataTables_wrapper):not(.dataTables_scrollBody):not(.dataTables_scrollHead) > table.table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* DataTables length/filter/info/paginate rows wrap instead of overflowing */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none;
        text-align: left;
        max-width: 100%;
        flex-wrap: wrap;
    }

    .pagination {
        flex-wrap: wrap;
    }

    /* Toolbars, button groups and header action rows wrap */
    .card-toolbar,
    .card-header,
    .app-toolbar-container,
    .page-heading,
    .d-flex.justify-content-between.align-items-center {
        flex-wrap: wrap;
    }

    .card-toolbar,
    .card-header {
        gap: .5rem;
    }

    .card-header .card-title,
    .card-header .card-toolbar {
        max-width: 100%;
    }

    .btn {
        white-space: normal;
    }

    /* Form controls and Select2 never exceed their column */
    .form-control,
    .form-select,
    .select2-container,
    .select2-container--bootstrap5 {
        max-width: 100%;
    }

    .select2-container {
        width: 100% !important;
    }

    .select2-dropdown {
        max-width: calc(100vw - 1.5rem);
    }

    /* Modals use the screen width, not their desktop mw-* width */
    .modal-dialog {
        max-width: calc(100vw - 1rem);
        margin-left: auto;
        margin-right: auto;
    }

    .mw-300px, .mw-400px, .mw-450px, .mw-500px, .mw-550px, .mw-600px,
    .mw-650px, .mw-700px, .mw-750px, .mw-800px, .mw-850px, .mw-900px,
    .mw-950px, .mw-1000px {
        max-width: 100% !important;
    }

    /* Pre-formatted / long unbroken strings (emails, references, URLs) */
    pre,
    code {
        white-space: pre-wrap;
        word-break: break-word;
    }

    .row {
        --bs-gutter-x: 1rem;
    }

    .type-option-view {
        flex-wrap: wrap;
    }
}

/* ── 3. Phones (< 768px) ─────────────────────────────────────────────────── */
@media (max-width: 767.98px) {

    .app-container,
    .container-xxl,
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .card-body,
    .card-header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Oversized marketing / hero type */
    .captionHeadViewAccommodation h1,
    .captionHeadViewAccommodation h1 span {
        font-size: 30px;
        line-height: 38px;
    }

    .carousel-inner-css {
        min-height: 220px;
    }

    .carousel-item-css img {
        height: 220px;
    }

    /* Stack side-by-side action buttons and let them use the width */
    .card-footer .btn,
    .modal-footer .btn {
        flex: 1 1 auto;
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    /* Wide filter rows / inline forms stack */
    .form-inline,
    .d-flex.flex-row.gap-5 {
        flex-wrap: wrap;
    }

    /* Fixed-width utility classes used on filters, form fields and buttons (not on table
       cells — their min-widths are what keeps columns readable inside the scrolling table) */
    :not(th):not(td).w-125px, :not(th):not(td).w-175px, :not(th):not(td).w-200px,
    :not(th):not(td).w-250px, :not(th):not(td).w-275px {
        max-width: 100%;
    }

    :not(th):not(td).min-w-100px, :not(th):not(td).min-w-125px, :not(th):not(td).min-w-150px,
    :not(th):not(td).min-w-175px, :not(th):not(td).min-w-200px, :not(th):not(td).min-w-250px {
        min-width: 0 !important;
    }

    /* SweetAlert pop-ups */
    .swal2-popup {
        width: calc(100vw - 2rem) !important;
        max-width: 32rem;
    }
}
