/* Unified styling for resolutions < 1200px based on desktop (>1200px) layout */

@media (max-width: 1199px) {
    /* 1. Product Boxes Unification */
    .tvproduct-wrapper {
        border: none !important;
        box-shadow: none;
    }

    .tvproduct-wrapper:hover {
        box-shadow: 2px 8px 38px 2px rgba(0, 0, 0, 0.07) !important;
    }

    /* Reserve space for 3 lines of title like on desktop */
    .tvproduct-name.product-title a h6 {
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        font-size: 14px !important;
        line-height: 1.4 !important;
        min-height: 58.8px !important; /* 3 lines × 14px × 1.4 = 58.8px */
        text-align: center;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Unify price and cart inline layout */
    .tv-price-cart-inline-wrapper {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    .tv-price-cart-inline-wrapper .tv-product-price.tvproduct-name-price-wrapper {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        line-height: 1 !important;
        text-align: right;
    }

    .tvproduct-cart-btn-info {
        flex: 0 0 auto !important;
    }

    /* Red CTA button with white icon for all sizes < 1200px */
    .tvproduct-cart-btn-info .tvproduct-add-to-cart {
        width: 70px !important;
        height: 38px !important;
        min-width: 70px !important;
        background-color: #CF0000 !important;
        border-radius: 5px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .tvproduct-cart-btn-info .tvproduct-add-to-cart svg path {
        stroke: #ffffff !important;
        fill: none !important;
    }

    /* Hide hover buttons by default for < 1200px to keep layout clean */
    .tvproduct-wrapper.grid .tvproduct-hover-btn, 
    .tvproduct-wrapper.grid-2 .tvproduct-hover-btn {
        display: none !important;
    }

    /* Show color pickers if present */
    .tvproduct-color {
        opacity: 1 !important;
        position: relative !important;
        bottom: 0 !important;
        margin-top: 10px;
    }

    /* 2. Search Bar Unification */
    body #header .tvsearch-header-display-wrappper form {
        height: 45px !important;
        display: flex !important;
        align-items: center !important;
        border-radius: 5px !important;
        max-width: 435px !important;
        margin: auto !important;
        border: 1px solid #e4e4e4 !important;
    }

    body #header .tvsearch-header-display-wrappper form input[type="text"] {
        height: 100% !important;
        border: none !important;
        background: transparent !important;
        padding-left: 15px !important;
    }

    .tvheader-top-search-wrapper {
        padding: 0 15px !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
    }

    /* 3. Homepage Categories Slider Unification */
    .tvcategory-slider-info-box {
        border: none !important;
        background: transparent !important;
        margin-inline: 0px !important;
    }

    .tvcategory-slider-wrapper-info:hover .tvcategory-slider-info-box {
        background: none !important;
    }

    .tvcategory-slider-wrapper-info:hover .tvcategory-slider-info-box .tvcategory-slider-info-title {
        color: #cf0000 !important;
    }

    .tvcategory-img-block {
        margin-bottom: 8px !important;
    }

    /* 4. Global Hover override for compare/wishlist/quickview icons - all breakpoints < 1200px */
    .tvproduct-wrapper .tvcompare-wrapper:hover .tvproduct-compare-icon,
    .tvproduct-wrapper .tvproduct-wishlist:hover .tvproduct-wishlist-icon,
    .tvproduct-wrapper .tvproduct-quick-btn:hover .tvproduct-quick-icon,
    .tv-product-catalog-btn .tvcompare-wrapper:hover .tvproduct-compare-icon,
    .tv-product-catalog-btn .tvproduct-wishlist:hover .tvproduct-wishlist-icon,
    .tv-product-catalog-btn .tvproduct-quick-btn:hover .tvproduct-quick-icon,
    .tvcatlog-button-wrapper .tvcompare-wrapper:hover .tvproduct-compare-icon,
    .tvcatlog-button-wrapper .tvproduct-wishlist:hover .tvproduct-wishlist-icon,
    .tvcatlog-button-wrapper .tvproduct-quick-btn:hover .tvproduct-quick-icon {
        background-color: #CF0000 !important;
        border-color: #CF0000 !important;
    }

    .tvproduct-wrapper .tvcompare-wrapper:hover .tvproduct-compare-icon svg path,
    .tvproduct-wrapper .tvproduct-wishlist:hover .tvproduct-wishlist-icon svg path,
    .tv-product-catalog-btn .tvcompare-wrapper:hover .tvproduct-compare-icon svg path,
    .tv-product-catalog-btn .tvproduct-wishlist:hover .tvproduct-wishlist-icon svg path,
    .tvcatlog-button-wrapper .tvcompare-wrapper:hover .tvproduct-compare-icon svg path,
    .tvcatlog-button-wrapper .tvproduct-wishlist:hover .tvproduct-wishlist-icon svg path {
        fill: #ffffff !important;
    }

    .tvproduct-wrapper .tvproduct-quick-btn:hover .tvproduct-quick-icon svg path,
    .tv-product-catalog-btn .tvproduct-quick-btn:hover .tvproduct-quick-icon svg path,
    .tvcatlog-button-wrapper .tvproduct-quick-btn:hover .tvproduct-quick-icon svg path {
        fill: none !important;
        stroke: #ffffff !important;
    }
}

/* 5. Show compare and wishlist buttons below 1024px */
@media (max-width: 1023px) {
    /* Hide quick view below 768px as requested */
    @media (max-width: 768px) {
        .tvproduct-quick-btn {
            display: none !important;
        }

        /* Ensure cart, compare, and wishlist are in one line - Agresive mode */
        .tvcatlog-button-wrapper {
            display: flex !important;
            flex-direction: row !important;
            flex-wrap: nowrap !important;
            justify-content: center !important;
            align-items: center !important;
            gap: 10px !important;
            width: 100% !important;
            margin-top: 10px !important;
        }

        /* Always hide quick view as requested */
        .tvcatlog-button-wrapper .tvproduct-quick-btn {
            display: none !important;
        }

        /* Target only the remaining three buttons containers to force fixed square size */
        .tvcatlog-button-wrapper .tvproduct-cart-btn,
        .tvcatlog-button-wrapper .tvcompare-wrapper,
        .tvcatlog-button-wrapper .tvproduct-wishlist {
            display: block !important;
            flex: 0 0 auto !important;
            width: 40px !important;
            min-width: 40px !important;
            height: 40px !important;
            margin: 0 !important;
            padding: 0 !important;
        }

        /* Cleanup form and cart button specifically */
        .tvcatlog-button-wrapper .tvproduct-cart-btn form,
        .tvcatlog-button-wrapper .tvproduct-cart-btn .tvproduct-add-to-cart {
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            width: 40px !important;
            height: 40px !important;
            padding: 0 !important;
            margin: 0 !important;
            min-width: unset !important;
            border-radius: 5px !important;
            background-color: #CF0000 !important;
            border: none !important;
        }

        /* Ensure compare and wishlist icons fill the 40x40 area */
        .tvcatlog-button-wrapper .tvproduct-wishlist-icon,
        .tvcatlog-button-wrapper .tvproduct-compare-icon {
            width: 40px !important;
            height: 40px !important;
            padding: 0 !important;
            margin: 0 !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            border-radius: 5px !important;
            border: 1px solid #e4e4e4 !important;
            background-color: #ffffff !important;
        }

        /* Hover states for compare and wishlist in catalog view */
        .tvcatlog-button-wrapper .tvcompare-wrapper:hover .tvproduct-compare-icon,
        .tvcatlog-button-wrapper .tvproduct-wishlist:hover .tvproduct-wishlist-icon {
            background-color: #CF0000 !important;
            border-color: #CF0000 !important;
        }

        .tvcatlog-button-wrapper .tvcompare-wrapper:hover .tvproduct-compare-icon svg path,
        .tvcatlog-button-wrapper .tvproduct-wishlist:hover .tvproduct-wishlist-icon svg path {
            fill: #ffffff !important;
        }

        /* Standardize SVG sizes within these buttons */
        .tvcatlog-button-wrapper .tvproduct-cart-btn svg,
        .tvcatlog-button-wrapper .tvproduct-wishlist-icon svg,
        .tvcatlog-button-wrapper .tvproduct-compare-icon svg {
            width: 20px !important;
            height: 20px !important;
            margin: 0 !important;
            min-width: 20px !important;
        }

        /* Be extra aggressive in hiding labels and extra text */
        .tvcatlog-button-wrapper span,
        .tvcatlog-button-wrapper label,
        .tvcatlog-button-wrapper .tvproduct-add-to-cart-label {
            display: none !important;
        }
    }

    .tvproduct-wrapper.grid .tvproduct-hover-btn, 
    .tvproduct-wrapper.grid-2 .tvproduct-hover-btn,
    .tvproduct-wrapper.catelog .tvproduct-hover-btn {
        display: flex !important;
        flex-direction: column;
        gap: 5px;
        position: absolute !important;
        top: 10px !important;
        right: 10px !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        z-index: 10;
        background: transparent !important;
        width: auto !important;
        height: auto !important;
    }

    /* Reset individual button styles for forced display */
    .tvproduct-hover-btn .tvproduct-wishlist,
    .tvproduct-hover-btn .tvcompare-wrapper {
        display: flex !important;
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        margin: 0 !important;
    }

    .tvproduct-hover-btn .tvproduct-wishlist-icon,
    .tvproduct-hover-btn .tvproduct-compare-icon,
    .tvproduct-hover-btn .tvproduct-quick-icon {
        background-color: #ffffff !important;
        border: 1px solid #e4e4e4 !important;
        border-radius: 5px !important;
        width: 35px !important;
        height: 35px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    /* Hover states for hover buttons */
    .tvproduct-hover-btn .tvcompare-wrapper:hover .tvproduct-compare-icon,
    .tvproduct-hover-btn .tvproduct-wishlist:hover .tvproduct-wishlist-icon,
    .tvproduct-hover-btn .tvproduct-quick-btn:hover .tvproduct-quick-icon {
        background-color: #CF0000 !important;
        border-color: #CF0000 !important;
    }

    .tvproduct-hover-btn .tvcompare-wrapper:hover .tvproduct-compare-icon svg path,
    .tvproduct-hover-btn .tvproduct-wishlist:hover .tvproduct-wishlist-icon svg path,
    .tvproduct-hover-btn .tvproduct-quick-btn:hover .tvproduct-quick-icon svg path {
        fill: #ffffff !important;
        stroke: #ffffff !important;
    }

    /* Change icon color to red on hover if needed, or keep black */
    .tvproduct-hover-btn .tvproduct-wishlist-icon svg path,
    .tvproduct-hover-btn .tvproduct-compare-icon svg path,
    .tvproduct-hover-btn .tvproduct-quick-icon svg path {
        fill: #000000 !important;
    }

    /* Hide the redundant cart button and quick view in hover container */
    .tvproduct-hover-btn .tvproduct-cart-btn,
    .tvproduct-hover-btn .tvproduct-quick-btn {
        display: none !important;
    }
}

/* 4.1 Force 2 products per row for mobile/tablet 450px-768px */
@media (min-width: 450px) and (max-width: 769px) {
    article.product-miniature {
        width: 50% !important;
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0 5px !important; /* 5px each side = 10px gap */
        box-sizing: border-box !important;
    }

    article.product-miniature .tvproduct-wrapper {
        margin-bottom: 10px !important;
    }
}

/* 5. Fix customer services boxes grid for 992px-1335px */
@media (min-width: 992px) and (max-width: 1335px) {
    /* Main container for info boxes */
    .tvcmscustomer-services .tvservices-center {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* Individual service box */
    .tvcmscustomer-services .tvservices-center .tvall-block-box-shadows {
        width: 100% !important;
        flex: 1 1 auto !important;
        min-height: 180px !important; /* Ensure they have enough height to be equal */
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        padding: 20px !important;
        margin-bottom: 0 !important;
        box-sizing: border-box !important;
    }

    /* Inner content alignment */
    .tvservices-content-box {
        text-align: center !important;
    }

    .tvservices-content-box .tvservices-title {
        min-height: 40px !important; /* Force title height for alignment */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin-bottom: 10px !important;
    }

    .tvservices-content-box .tvservice-dec {
        font-size: 13px !important;
        line-height: 1.4 !important;
    }

    /* Fix potential sidebar wrapping */
    .tvcmscustomer-services {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* 2.1 Hide Mega Menu Title for Tablet Portrait/Large Landscape */
    .tvmega-menu-title {
        display: none !important;
    }

    /* 2.2 Fix for "Ghost Sidebar" covering page content (992px-1199px) */
    #left-column.tv-left-right-panel-hide:not(.open), 
    #right-column.tv-left-right-panel-hide:not(.open) {
        pointer-events: none !important;
        visibility: hidden !important;
        /* Ensure it doesn't take space if layout attempts to render it as col */
        display: none !important; 
    }

    /* Reset positioning if we are in non-mobile view for this range */
    #left-column.tv-left-right-panel-hide.open, 
    #right-column.tv-left-right-panel-hide.open {
        display: block !important;
        pointer-events: auto !important;
        visibility: visible !important;
    }
}

/* 5.1 Hide unwanted product view switches */
.tvproduct-view.tvproduct-grid-2,
.tvproduct-view.tvproduct-list,
.tvproduct-view.tvproduct-list-2 {
    display: none !important;
}

/* 6. Fix customer services boxes grid for mobile (and below 991px) */
/* Universal fix for all resolutions where the grid is 2-column (all breakpoints except mobile XS) */
.tvcmscustomer-services .tvservices-center:nth-child(2n+1) {
    clear: left !important;
}

@media (max-width: 991px) {
    /* Main container for info boxes on mobile/small tablets */
    .tvcmscustomer-services .tvservices-center {
        display: block !important;
        float: left !important;
        gap: 10px !important;
        padding: 0 10px !important;
    }

    @media (min-width: 370px) and (max-width: 575px) {
        .tvcmscustomer-services .tvservices-center {
            width: 50% !important;
            max-width: 50% !important;
        }
    }

    /* Individual service box on mobile */
    .tvcmscustomer-services .tvservices-center .tvall-block-box-shadows {
        width: 100% !important;
        min-height: 160px !important; /* Slightly taller to accommodate content without jumping */
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        padding: 15px !important;
        margin-bottom: 15px !important;
        box-sizing: border-box !important;
        border: 1px solid #e4e4e4 !important;
        background-color: #ffffff !important;
    }

    /* Title and description alignment for mobile */
    .tvservices-content-box .tvservices-title {
        min-height: auto !important;
        margin-bottom: 5px !important;
        justify-content: center !important;
    }

    .tvservices-content-box .tvservice-dec {
        font-size: 12px !important;
        line-height: 1.3 !important;
        text-align: center !important;
    }

    /* Ensure icons are centered */
    .tvservices-img {
        margin-bottom: 10px !important;
        display: flex !important;
        justify-content: center !important;
    }
}

/* 7. Customer Services Layout for 992px-1199px: Image full width, services 2x2 grid below */
@media (min-width: 992px) and (max-width: 1199px) {
    /* Image block - full width in first row */
    .tvcmscustomer-services .tvourprocesss-block-img {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        margin-bottom: 20px !important;
    }

    /* Services container - full width below image */
    .tvcmscustomer-services .tv-all-service {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
    }

    /* Each service box - 50% width = 2 columns × 2 rows */
    .tvcmscustomer-services .tv-all-service .tvservices-center {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
        float: none !important;
        display: block !important;
        padding: 0 10px !important;
        box-sizing: border-box !important;
    }

    /* Service box content */
    .tvcmscustomer-services .tv-all-service .tvservices-center .tvall-block-box-shadows {
        width: 100% !important;
        min-height: 180px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        padding: 20px !important;
        margin-bottom: 15px !important;
        box-sizing: border-box !important;
    }
}
