/* ============================================
   Grass247-style Product Page
   ============================================ */

.g247 {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 0;
    color: #333;
    font-size: 15px;
    line-height: 1.6;
}

/* ── Breadcrumb ── */
.g247__breadcrumb {
    font-size: 13px;
    color: #999;
    padding: 12px 0;
    margin-bottom: 8px;
}

.g247__breadcrumb a {
    color: #666;
    text-decoration: none;
}

.g247__breadcrumb a:hover { text-decoration: underline; }
.g247__breadcrumb span { color: #ccc; margin: 0 4px; }

/* ── Two-column layout: left scrolls, right sticky ── */
.g247__columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 40px;
    align-items: start;
    margin-bottom: 0;
}

/* Everything except .g247__right goes in column 1 */
.g247__columns > * {
    grid-column: 1;
}

.g247__columns > .g247__right {
    grid-column: 2;
    grid-row: 1 / 2;
    position: sticky;
    top: 80px;
    align-self: start;
}

/* Gallery */
.g247__gallery {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 10px;
}

.g247__gallery--single {
    grid-template-columns: 1fr;
}

.g247__thumbs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.g247__thumb {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    background: #f5f5f3;
    transition: border-color 150ms;
    flex-shrink: 0;
}

.g247__thumb.is-active,
.g247__thumb:hover {
    border-color: #2f6120;
}

.g247__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.g247__main-image {
    border-radius: 10px;
    overflow: hidden;
    background: #f5f5f3;
    position: relative;
    width: 550px;
    height: 550px;
    max-width: 100%;
}

.g247__main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Gallery arrows inside main image */
.g247__img-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 0;
    line-height: 1;
}

.g247__img-arrow:hover {
    background: rgba(255, 255, 255, 0.5);
}

.g247__img-arrow--prev { left: 12px; }
.g247__img-arrow--next { right: 12px; }

.g247__main-image .ago-hp-card__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    right: auto;
    width: auto;
}

/* Summary */
.g247__summary {
    max-width: 540px;
}

.g247__title {
    font-size: 26px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 10px;
    line-height: 1.25;
}

.g247__price-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.g247__price-now {
    font-size: 22px;
    font-weight: 800;
    color: #c12c27;
}

.g247__price-now .woocommerce-Price-amount { font-size: inherit; font-weight: inherit; color: inherit; }
.g247__price-now sup { font-size: 12px; vertical-align: super; }

.g247__price-was {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
}

.g247__price-was .woocommerce-Price-amount { font-size: inherit; color: inherit; }
.g247__price-was sup { font-size: 10px; vertical-align: super; }

.g247__rating {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.g247__star { color: #ddd; font-size: 16px; }
.g247__star.is-filled { color: #F5C518; }

.g247__review-count {
    font-size: 13px;
    color: #666;
    margin-left: 4px;
}

/* Cart form */
.g247__cart-form {
    margin-bottom: 10px;
}

/* Variation group */
.g247__variation-group {
    margin-bottom: 14px;
}

.g247__variation-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

/* Custom swatches */
.g247__swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.g247__swatch {
    position: relative;
    padding: 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    background: #fff;
    overflow: hidden;
    transition: border-color 150ms, box-shadow 150ms;
}

.g247__swatch:hover {
    border-color: #2f6120;
}

.g247__swatch.is-active {
    border-color: #2f6120;
    box-shadow: 0 0 0 2px rgba(47, 97, 32, 0.25);
}

.g247__swatch--image {
    width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding-bottom: 6px;
}

.g247__swatch--image img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    border-radius: 6px 6px 0 0;
}

.g247__swatch--image .g247__swatch-label {
    font-size: 10px;
    font-weight: 600;
    color: #333;
    text-align: center;
    padding: 4px 4px 0;
    line-height: 1.2;
    word-break: break-word;
}

.g247__swatch--image.is-active .g247__swatch-label {
    color: #2f6120;
}

.g247__swatch--text {
    padding: 8px 16px;
    min-width: 48px;
    text-align: center;
}

.g247__swatch--text .g247__swatch-label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.g247__swatch--text:hover .g247__swatch-label,
.g247__swatch--text.is-active .g247__swatch-label {
    color: #2f6120;
}

.g247__swatch.is-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Quantity + Add to Cart row */
.g247__qty-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-top: 14px;
}

.g247__qty {
    flex-shrink: 0;
}

.g247__qty label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
}

.g247__qty-input {
    width: 64px;
    padding: 10px 8px;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    text-align: center;
}

.g247__add-to-cart {
    flex: 1;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 6px;
    background: #2f6120;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 150ms;
    text-align: center;
}

.g247__add-to-cart:hover {
    background: #1a3a10;
}

/* WooCommerce variation price/stock updates */
.g247__cart-form .woocommerce-variation {
    margin-bottom: 10px;
}

.g247__cart-form .woocommerce-variation-price {
    font-size: 18px;
    font-weight: 700;
    color: #c12c27;
}

.g247__cart-form .woocommerce-variation-availability {
    font-size: 13px;
    margin-top: 4px;
}

/* Hidden WC variations table — must stay in DOM for WC JS but invisible */
.g247__cart-form table.variations {
    display: none !important;
    position: absolute !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* WC variation info display */
.g247__cart-form .single_variation_wrap .single_variation {
    margin-bottom: 10px;
}

.g247__cart-form .woocommerce-variation-price {
    font-size: 18px;
    font-weight: 700;
    color: #c12c27;
}

.g247__cart-form .woocommerce-variation-availability p {
    font-size: 13px;
    color: #059669;
    margin: 4px 0 0;
}

/* Reset link */
.g247__cart-form .reset_variations {
    display: inline-block;
    font-size: 12px;
    color: #999;
    margin-top: 6px;
    cursor: pointer;
}

.g247__cart-form .cart {
    margin-bottom: 0;
}

.g247__cart-form .single_add_to_cart_button {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 6px;
    background: #2f6120;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 150ms;
}

.g247__cart-form .single_add_to_cart_button:hover {
    background: #1a3a10;
}

/* Sample button */
.g247__btn {
    display: block;
    text-align: center;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 150ms;
    margin-bottom: 14px;
}

.g247__btn--sample {
    background: #f5f5f3;
    color: #333;
    border: 1.5px solid #ddd;
}

.g247__btn--sample:hover {
    background: #eee;
    color: #333;
}

/* Status row */
.g247__status-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.g247__status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.g247__status-item--delivery { color: #2f6120; }
.g247__status-item--delivery svg { color: #2f6120; }
.g247__status-item--stock { color: #059669; }
.g247__status-item--stock svg { color: #059669; }

/* Finance */
.g247__finance {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: #666;
    padding: 10px 14px;
    background: #fdf8f0;
    border: 1px solid #f0e6d4;
    border-radius: 6px;
    margin-bottom: 16px;
}

/* ── Frequently Bought Together (boxed stack, mirrors .ag-area-calculator) ── */
.g247__fbt {
    border: 1.5px solid #d4edda;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    background: #f9fdf9;
    box-shadow: 0 1px 4px rgba(45, 122, 58, 0.06);
    box-sizing: border-box;
    max-width: 100%;
}

.g247__fbt-title {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 700;
    color: #1a1a1a;
}

.g247__fbt-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.g247__fbt .g247__acc-card {
    flex: 1 1 auto;
    background: #fff;
}

/* ── Legacy accessories carousel (kept for any other pages still using it) ── */
.g247__acc-carousel {
    border-top: 1px solid #eee;
    padding-top: 16px;
    margin-top: 4px;
    padding-bottom: 32px;
}

.g247__acc-carousel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.g247__acc-carousel-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

.g247__acc-carousel-nav {
    display: flex;
    gap: 4px;
}

.g247__acc-arrow {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid #ddd;
    background: #fff;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 150ms;
}

.g247__acc-arrow:hover {
    border-color: #2f6120;
    color: #2f6120;
}

.g247__acc-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

.g247__acc-track-wrap {
    overflow: hidden;
    border-radius: 8px;
}

.g247__acc-track {
    display: flex;
    gap: 10px;
    transition: transform 300ms ease;
}

.g247__acc-card {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 10px;
    color: inherit;
    background: #fff;
    transition: border-color 150ms, box-shadow 150ms;
}

.g247__acc-card:hover {
    border-color: #d4edda;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.g247__acc-card-link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.g247__acc-card-img {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f5f5f3;
}

.g247__acc-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.g247__acc-card-body {
    flex: 1;
    min-width: 0;
}

.g247__acc-card-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.g247__acc-card-price {
    font-size: 13px;
    font-weight: 700;
    color: #2f6120;
}

.g247__acc-cta {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 150ms;
}

.g247__acc-cta--add {
    background: #2f6120;
    color: #fff;
    border: 1.5px solid #2f6120;
}

.g247__acc-cta--add:hover {
    background: #1a3a10;
    border-color: #1a3a10;
    color: #fff;
}

.g247__acc-cta--added {
    background: #e8f5e9;
    color: #2f6120;
    border: 1.5px solid #c8e6c9;
    cursor: default;
}

.g247__acc-cta--options {
    background: #fff;
    color: #2f6120;
    border: 1.5px solid #2f6120;
}

.g247__acc-cta--options:hover {
    background: #2f6120;
    color: #fff;
}

/* ── Feature Highlights (2-col grid) ── */
.g247__why-buys {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 8px;
    margin-bottom: 24px;
}

.g247__why-buy {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: #fff;
    border: 1.5px solid #e8f0e8;
    border-radius: 12px;
    text-align: left;
    transition: border-color 200ms, box-shadow 200ms;
}

.g247__why-buy:hover {
    border-color: #c8dcc8;
    box-shadow: 0 4px 16px rgba(45, 122, 58, 0.06);
}

.g247__why-buy img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex-shrink: 0;
}

.g247__why-buy strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--ag-header-bg, #2f6120);
    margin-bottom: 3px;
    line-height: 1.3;
    text-align: left;
}

.g247__why-buy p {
    font-size: 12.5px;
    color: #777;
    margin: 0;
    line-height: 1.45;
    text-align: left;
}

@media (max-width: 768px) {
    .g247__why-buys {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .g247__why-buys {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .g247__why-buy {
        padding: 14px 10px;
    }
}

/* ── Accordion Sections ── */
.g247__sections {
    max-width: 100%;
    margin-bottom: 0;
}

.g247__section {
    border-bottom: 1px solid #eee;
}

.g247__section-heading {
    padding: 18px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--ag-header-bg, #2f6120);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
}

.g247__section-heading::-webkit-details-marker { display: none; }

.g247__section-heading::after {
    content: '';
    width: 12px;
    height: 12px;
    border-right: 2px solid var(--ag-header-bg, #2f6120);
    border-bottom: 2px solid var(--ag-header-bg, #2f6120);
    transform: rotate(45deg);
    transition: transform 200ms;
    flex-shrink: 0;
}

.g247__section[open] > .g247__section-heading::after {
    transform: rotate(-135deg);
}

.g247__section-body {
    padding: 0 0 20px;
    font-size: 14.5px;
    color: #555;
    line-height: 1.7;
}

.g247__section-body p { margin: 0 0 12px; }

/* Specs — clean label/value rows, 2 columns */
.g247__specs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 40px;
}

.g247__spec-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0ee;
}

.g247__specs-col .g247__spec-row:last-child {
    border-bottom: none;
}

.g247__spec-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--ag-header-bg, #2f6120);
}

.g247__spec-value {
    font-size: 14px;
    font-weight: 400;
    color: #777;
    text-align: right;
}

@media (max-width: 600px) {
    .g247__specs-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Related Products ── */
.g247__related {
    margin-top: 48px;
}

.g247__related-heading {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    text-align: center;
    margin: 0 0 24px;
}

.g247__related-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .g247__hero {
        gap: 24px;
    }

    .g247__related-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {

    /* ── Hard overflow guard ──
       BeTheme's parent wrappers and authored content blocks can introduce
       horizontal overflow on the PDP. Clip at every level so nothing escapes
       the viewport, and force border-box on the .g247 root so its 12px
       gutter padding doesn't push children out. */
    html,
    body.single-product {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Force all theme wrappers to full viewport width */
    .single-product #Wrapper,
    .single-product #Content,
    .single-product .content_wrapper,
    .single-product .sections_group,
    .single-product .entry-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Grass247 wrapper — consistent gutter on mobile */
    .g247 {
        padding: 0 12px 32px !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden;
    }

    .g247__columns {
        grid-template-columns: 1fr;
        gap: 20px;
        max-width: 100%;
        min-width: 0;
    }

    .g247__columns > .g247__right {
        grid-column: 1;
        grid-row: auto;
        position: static;
        max-width: 100%;
        min-width: 0;
    }

    .g247__summary {
        max-width: 100%;
        min-width: 0;
    }

    /* ── Typography rhythm ── */
    .g247__breadcrumb {
        font-size: 12px;
        padding: 8px 0;
        margin-bottom: 4px;
        white-space: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .g247__breadcrumb::-webkit-scrollbar { display: none; }

    .g247__title {
        font-size: 22px;
        line-height: 1.25;
        margin: 0 0 8px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .g247__price-now {
        font-size: 20px;
    }

    .g247__price-was {
        font-size: 13px;
    }

    .g247__price-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-bottom: 12px;
    }

    .g247__rating { margin-left: 0; }

    /* ── Gallery ── */
    .g247__gallery {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

    .g247__main-image {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .g247__thumbs {
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
    }

    .g247__thumb {
        width: 56px;
        height: 56px;
        flex: 0 0 auto;
    }

    /* ── Cart form & calculator hardening ──
       Anything inside the cart form must respect the column width.
       The calculator (.ag-area-calculator) is rendered here by the plugin
       — force border-box so its border + padding stay within bounds. */
    .g247__cart-form,
    .g247__cart-form > *,
    .g247__cart-form form,
    .g247__cart-form .ag-area-calculator {
        max-width: 100%;
        box-sizing: border-box;
        min-width: 0;
    }

    .g247__cart-form .ag-area-calculator,
    .g247__cart-form .ag-area-calculator * {
        box-sizing: border-box !important;
    }

    /* ── Quantity + Add to Cart row ── */
    .g247__qty-row {
        gap: 8px;
        flex-wrap: nowrap;
        align-items: stretch;
    }

    .g247__qty {
        flex: 0 0 auto;
    }

    .g247__qty-input {
        width: 64px;
        height: 100%;
        min-height: 48px;
    }

    .g247__add-to-cart,
    .g247__cart-form .single_add_to_cart_button {
        flex: 1 1 0;
        min-width: 0;
        padding: 14px 12px;
        font-size: 15px;
        min-height: 48px;
    }

    /* ── Swatches: don't let huge images break the grid ── */
    .g247__swatches { gap: 6px; }
    .g247__swatch--image {
        width: calc(33.333% - 4px);
        max-width: 96px;
    }

    /* ── Status / finance rows ── */
    .g247__status-row {
        gap: 12px;
        flex-wrap: wrap;
    }

    .g247__finance {
        font-size: 12px;
        padding: 10px 12px;
    }

    /* ── Why-buys, related, sections ── */
    .g247__why-buys {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

    .g247__related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .g247__related-heading {
        font-size: 20px;
        margin-bottom: 16px;
    }

    .g247__section-heading {
        padding: 16px 0;
        font-size: 16px;
    }

    .g247__section-body {
        font-size: 14px;
    }

    /* Specs already collapse to 1 col at 600px — keep that */
}

/* ── Phone (≤480px) — final tightening ── */
@media (max-width: 480px) {
    .g247 {
        padding: 0 12px 28px !important;
    }

    .g247__title {
        font-size: 20px;
    }

    .g247__price-now {
        font-size: 18px;
    }

    .g247__related-grid {
        grid-template-columns: 1fr;
    }

    .g247__qty-input {
        width: 56px;
    }

    .g247__add-to-cart,
    .g247__cart-form .single_add_to_cart_button {
        padding: 14px 10px;
        font-size: 14.5px;
    }
}
