/*
 * Unimart Responsive Compatibility Layer
 * Only responsive/layout safeguards. Does not alter theme functionality.
 */

/* Global overflow and media safeguards */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}
*, *::before, *::after {
    box-sizing: border-box;
}
img, svg, video, iframe {
    max-width: 100%;
}
img {
    height: auto;
}
iframe {
    border: 0;
}
table {
    max-width: 100%;
}

/* Prevent long content from forcing the viewport wider */
p, li, td, th, a, span, label, input, textarea, select, button {
    overflow-wrap: anywhere;
}

/* WordPress / Elementor content */
.wp-block-image img,
.elementor img,
.elementor-widget-image img,
.elementor-widget-video iframe,
.elementor-widget-html iframe {
    max-width: 100%;
}
.elementor-container,
.elementor-widget-container {
    max-width: 100%;
}
.elementor-section,
.elementor-section-boxed > .elementor-container {
    max-width: 100%;
}

/* WooCommerce */
.woocommerce img,
.woocommerce-page img {
    max-width: 100%;
    height: auto;
}
.woocommerce ul.products,
.woocommerce-page ul.products {
    width: 100%;
}
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    max-width: 100%;
}
.woocommerce div.product div.images img {
    width: 100%;
    height: auto;
}
.woocommerce .quantity .qty {
    max-width: 100%;
}
.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea,
.woocommerce form .form-row select,
.woocommerce form .form-row .select2-container {
    max-width: 100%;
}
.woocommerce table.shop_table {
    width: 100%;
}

/* Medium screens */
@media (max-width: 1199.98px) {
    .container,
    .container-fluid {
        max-width: 100%;
    }

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

    .rbt-header-wrapper .mainmenu-nav,
    .rbt-header-wrapper .mainmenu {
        max-width: 100%;
    }

    .rbt-header-wrapper .header-right {
        min-width: 0;
    }

    .rbt-header-wrapper .header-right > * {
        min-width: 0;
    }

    .rbt-single-product .product-thumb,
    .rbt-single-product .product-thumbnail {
        max-width: 100%;
    }
}

/* Tablets */
@media (max-width: 991.98px) {
    .container,
    .container-sm,
    .container-md {
        width: 100%;
        max-width: 100%;
    }

    .row {
        margin-left: calc(var(--bs-gutter-x, 1.5rem) * -.5);
        margin-right: calc(var(--bs-gutter-x, 1.5rem) * -.5);
    }

    /* Header/search areas */
    .rbt-header-wrapper .header-left,
    .rbt-header-wrapper .header-right {
        min-width: 0;
        max-width: 100%;
    }

    .rbt-header-wrapper .header-right {
        flex-wrap: wrap;
    }

    /* Grids remain inside the viewport */
    .rbt-product-grid,
    .product-grid,
    .products,
    .row {
        max-width: 100%;
    }

    /* Large flex children must be allowed to shrink */
    .rbt-header-wrapper [class*="col-"],
    .rbt-header-wrapper .header-left,
    .rbt-header-wrapper .header-right,
    .rbt-header-wrapper .header-search,
    .rbt-header-wrapper form {
        min-width: 0;
    }

    /* Tables can scroll instead of breaking the page */
    .woocommerce table.shop_table_responsive,
    .woocommerce-page table.shop_table_responsive {
        width: 100%;
    }

    .table-responsive {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Popups/modals */
    .modal-dialog,
    .mfp-content {
        max-width: calc(100% - 30px);
    }
}

/* Phones */
@media (max-width: 767.98px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .container,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl,
    .container-xxl,
    .container-fluid {
        width: 100%;
        max-width: 100%;
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Prevent fixed desktop dimensions from creating horizontal scroll */
    .rbt-header-wrapper,
    .rbt-main-wrapper,
    .rbt-footer-wrapper,
    .rbt-section,
    .elementor-section {
        max-width: 100%;
        overflow-x: clip;
    }

    /* Typography scales without changing desktop design */
    h1 {
        font-size: clamp(28px, 7vw, 42px);
        line-height: 1.15;
    }
    h2 {
        font-size: clamp(24px, 6vw, 36px);
        line-height: 1.2;
    }
    h3 {
        font-size: clamp(21px, 5.2vw, 30px);
        line-height: 1.25;
    }

    /* Header elements */
    .rbt-header-wrapper .header-right {
        width: 100%;
    }

    .rbt-header-wrapper .mainmenu-nav,
    .rbt-header-wrapper .mainmenu {
        max-width: 100%;
    }

    /* Images/cards */
    .rbt-card,
    .rbt-product-card,
    .rbt-single-product,
    .woocommerce ul.products li.product,
    .woocommerce-page ul.products li.product {
        max-width: 100%;
    }

    /* Buttons and controls */
    .rbt-btn,
    button,
    input[type="submit"],
    input[type="button"],
    .woocommerce a.button,
    .woocommerce button.button,
    .woocommerce input.button {
        max-width: 100%;
    }

    /* Forms */
    .rbt-form-group,
    .form-group,
    .woocommerce form .form-row {
        max-width: 100%;
    }

    .woocommerce form .form-row-first,
    .woocommerce form .form-row-last {
        width: 100%;
        float: none;
    }

    /* Product/cart tables */
    .woocommerce table.shop_table,
    .woocommerce-page table.shop_table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Avoid oversized popups */
    .modal-dialog,
    .mfp-content,
    .fancybox-content {
        width: auto;
        max-width: calc(100vw - 24px);
        margin-left: auto;
        margin-right: auto;
    }

    /* Long URLs / code / embeds */
    pre,
    code {
        max-width: 100%;
        white-space: pre-wrap;
        word-break: break-word;
    }

    /* WooCommerce notices */
    .woocommerce-notices-wrapper,
    .woocommerce-message,
    .woocommerce-info,
    .woocommerce-error {
        max-width: 100%;
    }
}

/* Small phones */
@media (max-width: 575.98px) {
    .container,
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

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

    .rbt-header-wrapper .header-right {
        gap: 8px;
    }

    .woocommerce .quantity .qty {
        width: auto;
        min-width: 70px;
    }

    .woocommerce ul.products[class*="columns-"] li.product,
    .woocommerce-page ul.products[class*="columns-"] li.product {
        width: 100%;
        margin-right: 0;
    }

    /* Make common two-column form layouts single-column on narrow screens */
    .woocommerce form .form-row-wide,
    .woocommerce form .form-row-first,
    .woocommerce form .form-row-last {
        width: 100%;
        float: none;
        clear: both;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .container,
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .rbt-btn,
    .woocommerce a.button,
    .woocommerce button.button,
    .woocommerce input.button {
        white-space: normal;
    }
}
