/* =========================================================
   Berry theme – responsive enhancements
   Loaded AFTER responsive.css to patch gaps across devices.
   ========================================================= */

/* --- Global safety nets ------------------------------------------------- */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img, svg, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* Any generic table becomes horizontally scrollable on small screens */
@media (max-width: 767px) {
    .page-body table:not(.cart):not(.data-table) {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .page-body .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* --- Extra-large desktops (>= 1400px) ---------------------------------- */
@media (min-width: 1400px) {
    .master-wrapper-content,
    .header,
    .footer,
    .header-lower,
    .header-upper {
        max-width: 1320px;
        margin-left: auto;
        margin-right: auto;
    }

    .product-grid .item-box {
        width: calc(25% - 20px);
    }

    #anywhere-slider-1 .slider-caption h2 {
        font-size: 56px;
    }
}

/* --- Standard desktop tweaks (992–1199px) ------------------------------ */
@media (min-width: 992px) and (max-width: 1199px) {
    .product-grid .item-box {
        width: calc(33.33% - 20px);
    }

    .header-upper .search-box-text {
        width: 200px;
    }

    .header-logo {
        max-width: 200px;
    }
}

/* --- Tablets (768–991px) ----------------------------------------------- */
@media (min-width: 768px) and (max-width: 991px) {
    .product-grid .item-box {
        width: calc(33.33% - 16px);
    }

    .product-essential .gallery,
    .product-essential .overview {
        width: 100%;
        float: none;
    }

    .product-details-page .product-variant-line {
        display: block;
    }

    .ui-tabs .ui-tabs-nav li {
        display: block;
        width: 100%;
    }

    .header-lower .search-box.store-search-box {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .header-lower .search-box-text {
        width: 100%;
    }
}

/* --- Phones (<= 767px) ------------------------------------------------- */
@media (max-width: 767px) {
    /* Full-width search inside collapsed header */
    .header-lower .search-box.store-search-box,
    .search-box.store-search-box {
        width: 100%;
        max-width: none;
        min-width: 0;
        display: block;
    }

    .header-lower .search-box-text,
    .search-box .search-box-text {
        width: 100%;
        box-sizing: border-box;
    }

    /* Header row wraps cleanly */
    .header-upper {
        flex-wrap: wrap;
        justify-content: space-between;
        row-gap: 10px;
        padding: 10px;
    }

    .header-upper .header-links-wrapper {
        flex: 0 0 auto;
    }

    /* Accessible touch targets */
    .header-links a,
    .footer-block a,
    .top-menu a,
    .buttons .button-1,
    .buttons .button-2,
    .add-to-cart-button,
    .add-to-wishlist-button,
    .search-box-button {
        min-height: 44px;
        line-height: 1.3;
        display: inline-flex;
        align-items: center;
    }

    /* Forms – prevent iOS zoom on focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px;
    }

    /* Breadcrumb wraps */
    .breadcrumb ul,
    .breadcrumb {
        flex-wrap: wrap;
    }

    /* Order summary / totals stack cleanly */
    .order-summary-content .cart-footer {
        display: block;
    }

    .order-summary-content .cart-footer .totals,
    .order-summary-content .cart-footer .cart-collaterals {
        width: 100%;
        margin: 0 0 15px;
    }

    /* Product details: stack picture + info, full-width buttons */
    .product-essential .gallery,
    .product-essential .overview {
        width: 100%;
        float: none;
        margin: 0 0 20px;
    }

    .product-essential .overview-buttons .add-to-cart,
    .product-essential .overview-buttons .add-to-wishlist {
        width: 100%;
    }

    .product-essential .overview-buttons .add-to-cart-button,
    .product-essential .overview-buttons .add-to-wishlist-button {
        width: 100%;
    }

    /* Footer stacks, social icons centered */
    .footer-upper .footer-block {
        width: 100%;
        margin: 0 0 10px;
    }

    .footer-lower .footer-info,
    .footer-lower .footer-disclaimer,
    .footer-lower .footer-powered-by,
    .footer-lower .footer-store-theme,
    .footer-lower .accepted-payment-methods {
        width: 100%;
        text-align: center;
        margin: 5px 0;
    }

    /* Flyout cart fits viewport */
    .flyout-cart {
        width: 100vw;
        max-width: 100vw;
        left: 0;
        right: 0;
    }

    /* Admin bar / theme controls wrap */
    .admin-header-links,
    .header-theme-controls {
        flex-wrap: wrap;
    }
}

/* --- Small phones (<= 480px) ------------------------------------------- */
@media (max-width: 480px) {
    .product-grid .item-box,
    .category-page .product-grid .item-box,
    .sub-category-grid .item-box,
    .manufacturer-grid .item-box,
    .vendor-grid .item-box {
        width: calc(100% - 16px);
        margin: 10px 8px;
    }

    .home-page-product-grid .title,
    .related-products-grid .title,
    .featured-product-grid .title,
    .ocarousel-grid .title {
        font-size: 20px;
    }

    .page-title h1,
    .page-title h2 {
        font-size: 22px;
        line-height: 1.3;
    }
}

/* --- Extra-small phones (<= 360px) ------------------------------------- */
@media (max-width: 360px) {
    .header-logo {
        max-width: 110px;
    }

    .header-upper .header-links li {
        padding: 0 4px;
        font-size: 12px;
    }

    .admin-header-links a {
        font-size: 12px;
    }

    .cart-qty,
    .flyout-cart-qty {
        font-size: 12px;
    }

    .buttons .button-1,
    .buttons .button-2 {
        padding: 8px 10px;
        font-size: 13px;
    }
}

/* --- Landscape phones: tighter vertical rhythm ------------------------- */
@media (max-width: 900px) and (orientation: landscape) {
    .header-upper {
        min-height: 56px;
    }

    .anywhere-slider-bg .owl-item .slider-caption {
        padding-top: 15px;
        padding-bottom: 15px;
    }
}

/* --- Print ------------------------------------------------------------- */
@media print {
    .header, .footer, .header-menu, .flyout-cart, .admin-header-links,
    .menu-toggle, .side-2, .breadcrumb {
        display: none !important;
    }

    .master-wrapper-content,
    .page-body {
        width: 100% !important;
        margin: 0 !important;
    }
}

/* ----- Toggleable header search box ----- */
.search-icon-wrapper {
    position: relative;
}

/* Collapsed state: panel absolutely positioned under the header, animated */
.search-box.store-search-box {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    z-index: 1050;
    width: 320px;
    max-width: 90vw;
    padding: 10px;
    background: #fff;
    border: 1px solid #e5e5e5;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    border-radius: 4px;

    /* animation */
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.search-box.store-search-box.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Keep [hidden] semantics but allow transition before it actually hides */
.search-box.store-search-box[hidden] {
    display: block;
}
.search-box.store-search-box[hidden]:not(.open) {
    display: none;
}

.search-box.store-search-box .search-box-text {
    width: 100%;
    height: 38px;
    box-sizing: border-box;
    border: 1px solid #dcdcdc;
    border-radius: 3px;
    padding: 0 10px;
    display: block;
}

/* On phones: full-width bar spanning the header row */
@media (max-width: 767px) {
    .search-box.store-search-box {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        padding: 12px 14px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}