/* ===========================
   COMAGRO - WooCommerce Fixes
   =========================== */

/* --- Global box-sizing --- */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ==============================================
   1. NEUTRALISE WOOCOMMERCE FLOAT-BASED DEFAULTS
   WooCommerce's own stylesheet floats div.images
   left (48%) and div.summary right (48%). Reset
   those so our custom flex classes take over.
   ============================================== */

.woocommerce div.product div.images,
.woocommerce #content div.product div.images,
.woocommerce div.product .woocommerce-product-gallery {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

.woocommerce div.product div.summary,
.woocommerce #content div.product div.summary {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

/* ==============================================
   2. TWO-COLUMN LAYOUT: gallery left, summary right
   ============================================== */

.comagro-product-layout {
    display: flex;
    flex-direction: row;
    gap: 40px;
    align-items: flex-start;
    margin-bottom: 40px;
    width: 100%;
}

/* Both columns get exactly half the space minus half the gap */
.comagro-product-gallery-col,
.comagro-product-summary-col {
    flex: 0 0 calc(50% - 20px);
    width: calc(50% - 20px);
    min-width: 0;
}

/* Gallery column: position:relative so the sale badge stays inside */
.comagro-product-gallery-col {
    position: relative;
}

/* Top-level gallery container: reset WooCommerce float/margin */
.comagro-product-gallery-col div.images,
.comagro-product-gallery-col .woocommerce-product-gallery {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

/* FlexSlider internals (.flex-viewport, __wrapper ul, __image li, a) are
   intentionally left alone. FlexSlider sets pixel widths on those via JS
   and animates by shifting margin-left on __wrapper. Any CSS width or
   margin override on those elements breaks slide switching. */

.comagro-product-gallery-col img {
    width: 100% !important;
    height: auto !important;
    display: block;
}

/* Single-image products: PHP stamps .comagro-no-gallery on the column when
   $product->get_gallery_image_ids() is empty. Target every wrapper level so
   the featured image fills the full column width on desktop. */
.comagro-no-gallery .woocommerce-product-gallery__wrapper,
.comagro-no-gallery .woocommerce-product-gallery__image,
.comagro-no-gallery .woocommerce-product-gallery__image a {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
}

/* ==============================================
   3. MOBILE — full-width stacked
   ============================================== */

@media (max-width: 768px) {
    .comagro-product-layout {
        flex-direction: column;
        gap: 24px;
    }

    .comagro-product-gallery-col,
    .comagro-product-summary-col {
        flex: 0 0 100%;
        width: 100%;
    }
}

/* ==============================================
   4. SUMMARY — price, button, meta styles
   ============================================== */

/* Price spacing */
.comagro-product-summary-col .price-wrap {
    margin: 12px 0;
}

/* Price colour */
.comagro-product-summary-col span.price,
.comagro-product-summary-col p.price,
.comagro-product-summary-col .woocommerce-Price-amount {
    color: rgb(11, 16, 87) !important;
}

.comagro-product-summary-col span.price del,
.comagro-product-summary-col span.price del .woocommerce-Price-amount {
    color: rgba(11, 16, 87, 0.4) !important;
}

/* Add to cart button */
.comagro-product-summary-col .single_add_to_cart_button,
.woocommerce a.button.alt,
.woocommerce button.button.alt {
    background-color: rgba(0, 82, 0, 0.8) !important;
    border-color: rgba(0, 82, 0, 0.8) !important;
    color: #fff !important;
    border-radius: 4px !important;
}

.comagro-product-summary-col .single_add_to_cart_button:hover {
    background-color: rgba(0, 82, 0, 1) !important;
    border-color: rgba(0, 82, 0, 1) !important;
}

/* SKU above category */
.comagro-product-summary-col .product_meta {
    margin-top: 16px;
}

.comagro-product-summary-col .product_meta .sku_wrapper {
    display: block;
    margin-bottom: 5px;
}

.comagro-product-summary-col .product_meta .posted_in {
    display: block;
}

/* ==============================================
   5. SALE BADGE — circle, theme green
   ============================================== */

.woocommerce span.onsale {
    background-color: rgba(0, 82, 0, 0.85) !important;
    color: #fff !important;
    border-radius: 50% !important;
    width: 56px !important;
    height: 56px !important;
    line-height: 56px !important;
    min-height: unset !important;
    min-width: unset !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    text-align: center !important;
}

/* ==============================================
   6. TABS
   Desktop : all 3 tabs on one row, no scrollbar
   Mobile  : all 3 on one row, scroll horizontally
             if they don't fit; no page overflow
   ============================================== */

/* Wrapper: clip anything that would cause page overflow */
.comagro-product-tabs {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* --- Tab nav: shared base styles --- */
.woocommerce-tabs ul.tabs {
    display: flex !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Remove WooCommerce's decorative ::before border line */
.woocommerce-tabs ul.tabs::before {
    display: none !important;
}

.woocommerce-tabs ul.tabs li {
    float: none !important;         /* override WooCommerce float:left */
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.woocommerce-tabs ul.tabs li:first-child {
    border-left: none !important;
    margin-left: 0 !important;
}

/* Desktop: wrap to next line if tabs ever can't fit; no horizontal scroll */
@media (min-width: 769px) {
    .woocommerce-tabs ul.tabs {
        flex-wrap: wrap !important;
        overflow: visible !important;
    }
}

/* Mobile: keep all tabs on one line and scroll; no page overflow */
@media (max-width: 768px) {
    .woocommerce-tabs ul.tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;   /* Firefox */
    }

    .woocommerce-tabs ul.tabs::-webkit-scrollbar {
        display: none;                       /* Chrome / Safari */
    }

    .woocommerce-tabs ul.tabs li {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* ==============================================
   7. HORIZONTAL OVERFLOW PREVENTION
   ============================================== */

.comagro-single-product,
.comagro-product-layout,
.comagro-product-gallery-col,
.comagro-product-summary-col,
.comagro-product-tabs,
.woocommerce-product-gallery,
.woocommerce-product-gallery .flex-viewport {
    max-width: 100%;
    box-sizing: border-box;
}
/* .woocommerce-product-gallery__wrapper is intentionally excluded:
   FlexSlider sets its width to N × slide_width (wider than 100%) and
   animates by shifting margin-left. max-width: 100% collapses all slides
   into one view, breaking thumbnail switching. */

#primary,
#main {
    overflow-x: hidden;
    max-width: 100%;
}


/* ==============================================
   8. HEADER ICONS — cart & account
   ============================================== */

/*
 * The nav element (.header__menu) contains both the wp_nav_menu <ul>
 * and the .header__icons <div> as siblings. Making it a flex row lets
 * the icons sit on the SAME LINE as the menu items, pushed to the right
 * via margin-left: auto on .header__icons.
 */
.header__menu {
    display: flex;
    align-items: center;
    /* Grow to fill remaining header width so margin-left:auto on
       .header__icons actually pushes icons to the far right edge */
    flex: 1;
}

/* Icon group — shoved to the far right of the nav row */
.header__icons {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    padding-left: 24px;
    color: #0b1057;
}

/* Individual icon link */
.header__icon {
    position: relative;
    display: flex;
    align-items: center;
    color: #0b1057;
    line-height: 1;
    text-decoration: none;
}

.header__icon svg {
    stroke: #0b1057;
    display: block;
    flex-shrink: 0;
    transition: stroke 0.3s;
}

.header__icon:hover svg {
    stroke: #007a4b;
}

/* Cart count badge */
.header__cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: rgba(0, 82, 0, 0.85);
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    pointer-events: none;
    /* Ensure badge is above everything in the icon */
    z-index: 1;
}