/**
 * BoboPkg Mobile Performance CSS
 * 
 * Lightweight mobile-specific styles for improved Core Web Vitals
 * This file is loaded ONLY on mobile devices and should be kept minimal.
 * 
 * @package BoboPkg
 */

/* ====================================
   1. LAYOUT STABILITY (Reduce CLS)
   ==================================== */

/* GLOBAL: Prevent horizontal overflow on mobile ONLY */
@media (max-width: 768px) {

    html,
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
}

/* Prevent layout shifts with explicit dimensions */
.bobopkg-header {
    min-height: 56px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-top-bar {
    min-height: 32px;
}

.header-main-bar {
    min-height: 56px;
}

/* Hero section stability */
.bobopkg-hero {
    min-height: 50vh;
    overflow: hidden;
}

.bobopkg-hero img {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    object-fit: cover;
}

/* Product card stability */
.product-card {
    min-height: 260px;
    contain: layout style;
}

.product-card-inner {
    aspect-ratio: 3/4;
    contain: layout paint style;
}

/* Category tile stability */
.category-tile {
    min-height: 200px;
    aspect-ratio: 4/3;
}

/* Image placeholders */
img[loading="lazy"]:not([src]),
img:not([complete]) {
    background: #f5f5f5;
    min-height: 100px;
}

/* ====================================
   2. PAINT PERFORMANCE (Reduce LCP)
   ==================================== */

/* Hardware acceleration for critical elements */
/* Note: #cart-drawer and #cart-drawer-overlay are excluded because they 
   need to preserve their translate-x-full transform for hiding/showing */
.bobopkg-hero,
#mobile-menu-drawer {
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* Cart drawer uses translate-x-full for hiding, so we only add will-change 
   and backface-visibility without overriding transform */
#cart-drawer,
#cart-drawer-overlay {
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Optimal image rendering */
img {
    content-visibility: auto;
}

/* Reduce paint area for animated elements */
/* Note: We only use will-change here, NOT transform: translateZ(0), because 
   setting a static transform value would override dynamic transforms like 
   translate-x-full used to hide the cart drawer */
.translate-y-full,
.group-hover\:translate-y-0 {
    will-change: transform;
}

/* For transition-transform, only add will-change without overriding transform,
   as elements using this class may have other transform values applied */
.transition-transform {
    will-change: transform;
}

/* ====================================
   3. INPUT DELAY (Reduce FID/INP)
   ==================================== */

/* Remove 300ms tap delay */
html {
    touch-action: manipulation;
}

/* Optimize touch targets */
a,
button,
input,
select,
textarea,
.mobile-submenu-toggle,
.header-cart-toggle,
.add_to_cart_button,
.single_add_to_cart_button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure minimum touch target size */
@media (max-width: 768px) {

    button,
    .button,
    .mobile-submenu-toggle,
    .add_to_cart_button,
    .single_add_to_cart_button {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Passive scrolling */
.mobile-sub-menu,
#cart-drawer,
#mobile-menu-drawer,
.bobopkg-sidebar-products {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ====================================
   4. CONTENT VISIBILITY (Reduce TTI)
   ==================================== */

/* Off-screen content visibility */
.bobopkg-product-cards,
.bobopkg-category-tiles,
.bobopkg-related-products,
.bobopkg-sidebar-products,
.bobopkg-promotional-banners {
    content-visibility: auto;
    contain-intrinsic-size: 0 400px;
}

/* Delay rendering of below-fold content */
.product-card:nth-child(n+5),
.category-tile:nth-child(n+4) {
    content-visibility: auto;
    contain-intrinsic-size: 0 300px;
}

/* Footer content visibility */
footer,
.bobopkg-footer,
.site-footer {
    content-visibility: auto;
    contain-intrinsic-size: 0 300px;
}

/* ====================================
   5. ANIMATION OPTIMIZATION
   ==================================== */

/* Reduce motion for accessibility and performance */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Simplify transitions on mobile */
.transition-all {
    transition-property: opacity, transform !important;
    transition-duration: 0.15s !important;
    transition-timing-function: ease-out !important;
}

/* Disable hover-dependent effects on touch devices */
@media (hover: none) and (pointer: coarse) {

    .group:hover .group-hover\:opacity-0,
    .group:hover .group-hover\:opacity-100 {
        opacity: inherit !important;
    }

    .group:hover .img-secondary {
        opacity: 0 !important;
    }

    .group:hover .translate-y-full {
        transform: translateY(100%) !important;
    }

    .card-hover-swap:hover .img-secondary {
        opacity: 0 !important;
    }

    /* Hide desktop-only hover elements */
    .hidden.md\:block.absolute.bottom-0 {
        display: none !important;
    }
}

/* ====================================
   6. VISUAL SIMPLIFICATION
   ==================================== */

@media (max-width: 768px) {

    /* Reduce shadow complexity */
    .shadow-sm {
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
    }

    .shadow {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06) !important;
    }

    .shadow-md {
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08) !important;
    }

    .shadow-lg {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    }

    .shadow-xl {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08) !important;
    }

    .shadow-2xl {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1) !important;
    }

    /* Simplify gradients */
    .bg-gradient-to-r,
    .bg-gradient-to-b {
        background-size: 100% 100% !important;
    }
}

/* ====================================
   7. FONT OPTIMIZATION
   ==================================== */

body {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    text-rendering: optimizeLegibility;
}

@media (max-width: 768px) {

    /* Reduce font weight variations */
    .font-light {
        font-weight: 400 !important;
    }

    .font-thin {
        font-weight: 400 !important;
    }

    .font-extralight {
        font-weight: 400 !important;
    }
}

/* ====================================
   8. SPACING OPTIMIZATION
   ==================================== */

@media (max-width: 768px) {

    /* Reduce padding on mobile for faster rendering */
    .py-20 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }

    .py-16 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .py-12 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    .gap-y-12 {
        row-gap: 2rem !important;
    }

    .gap-y-8 {
        row-gap: 1.5rem !important;
    }

    .mb-16 {
        margin-bottom: 2rem !important;
    }

    .mt-16 {
        margin-top: 2rem !important;
    }
}

/* ====================================
   9. SKELETON LOADING
   ==================================== */

@keyframes skeleton-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.skeleton,
.skeleton-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ====================================
   10. CART DRAWER MOBILE OPTIMIZATION
   ==================================== */

@media (max-width: 768px) {
    #cart-drawer {
        max-width: calc(100vw - 16px) !important;
        width: 100% !important;
        contain: layout style;
    }

    #cart-drawer .cart-drawer-content {
        padding: 1.25rem !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    /* Smaller cart item images on mobile */
    #cart-drawer .woocommerce-mini-cart-item img {
        width: 48px !important;
        height: 48px !important;
    }
}

/* ====================================
   11. MOBILE MENU OPTIMIZATION
   ==================================== */

#mobile-menu-drawer {
    contain: layout style;
}

#mobile-menu-drawer ul {
    contain: layout;
}

.mobile-sub-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out;
}

.mobile-sub-menu.is-open {
    max-height: 1500px;
}

/* ====================================
   12. PRODUCT PAGE OPTIMIZATION
   ==================================== */

/* Optimize product gallery */
.woocommerce-product-gallery {
    contain: layout style;
}

/* Simplify variation select on mobile */
.variations select {
    height: 48px;
    font-size: 16px;
    /* Prevent zoom on iOS */
}

/* Optimize variation form */
.variations_form {
    contain: layout;
}

/* ====================================
   13. GRID PERFORMANCE
   ==================================== */

.product-cards-grid,
.category-tiles-grid,
.woocommerce ul.products {
    contain: layout;
    max-width: 100vw;
    /* Ensure no overflow */
    box-sizing: border-box;
}

/* Force 2-column grid on mobile, but respect container */
@media (max-width: 767px) {

    .product-cards-grid,
    .woocommerce ul.products {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.75rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    /* FIX: Category tiles grid MUST fit within viewport */
    .category-tiles-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* Ensure category tiles container doesn't overflow */
    .category-tiles-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* Ensure individual tiles don't exceed their grid cell */
    .category-tile {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        /* Critical for flex/grid children */
        overflow: hidden !important;
    }

    /* Fix aspect ratio on mobile */
    .category-tile {
        aspect-ratio: 4/5 !important;
        min-height: unset !important;
    }
}

/* ====================================
   13.5. THIRD PARTY FIXES (TranslatePress, etc)
   ==================================== */

/* Fix oversized TranslatePress floater */
#trp-floater-ls,
.trp-language-switcher {
    max-width: 200px !important;
    font-size: 14px !important;
}

#trp-floater-ls img,
.trp-language-switcher img {
    width: 18px !important;
    height: 12px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

/* Fix generic touch target rules affecting other elements */
button:not(.header-icon-btn):not(.mobile-submenu-toggle):not(.add_to_cart_button),
.button:not(.header-icon-btn):not(.mobile-submenu-toggle) {
    min-width: unset;
    /* Remove global min-width forcing */
}

/* ====================================
   14. ACCESSIBILITY & PERFORMANCE
   ==================================== */

/* High contrast mode */
@media (prefers-contrast: high) {
    .text-muted-foreground {
        opacity: 1;
        color: #333;
    }

    .border-border {
        border-color: #666;
    }
}

/* Dark mode skeleton */
@media (prefers-color-scheme: dark) {

    .skeleton,
    .skeleton-loading,
    img[loading="lazy"]:not([src]) {
        background-color: #2a2a2a;
        background-image: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
    }
}

/* ====================================
   15. PRINT OPTIMIZATION
   ==================================== */

@media print {

    .bobopkg-header,
    #cart-drawer,
    #mobile-menu-drawer,
    .header-cart-toggle,
    .mobile-submenu-toggle {
        display: none !important;
    }

    .product-card {
        break-inside: avoid;
    }
}

/* ====================================
   16. CART & CHECKOUT PAGE PADDING FIX
   ==================================== */

@media (max-width: 768px) {

    /* Add padding to the main wrapper of Cart and Checkout pages to prevent text touching edges */
    .woocommerce-cart .entry-content,
    .woocommerce-cart .woocommerce,
    .woocommerce-checkout .entry-content,
    .woocommerce-checkout .woocommerce {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Cart page title padding - Align with content */
    .woocommerce-cart h1.entry-title,
    .woocommerce-cart .page-title,
    .woocommerce-cart .woocommerce>h2,
    .woocommerce-cart .cart-empty,
    .woocommerce-cart .return-to-shop {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }

    /* Additional safety for the cart form to prevent overflow */
    .woocommerce-cart-form {
        width: 100%;
        overflow-x: hidden;
    }

    .woocommerce-cart .woocommerce-notices-wrapper,
    .woocommerce-checkout .woocommerce-notices-wrapper {
        width: 100%;
        box-sizing: border-box;
    }

    /* Cart page collaterals (totals section) */
    .woocommerce-cart .cart-collaterals,
    .woocommerce-cart .cart_totals {
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
    }

    /* Cart totals table text */
    .woocommerce-cart .cart_totals th,
    .woocommerce-cart .cart_totals td {
        padding: 0.75rem 0.5rem !important;
        font-size: 14px !important;
    }

    /* WooCommerce Blocks cart page */
    .wc-block-cart,
    .wp-block-woocommerce-cart {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Proceed to Checkout fixed button - higher z-index to stay above language switcher */
    .woocommerce-cart .wc-proceed-to-checkout,
    .wc-block-cart__submit,
    /* Block Wrapper */
    .wp-block-woocommerce-proceed-to-checkout-block {
        position: fixed !important;
        bottom: 60px !important;
        /* Above language switcher floater */
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 9998 !important;
        /* Below language switcher (9999) but above content */
        padding: 1rem 1.25rem !important;
        /* Align with page padding */
        background-color: #ffffff !important;
        border-top: 1px solid #e5e5e5 !important;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1) !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        display: block !important;
    }

    /* Styling the actual button inside the fixed container */
    .woocommerce-cart .wc-proceed-to-checkout .checkout-button,
    .woocommerce-cart .wc-proceed-to-checkout a.checkout-button,
    .woocommerce-cart .checkout-button,
    .woocommerce-cart a.checkout-button,
    .woocommerce-cart .wc-proceed-to-checkout .checkout-button:hover,
    .woocommerce-cart .wc-proceed-to-checkout a.checkout-button:hover,
    .woocommerce-cart .checkout-button:hover,
    .woocommerce-cart a.checkout-button:hover,
    .wc-block-cart__submit-button,
    /* Block Button */
    .wp-block-woocommerce-checkout-button {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 4px !important;
        /* Standard button radius */
        background-color: hsl(221, 83%, 53%) !important;
        /* Theme Blue */
        background-image: none !important;
        color: #000000 !important;
        /* Black Text as requested */
        opacity: 1 !important;
        display: block !important;
        text-align: center !important;
        line-height: 2.5rem !important;
        box-shadow: none !important;
        text-decoration: none !important;
        font-weight: 700 !important;
        font-size: 16px !important;
        height: auto !important;
        padding: 0 !important;
    }

    /* Add bottom padding to cart page body to prevent content overlap with fixed button */
    .woocommerce-cart {
        padding-bottom: 120px !important;
        /* Extra space for checkout button + language switcher */
    }

    /* TranslatePress language switcher - ensure it's above checkout button */
    #trp-floater-ls,
    .trp-language-switcher-container {
        z-index: 9999 !important;
        bottom: 10px !important;
    }
}

/* ====================================
   17. CHECKOUT PAGE MOBILE FIXES
   ==================================== */

@media (max-width: 768px) {

    /* Fix Oversized Payment Logo (PayPal & Others) - MAXIMUM STRENGTH Selector */
    #payment img,
    .wc_payment_method img,
    .wc_payment_method label img,
    .payment_method_paypal img,
    .payment_method_paypal label img,
    img[alt="PayPal"],
    img[alt*="paypal" i],
    img[src*="paypal" i],
    .woocommerce-checkout #payment ul.wc_payment_methods li img,
    .woocommerce-checkout #payment ul.wc_payment_methods li label img {
        max-width: 80px !important;
        max-height: 28px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        margin-left: 0.5rem !important;
        vertical-align: middle !important;
        margin-top: 0 !important;
        display: inline-block !important;
    }

    /* Hide oversized payment images if they still overflow */
    .wc_payment_method>label {
        overflow: hidden !important;
        max-width: 100% !important;
    }

    /* Fix Oversized Product List Text - Stronger Selector */
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name,
    .woocommerce-checkout table.shop_table tr.cart_item td.product-total,
    .woocommerce-checkout table.shop_table tr.cart_item .product-quantity,
    .product-name,
    .product-name a,
    .woocommerce-table__product-name {
        font-size: 13px !important;
        line-height: 1.4 !important;
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
        font-family: var(--wp--preset--font-family--inter, inherit) !important;
        font-weight: 400 !important;
    }

    /* Target Product Variations specifically to prevent huge text blocks */
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name dl.variation,
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name .wc-item-meta {
        font-size: 12px !important;
        margin: 0.25rem 0 0 !important;
        display: block !important;
    }

    .woocommerce-checkout table.shop_table tr.cart_item td.product-name dl.variation dt,
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name dl.variation dd {
        display: inline-block !important;
        margin: 0 !important;
        padding: 0 0.25rem 0 0 !important;
        float: none !important;
        font-weight: normal !important;
    }

    /* Reduce Heading size in product name if it exists */
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name h1,
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name h2,
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name h3,
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name h4,
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name h5,
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name strong {
        font-size: 13px !important;
        font-weight: 600 !important;
        margin: 0 !important;
        font-family: var(--wp--preset--font-family--inter, inherit) !important;
    }

    /* Ensure product name wraps nicely */
    .woocommerce-checkout table.shop_table tr.cart_item td.product-name {
        word-break: break-word;
    }
}

/* ====================================
   18. ARCHIVE GRID LAYOUT FIXES
   ==================================== */

/* Force grid layout for Archive/Category/Tag pages */
/* Force grid layout for Archive/Category/Tag pages */
/* CORRECTED: Apply grid to inner list, not wrapper */
.product-cards-grid .wp-block-post-template,
.wp-block-query.product-cards-grid .wp-block-post-template {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    /* Mobile: 2 cols */
    gap: 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
}

/* Wrapper should NOT be grid */
.wp-block-query.product-cards-grid {
    display: block !important;
    width: 100% !important;
    padding: 0 1rem !important;
}

@media (min-width: 768px) {

    .product-cards-grid .wp-block-post-template,
    .wp-block-query.product-cards-grid .wp-block-post-template {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        /* Tablets: 3 cols */
        gap: 1.5rem !important;
    }

    .wp-block-query.product-cards-grid {
        padding: 0 !important;
    }
}

@media (min-width: 1024px) {

    .product-cards-grid .wp-block-post-template,
    .wp-block-query.product-cards-grid .wp-block-post-template {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        /* Desktop: 4 cols */
    }
}

/* Reset individual product card constraints within the grid */
/* Reset individual product card constraints within the grid */
/* CORRECTED: Don't apply flex to the grid container (.wp-block-post-template) */
.product-cards-grid .wp-block-post-template>li,
.product-cards-grid .product-card-static {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 0 !important;
    /* Remove bottom margin as grid handles gap */
    flex: none !important;
    /* Disable flex behavior if set */
    display: flex !important;
    flex-direction: column !important;
    list-style: none !important;
}

/* FIX: WordPress Featured Image Block - NUCLEAR OPTION */
/* 1. Force Aspect Ratio on the Wrapper */
.product-cards-grid .product-card-static>div:first-child,
.product-cards-grid .product-card-static .aspect-\[3\/4\] {
    width: 100% !important;
    aspect-ratio: 3/4 !important;
    position: relative !important;
    overflow: hidden !important;
    background-color: #f9f9f9 !important;
    display: block !important;
}

/* 2. Force Figure to fill Wrapper */
.product-cards-grid .product-card-static .wp-block-post-featured-image,
.product-cards-grid .product-card-static figure.wp-block-post-featured-image {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
}

/* 3. Force Link to fill Figure */
.product-cards-grid .product-card-static .wp-block-post-featured-image a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

/* 4. Force Image to fill Container with Contain */
.product-cards-grid .product-card-static .wp-block-post-featured-image img,
.product-cards-grid .product-card-static img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    /* Ensures whole product is visible */
    object-position: center !important;
    position: absolute !important;
    /* Absolute prevents layout shift */
    top: 0 !important;
    left: 0 !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Reduce Footer Summary Sizes */
.woocommerce-checkout table.shop_table tfoot th,
.woocommerce-checkout table.shop_table tfoot td {
    font-size: 14px !important;
    padding: 0.75rem 0.5rem !important;
}

/* Reduce Order Total Size slightly */
.woocommerce-checkout table.shop_table .order-total th,
.woocommerce-checkout table.shop_table .order-total td {
    font-size: 1.125rem !important;
    /* 18px */
    padding-top: 1rem !important;
}

/* ====================================
   19. CRITICAL: CHECKOUT/CART LAYOUT FIX
   Force vertical stacking on ALL mobile browsers
   ==================================== */

@media (max-width: 1023px) {
    /* NUCLEAR OPTION: Force single column layout for checkout/cart PAGES ONLY */
    /* Uses body class to avoid affecting mini-cart drawer */

    /* Classic WooCommerce Checkout */
    body.woocommerce-checkout form.checkout.woocommerce-checkout,
    body.woocommerce-checkout form.checkout,
    body.woocommerce-checkout .checkout,
    form.checkout.woocommerce-checkout {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* WooCommerce Blocks Checkout - SCOPED TO CHECKOUT PAGE */
    body.woocommerce-checkout .wc-block-checkout,
    body.woocommerce-checkout .wp-block-woocommerce-checkout,
    body.woocommerce-checkout .wc-block-checkout__form,
    body.woocommerce-checkout .wc-block-checkout-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* WooCommerce Blocks Cart - SCOPED TO CART PAGE */
    body.woocommerce-cart .wc-block-cart,
    body.woocommerce-cart .wp-block-woocommerce-cart,
    body.woocommerce-cart .wc-block-cart__items,
    body.woocommerce-cart .wc-block-cart-items {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Reset ALL grid/column positioning for checkout children */
    body.woocommerce-checkout #customer_details,
    body.woocommerce-checkout #order_review_heading,
    body.woocommerce-checkout #order_review,
    body.woocommerce-checkout .col-1,
    body.woocommerce-checkout .col-2,
    body.woocommerce-checkout .col2-set,
    body.woocommerce-checkout .wc-block-checkout__main,
    body.woocommerce-checkout .wc-block-checkout__sidebar,
    body.woocommerce-cart .wc-block-cart__main,
    body.woocommerce-cart .wc-block-cart__sidebar {
        grid-column: auto !important;
        grid-row: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        position: relative !important;
        display: block !important;
        flex: none !important;
    }

    /* CRITICAL: WooCommerce Blocks Sidebar Layout Component - SCOPED */
    body.woocommerce-checkout .wc-block-components-sidebar-layout,
    body.woocommerce-cart .wc-block-components-sidebar-layout {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 1.5rem !important;
    }

    body.woocommerce-checkout .wc-block-components-main,
    body.woocommerce-checkout .wc-block-components-sidebar,
    body.woocommerce-cart .wc-block-components-main,
    body.woocommerce-cart .wc-block-components-sidebar {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        min-width: 0 !important;
    }

    /* Order elements correctly */
    body.woocommerce-checkout #customer_details,
    body.woocommerce-checkout .wc-block-checkout__main,
    body.woocommerce-checkout .wc-block-components-main,
    body.woocommerce-cart .wc-block-cart__main,
    body.woocommerce-cart .wc-block-components-main {
        order: 1 !important;
    }

    body.woocommerce-checkout #order_review_heading,
    body.woocommerce-checkout #order_review,
    body.woocommerce-checkout .wc-block-checkout__sidebar,
    body.woocommerce-checkout .wc-block-components-sidebar,
    body.woocommerce-cart .wc-block-cart__sidebar,
    body.woocommerce-cart .wc-block-components-sidebar {
        order: 2 !important;
    }

    /* Prevent horizontal overflow - SCOPED to pages only */
    body.woocommerce-checkout,
    body.woocommerce-cart {
        overflow-x: hidden !important;
    }

    /* Full width content wrapper - SCOPED */
    body.woocommerce-checkout .entry-content,
    body.woocommerce-cart .entry-content,
    body.woocommerce-checkout .wp-block-woocommerce-checkout,
    body.woocommerce-cart .wp-block-woocommerce-cart {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* Extra fix for product name text overflow in order summary */
@media (max-width: 768px) {

    /* Fix product name overflow in checkout/cart */
    .woocommerce-checkout table.shop_table td.product-name,
    .wc-block-cart-item__product,
    .wc-block-components-order-summary-item__description,
    .wc-block-components-product-name {
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        white-space: normal !important;
        max-width: 60vw !important;
        display: block !important;
    }

    /* Fix vertical text issue */
    .wc-block-components-product-name,
    .wc-block-cart-item__product-name {
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
    }

    /* Order summary table */
    .woocommerce-checkout table.shop_table,
    .wc-block-components-order-summary {
        table-layout: fixed !important;
        width: 100% !important;
    }

    /* Product thumbnail column width */
    .woocommerce-checkout table.shop_table td.product-thumbnail,
    .wc-block-cart-item__image {
        width: 60px !important;
        min-width: 60px !important;
        max-width: 60px !important;
    }

    /* Product total column */
    .woocommerce-checkout table.shop_table td.product-total,
    .wc-block-cart-item__total {
        width: 70px !important;
        min-width: 70px !important;
        max-width: 70px !important;
        text-align: right !important;
        white-space: nowrap !important;
    }
}