/* Checkout UX for WooCommerce
 * Scoped to body.wcou-active to avoid affecting the rest of the store.
 */

body.wcou-active {
    --wcou-border: rgba(0, 0, 0, .10);
    --wcou-border-strong: rgba(0, 0, 0, .16);
    --wcou-bg-soft: #f7f8fa;
    --wcou-text-soft: #667085;
    --wcou-radius: 10px;
    --wcou-accent: var(--wd-primary-color, var(--wp--preset--color--primary, #2271b1));
}

body.wcou-active .wcou-trust-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 28px;
    margin: 0 0 24px;
    padding: 11px 18px;
    border: 1px solid var(--wcou-border);
    border-radius: var(--wcou-radius);
    background: var(--wcou-bg-soft);
    font-size: 13px;
    line-height: 1.35;
}

body.wcou-active .wcou-trust-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

body.wcou-active .wcou-trust-icon {
    color: var(--wcou-accent);
    font-weight: 800;
}

body.wcou-active .wcou-trust-phone:hover {
    color: var(--wcou-accent);
    text-decoration: underline;
}

body.wcou-active .wcou-coupon {
    max-width: 560px;
    margin: 0 0 22px;
    border-bottom: 1px solid var(--wcou-border);
}

body.wcou-active .wcou-coupon > summary {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 7px 0 10px;
    font-size: 14px;
    font-weight: 600;
}

body.wcou-active .wcou-coupon > summary::marker {
    content: '';
}

body.wcou-active .wcou-coupon .checkout_coupon {
    display: grid !important;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin: 0 0 16px;
    padding: 14px;
    border: 1px solid var(--wcou-border);
    border-radius: var(--wcou-radius);
    background: #fff;
}

body.wcou-active .wcou-coupon .form-row {
    float: none;
    width: auto;
    margin: 0;
}

body.wcou-active .wcou-coupon .button {
    min-height: 44px;
}

/* Main checkout two-column layout. */
body.wcou-active form.woocommerce-checkout {
    display: grid;
    grid-template-columns: minmax(0, 1.34fr) minmax(420px, 1fr);
    column-gap: 34px;
    align-items: start;
    width: 100%;
    max-width: none;
}

body.wcou-active form.woocommerce-checkout > .woocommerce-NoticeGroup,
body.wcou-active form.woocommerce-checkout > .woocommerce-error,
body.wcou-active form.woocommerce-checkout > .woocommerce-message,
body.wcou-active form.woocommerce-checkout > .woocommerce-info {
    grid-column: 1 / -1;
}

body.wcou-active .wcou-checkout-left {
    grid-column: 1;
    grid-row: 1 / span 3;
    min-width: 0;
}

/* Some themes (including Woodmart) wrap the order review in
 * .checkout-order-review. Normalize that wrapper without requiring the theme. */
body.wcou-active form.woocommerce-checkout > .checkout-order-review,
body.wcou-active form.woocommerce-checkout > .wcou-checkout-right {
    grid-column: 2;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    flex-basis: auto !important;
    float: none !important;
    clear: none !important;
    margin: 0 !important;
    box-sizing: border-box;
    justify-self: stretch;
}

body.wcou-active #order_review_heading,
body.wcou-active #order_review {
    min-width: 0;
    width: 100% !important;
    max-width: none !important;
    float: none !important;
    clear: none !important;
    box-sizing: border-box;
}

/* Standard WooCommerce markup can place heading/review directly in the form. */
body.wcou-active form.woocommerce-checkout > #order_review_heading,
body.wcou-active form.woocommerce-checkout > #order_review {
    grid-column: 2;
    justify-self: stretch;
}

body.wcou-active #order_review_heading {
    margin: 0;
    padding: 0 0 13px;
    font-size: 22px;
    line-height: 1.25;
}

body.wcou-active #order_review {
    margin: 0;
    padding: 20px;
    border: 1px solid var(--wcou-border);
    border-radius: var(--wcou-radius);
    background: #fff;
}

body.wcou-active.wcou-sticky-summary #order_review {
    position: sticky;
    top: 112px;
}

/* Customer details */
body.wcou-active #customer_details,
body.wcou-active #customer_details .col-1,
body.wcou-active #customer_details .col-2 {
    float: none;
    width: 100%;
}

body.wcou-active #customer_details {
    display: block;
    margin: 0;
}

body.wcou-active #customer_details .col-2 {
    margin-top: 22px;
}

body.wcou-active .woocommerce-billing-fields,
body.wcou-active .woocommerce-shipping-fields,
body.wcou-active .woocommerce-additional-fields,
body.wcou-active .wcou-payment-section {
    margin: 0 0 24px;
    padding: 24px;
    border: 1px solid var(--wcou-border);
    border-radius: var(--wcou-radius);
    background: #fff;
}

body.wcou-active .woocommerce-billing-fields > h3,
body.wcou-active .woocommerce-shipping-fields > h3,
body.wcou-active .woocommerce-additional-fields > h3 {
    margin-top: 0;
}

body.wcou-active .woocommerce-billing-fields__field-wrapper,
body.wcou-active .woocommerce-shipping-fields__field-wrapper {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
}

body.wcou-active .woocommerce-billing-fields__field-wrapper .form-row-wide,
body.wcou-active .woocommerce-shipping-fields__field-wrapper .form-row-wide,
body.wcou-active #billing_email_field,
body.wcou-active #billing_phone_field,
body.wcou-active #billing_address_1_field,
body.wcou-active #billing_address_2_field,
body.wcou-active #billing_country_field,
body.wcou-active #billing_state_field,
body.wcou-active #shipping_address_1_field,
body.wcou-active #shipping_address_2_field,
body.wcou-active #shipping_country_field,
body.wcou-active #shipping_state_field,
body.wcou-active .wcou-inline-section-title,
body.wcou-active .wcou-company-toggle,
body.wcou-active .wcou-company-field {
    grid-column: 1 / -1;
}

body.wcou-active .wcou-inline-section-title,
body.wcou-active .wcou-section-title {
    margin: 0 0 17px;
    font-size: 19px;
    line-height: 1.25;
    font-weight: 700;
}

body.wcou-active .wcou-details-title {
    margin-top: 12px;
    padding-top: 21px;
    border-top: 1px solid var(--wcou-border);
}

body.wcou-active .form-row {
    margin-bottom: 14px;
}

body.wcou-active .form-row label {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}

body.wcou-active .form-row input.input-text,
body.wcou-active .form-row textarea,
body.wcou-active .form-row .select2-selection,
body.wcou-active .form-row select {
    min-height: 46px;
    border-radius: 8px;
}

body.wcou-active .form-row textarea {
    min-height: 92px;
}

body.wcou-active .wcou-company-toggle {
    justify-self: start;
    margin: 3px 0 14px;
    padding: 7px 0;
    border: 0;
    background: transparent;
    color: var(--wcou-accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

body.wcou-active .wcou-company-field {
    display: none !important;
}

body.wcou-active .wcou-company-field.wcou-company-field-open {
    display: block !important;
}

/* Payment cards: gateway functionality stays WooCommerce-native. */
body.wcou-active .wcou-payment-section #payment {
    margin: 0;
    padding: 0;
    background: transparent;
}

body.wcou-active .wcou-payment-section #payment ul.payment_methods {
    margin: 0;
    padding: 0;
    border: 0;
}

body.wcou-active .wcou-payment-section .wcou-payment-card {
    position: relative;
    margin: 0 0 10px !important;
    padding: 15px 16px !important;
    border: 1px solid var(--wcou-border);
    border-radius: 9px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

body.wcou-active .wcou-payment-section .wcou-payment-card:has(input:checked) {
    border-color: var(--wcou-accent);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .055);
}

body.wcou-active .wcou-payment-section .payment_box {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--wcou-bg-soft);
    font-size: 13px;
}

body.wcou-active .wcou-payment-section .place-order {
    margin: 18px 0 0 !important;
    padding: 0 !important;
}

body.wcou-active .wcou-payment-section #place_order {
    width: 100%;
    min-height: 54px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
}

/* Shipping methods remain WooCommerce-native, but visually become cards. */
body.wcou-active #shipping_method {
    display: grid;
    gap: 8px;
}

body.wcou-active #shipping_method .wcou-shipping-card {
    margin: 0 !important;
    padding: 11px 12px !important;
    border: 1px solid var(--wcou-border);
    border-radius: 8px;
}

/* Order summary */
body.wcou-active #order_review table.shop_table {
    width: 100% !important;
    max-width: none !important;
    margin: 0;
    border: 0;
    table-layout: auto;
}

body.wcou-active #order_review table.shop_table .product-name {
    width: auto !important;
}

body.wcou-active #order_review table.shop_table .product-total {
    width: 32%;
    min-width: 92px;
    text-align: right;
}

body.wcou-active #order_review table.shop_table th,
body.wcou-active #order_review table.shop_table td {
    padding: 12px 0;
    border-color: var(--wcou-border);
    vertical-align: middle;
}

body.wcou-active #order_review .product-name {
    padding-right: 14px;
}

body.wcou-active .wcou-order-product {
    display: flex;
    align-items: center;
    gap: 11px;
}

body.wcou-active .wcou-order-thumb {
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
    border: 1px solid var(--wcou-border);
    border-radius: 7px;
    overflow: hidden;
    background: var(--wcou-bg-soft);
}

body.wcou-active .wcou-order-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body.wcou-active .wcou-order-name {
    min-width: 0;
    font-size: 13px;
    line-height: 1.35;
}

body.wcou-active #order_review .order-total th,
body.wcou-active #order_review .order-total td {
    padding-top: 17px;
    font-size: 18px;
    font-weight: 800;
}

body.wcou-active #order_review .wcou-savings-row th,
body.wcou-active #order_review .wcou-savings-row td {
    font-weight: 700;
}

body.wcou-active .wcou-field-error {
    display: block;
    margin-top: 5px;
    font-size: 12px;
}

body.wcou-active .woocommerce-invalid input.input-text,
body.wcou-active .woocommerce-invalid .select2-selection {
    border-width: 2px;
}

/* Do not let theme floats interfere with our left column. */
body.wcou-active .wcou-checkout-left::after,
body.wcou-active #customer_details::after {
    content: '';
    display: table;
    clear: both;
}

@media (max-width: 1024px) {
    body.wcou-active form.woocommerce-checkout {
        grid-template-columns: minmax(0, 1.2fr) minmax(360px, 1fr);
        column-gap: 24px;
    }

    body.wcou-active.wcou-sticky-summary #order_review {
        top: 88px;
    }
}

@media (max-width: 767px) {
    body.wcou-active .wcou-trust-bar {
        justify-content: flex-start;
        gap: 8px 18px;
        margin-bottom: 18px;
        padding: 10px 12px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    body.wcou-active form.woocommerce-checkout {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    body.wcou-active .wcou-checkout-left,
    body.wcou-active form.woocommerce-checkout > .checkout-order-review,
    body.wcou-active form.woocommerce-checkout > .wcou-checkout-right,
    body.wcou-active #order_review_heading,
    body.wcou-active #order_review {
        width: 100% !important;
        max-width: 100% !important;
    }

    body.wcou-active #order_review_heading {
        order: 2;
        margin-top: 4px;
        padding-top: 8px;
    }

    body.wcou-active #order_review {
        order: 3;
        padding: 16px;
    }

    body.wcou-active.wcou-sticky-summary #order_review {
        position: static;
    }

    body.wcou-active .woocommerce-billing-fields,
    body.wcou-active .woocommerce-shipping-fields,
    body.wcou-active .woocommerce-additional-fields,
    body.wcou-active .wcou-payment-section {
        margin-bottom: 16px;
        padding: 17px 15px;
    }

    body.wcou-active .woocommerce-billing-fields__field-wrapper,
    body.wcou-active .woocommerce-shipping-fields__field-wrapper {
        grid-template-columns: 1fr;
    }

    body.wcou-active .woocommerce-billing-fields__field-wrapper > *,
    body.wcou-active .woocommerce-shipping-fields__field-wrapper > * {
        grid-column: 1 !important;
    }

    body.wcou-active .form-row input.input-text,
    body.wcou-active .form-row textarea,
    body.wcou-active .form-row .select2-selection,
    body.wcou-active .form-row select {
        min-height: 48px;
        font-size: 16px;
    }

    body.wcou-active .wcou-payment-section #place_order {
        min-height: 56px;
    }

    body.wcou-active .wcou-coupon .checkout_coupon {
        grid-template-columns: 1fr;
    }

    body.wcou-active .wcou-coupon .button {
        width: 100%;
    }
}
