/*
 * OFFRAMP — Cart & Checkout Coupon UI v1.0.2
 * For the current CozyCorner CLASSIC cart/checkout templates only.
 * Intentionally no JavaScript, coupon value logic, templates, or payment changes.
 * Source visual approved: OFFRAMP_Coupon_UI_Visual_Preview.html
 */

/* ===== 0. Brand tokens; scoped to the coupon itself ===== */
body.woocommerce-cart .woocommerce-cart-form .coupon,
body.woocommerce-checkout:not(.woocommerce-order-received) .checkout-coupon-wrapper {
    --or-coupon-gold: #bd975a;
    --or-coupon-ink: #111111;
    --or-coupon-muted: #666666;
    --or-coupon-line: #e8e3d9;
    box-sizing: border-box;
}

/* ===== 1. Shared visual heading, generated by the theme PHP hooks ===== */
body.woocommerce-cart .offramp-coupon-heading,
body.woocommerce-checkout .checkout-coupon-wrapper .offramp-coupon-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 13px;
    padding: 0;
    text-align: left;
    width: 100%;
    color: #111;
}
body.woocommerce-cart .offramp-coupon-heading__text,
body.woocommerce-checkout .offramp-coupon-heading__text { min-width: 0; flex: 1 1 auto; }
body.woocommerce-cart .offramp-coupon-kicker,
body.woocommerce-checkout .offramp-coupon-kicker {
    display: block;
    margin: 0 0 5px;
    color: #a17a3c;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: .18em;
    text-transform: uppercase;
}
body.woocommerce-cart .offramp-coupon-title,
body.woocommerce-checkout .offramp-coupon-title {
    margin: 0 0 5px !important;
    padding: 0 !important;
    border: 0 !important;
    font-size: 18px !important;
    line-height: 1.25 !important;
    letter-spacing: -.02em;
    font-weight: 800 !important;
    color: #111 !important;
    text-transform: none;
}
body.woocommerce-cart .offramp-coupon-description,
body.woocommerce-checkout .offramp-coupon-description {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 12px !important;
    font-weight: 400;
    line-height: 1.55 !important;
    color: #666 !important;
}
/* v1.0.1: public campaign link, not a coupon submit button. */
body.woocommerce-cart .offramp-coupon-heading .offramp-coupon-offers-link,
body.woocommerce-checkout .checkout-coupon-wrapper .offramp-coupon-heading .offramp-coupon-offers-link {
    display: inline-flex !important;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    min-height: 38px;
    max-width: 100%;
    padding: 9px 13px !important;
    margin: 0 !important;
    border: 1px solid #bd975a !important;
    border-radius: 2px !important;
    background: #fff !important;
    box-shadow: none !important;
    color: #886529 !important;
    font-size: 10px !important;
    line-height: 1.4 !important;
    font-weight: 800 !important;
    letter-spacing: .08em;
    text-align: center;
    text-decoration: none !important;
    white-space: normal;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
body.woocommerce-cart .offramp-coupon-heading .offramp-coupon-offers-link::after,
body.woocommerce-checkout .checkout-coupon-wrapper .offramp-coupon-heading .offramp-coupon-offers-link::after {
    content: "\2197";
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}
body.woocommerce-cart .offramp-coupon-heading .offramp-coupon-offers-link:hover,
body.woocommerce-checkout .checkout-coupon-wrapper .offramp-coupon-heading .offramp-coupon-offers-link:hover {
    background: #111 !important;
    color: #e8cc91 !important;
    border-color: #111 !important;
}
body.woocommerce-cart .offramp-coupon-heading .offramp-coupon-offers-link:focus-visible,
body.woocommerce-checkout .checkout-coupon-wrapper .offramp-coupon-heading .offramp-coupon-offers-link:focus-visible {
    outline: 2px solid #bd975a !important;
    outline-offset: 3px;
}

/* ===== 2. Cart: retain the existing native coupon position ===== */
body.woocommerce-cart .woocommerce table.shop_table.cart td.actions .coupon,
body.woocommerce-cart .woocommerce-page table.cart td.actions .coupon {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 190px !important;
    gap: 10px !important;
    align-items: stretch !important;
    flex: 0 1 760px;
    width: min(760px, 100%) !important;
    max-width: 100%;
    min-width: 0;
    padding: 18px 20px 18px 20px !important;
    border: 1px solid #e8e3d9 !important;
    border-left: 4px solid #bd975a !important;
    border-radius: 0 !important;
    background: linear-gradient(90deg, #fff 0%, #fff 78%, #fdfbf7 100%) !important;
    box-shadow: 0 7px 20px rgb(30 30 30 / 3%);
    float: none !important;
    position: relative !important;
    overflow: visible !important;
    height: auto !important;
}
body.woocommerce-cart .woocommerce table.cart td.actions .coupon .offramp-coupon-cart-heading {
    grid-column: 1 / -1;
    order: -2;
    margin-bottom: 3px;
}
body.woocommerce-cart .woocommerce table.cart td.actions .coupon #coupon_code,
body.woocommerce-cart .woocommerce table.cart td.actions .coupon input.input-text[name="coupon_code"] {
    box-sizing: border-box !important;
    display: block !important;
    grid-column: 1;
    min-width: 0 !important;
    width: 100% !important;
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 !important;
    padding: 0 16px !important;
    border: 1px solid #989898 !important;
    border-radius: 2px !important;
    background: #fff !important;
    box-shadow: none !important;
    outline: 0;
    color: #171717 !important;
    font-size: 14px !important;
    font-weight: 600;
    letter-spacing: .02em;
}
body.woocommerce-cart .woocommerce table.cart td.actions .coupon .button[name="apply_coupon"] {
    box-sizing: border-box !important;
    display: inline-flex !important;
    grid-column: 2;
    align-items: center;
    justify-content: center;
    min-width: 0 !important;
    width: 100% !important;
    min-height: 50px !important;
    height: 50px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    border: 1px solid #111 !important;
    border-radius: 2px !important;
    background: #111 !important;
    color: #f0d49b !important;
    box-shadow: none !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    letter-spacing: .085em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ===== 3. Checkout: ALWAYS show the original standalone Woo coupon form ===== */
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper {
    box-sizing: border-box;
    position: relative;
    display: block;
    width: min(1060px, 100%);
    max-width: 100%;
    margin: 0 0 28px !important;
    padding: 21px 24px 20px 24px !important;
    border: 1px solid #e8e3d9 !important;
    border-left: 4px solid #bd975a !important;
    border-radius: 0 !important;
    background: linear-gradient(90deg, #fff 0%, #fff 78%, #fdfbf7 100%) !important;
    box-shadow: 0 7px 20px rgb(30 30 30 / 3%);
    overflow: visible !important;
}
/* WC prints the heading inside an info notice. Make it look like a card heading. */
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper > .woocommerce-info,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper > .woocommerce-form-coupon-toggle,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper > .woocommerce-form-coupon-toggle > .woocommerce-info {
    box-sizing: border-box;
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin: 0 0 13px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #111 !important;
    text-align: left !important;
}
body.woocommerce-checkout .checkout-coupon-wrapper > .woocommerce-info::before,
body.woocommerce-checkout .checkout-coupon-wrapper .woocommerce-form-coupon-toggle .woocommerce-info::before {
    content: none !important;
    display: none !important;
}
/* WooCommerce wc-checkout.js calls .hide() and sometimes .slideUp():
   these explicit rules keep this one form visible without touching its submit. */
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-login-coupon-wrapper .checkout-coupon-wrapper form.checkout_coupon,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper form.woocommerce-form-coupon {
    box-sizing: border-box;
    display: flex !important;
    flex-flow: row wrap !important;
    align-items: stretch !important;
    gap: 10px !important;
    position: static !important;
    width: 100% !important;
    max-width: 710px !important;
    min-height: 50px !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    opacity: 1 !important;
    visibility: visible !important;
    box-shadow: none !important;
}
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon .form-row-first {
    box-sizing: border-box;
    flex: 1 1 420px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon .form-row-last {
    box-sizing: border-box;
    flex: 0 0 190px !important;
    width: 190px !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon .clear { display: none !important; }
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon #coupon_code {
    box-sizing: border-box !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 !important;
    padding: 0 16px !important;
    border: 1px solid #989898 !important;
    border-radius: 2px !important;
    background: #fff !important;
    box-shadow: none !important;
    outline: 0;
    color: #171717 !important;
    font-size: 14px !important;
    font-weight: 600;
    letter-spacing: .02em;
}
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon button[name="apply_coupon"],
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon input[type="submit"][name="apply_coupon"] {
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-width: 0 !important;
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    border: 1px solid #111 !important;
    border-radius: 2px !important;
    background: #111 !important;
    color: #f0d49b !important;
    box-shadow: none !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    letter-spacing: .085em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ===== 3a. Decorative percent prefix INSIDE the existing native input =====
 * Use a background SVG rather than moving/wrapping WooCommerce's input.
 * This preserves coupon_code names, form DOM, Woo AJAX and accessibility.
 * CSS background images are non-interactive; typing/pasting remains normal.
 */
body.woocommerce-cart .woocommerce table.cart td.actions .coupon #coupon_code,
body.woocommerce-cart .woocommerce table.cart td.actions .coupon input.input-text[name="coupon_code"],
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon #coupon_code {
    padding-left: 60px !important;
    background-color: #fff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg stroke='%239a783d' fill='none' stroke-width='2.3' stroke-linecap='round'%3E%3Ccircle cx='6.3' cy='6.5' r='3.1'/%3E%3Cpath d='M5 20 L19 4'/%3E%3Ccircle cx='17.5' cy='17.3' r='3.1'/%3E%3C/g%3E%3C/svg%3E"), linear-gradient(#e7ddca, #e7ddca) !important;
    background-position: 15px center, 46px center !important;
    background-size: 21px 21px, 1px 24px !important;
    background-repeat: no-repeat, no-repeat !important;
}

/* ===== 4. Common interaction states ===== */
body.woocommerce-cart .woocommerce table.cart td.actions .coupon #coupon_code:focus,
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon #coupon_code:focus {
    border-color: #bd975a !important;
    box-shadow: 0 0 0 2px rgb(197 165 109 / 15%) !important;
}
body.woocommerce-cart .woocommerce table.cart td.actions .coupon .button[name="apply_coupon"]:hover,
body.woocommerce-cart .woocommerce table.cart td.actions .coupon .button[name="apply_coupon"]:focus-visible,
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon button[name="apply_coupon"]:hover,
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon button[name="apply_coupon"]:focus-visible,
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon input[type="submit"][name="apply_coupon"]:hover {
    border-color: #bd975a !important;
    background: #bd975a !important;
    color: #111 !important;
}
body.woocommerce-cart .woocommerce table.cart td.actions .coupon :is(#coupon_code,button[name="apply_coupon"]):focus-visible,
body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon :is(#coupon_code,button[name="apply_coupon"]):focus-visible {
    outline: 2px solid #bd975a;
    outline-offset: 2px;
}

/* ===== 5. Error and success notices: always occupy their OWN row ===== */
body.woocommerce-cart .woocommerce table.cart td.actions .coupon .coupon-error-notice,
body.woocommerce-cart .woocommerce table.cart td.actions .coupon .woocommerce-error,
body.woocommerce-cart .woocommerce table.cart td.actions .coupon .woocommerce-message {
    box-sizing: border-box !important;
    position: static !important; /* Overrides CozyCorner's -30px absolute rule */
    order: 9;
    grid-column: 1 / -1 !important;
    display: block !important;
    float: none !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin: 4px 0 0 !important;
    padding: 12px 14px !important;
    border: 1px solid #eed0cb !important;
    border-left: 3px solid #b13c31 !important;
    border-radius: 0 !important;
    background: #fff8f7 !important;
    color: #7d2e27 !important;
    font-size: 12px !important;
    font-weight: 400;
    line-height: 1.6 !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    box-shadow: none !important;
}
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper > .woocommerce-error,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper > .woocommerce-message,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper form.checkout_coupon .coupon-error-notice,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper form.checkout_coupon .woocommerce-error {
    box-sizing: border-box !important;
    position: static !important;
    order: 9;
    flex: 0 0 100% !important;
    display: block !important;
    width: 100% !important;
    max-width: 710px !important;
    height: auto !important;
    margin: 12px 0 0 !important;
    padding: 12px 14px !important;
    border: 1px solid #eed0cb !important;
    border-left: 3px solid #b13c31 !important;
    border-radius: 0 !important;
    background: #fff8f7 !important;
    color: #7d2e27 !important;
    font-size: 12px !important;
    font-weight: 400;
    line-height: 1.6 !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    box-shadow: none !important;
}
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper > .woocommerce-message,
body.woocommerce-cart .woocommerce table.cart td.actions .coupon .woocommerce-message {
    border-color: #d2e5ce !important;
    border-left-color: #58815c !important;
    background: #f7fbf6 !important;
    color: #345c3a !important;
}
/* WooCommerce's generic notices sometimes carry a decorative :before icon. */
body.woocommerce-checkout .checkout-coupon-wrapper .woocommerce-error::before,
body.woocommerce-checkout .checkout-coupon-wrapper .woocommerce-message::before,
body.woocommerce-cart table.cart .coupon .woocommerce-error::before {
    display: none !important;
    content: none !important;
}
body.woocommerce-checkout .checkout-coupon-wrapper .woocommerce-error li,
body.woocommerce-cart table.cart .coupon .woocommerce-error li {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ===== 6. Mobile: avoid squeezed input, overflow or button overlap ===== */
@media (max-width: 767px) {
    body.woocommerce-cart .offramp-coupon-heading,
    body.woocommerce-checkout .checkout-coupon-wrapper .offramp-coupon-heading {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    body.woocommerce-cart .offramp-coupon-heading__text,
    body.woocommerce-checkout .offramp-coupon-heading__text {
        width: 100%;
        flex: 0 0 auto;
    }
    body.woocommerce-cart .offramp-coupon-heading .offramp-coupon-offers-link,
    body.woocommerce-checkout .checkout-coupon-wrapper .offramp-coupon-heading .offramp-coupon-offers-link {
        display: flex !important;
        width: 100%;
        min-height: 42px;
    }
    body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper {
        width: 100%;
        margin-bottom: 22px !important;
        padding: 18px 16px 18px 16px !important;
    }
    body.woocommerce-cart .woocommerce table.shop_table.cart td.actions .coupon {
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
        padding: 18px 16px !important;
    }
    body.woocommerce-cart .woocommerce table.cart td.actions .coupon #coupon_code,
    body.woocommerce-cart .woocommerce table.cart td.actions .coupon .button[name="apply_coupon"] {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        max-width: 100% !important;
    }
    body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon .form-row-first,
    body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon .form-row-last {
        flex: 0 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
    body.woocommerce-checkout .woocommerce .checkout-coupon-wrapper form.checkout_coupon .coupon-error-notice {
        max-width: 100% !important;
    }
}
@media (max-width: 380px) {
    body.woocommerce-cart .offramp-coupon-title,
    body.woocommerce-checkout .offramp-coupon-title { font-size: 17px !important; }
}

/* ===== 7. v1.0.2 — Checkout offer-link arrow alignment (CSS-only fix) =====
 * CozyCorner style.css styles every link inside .woocommerce-info as an
 * UNDERLINE: its ::after is absolutely positioned at width:100%, changing
 * to width:0 on hover. Our Checkout heading resides inside .woocommerce-info,
 * so v1.0.1's ↗ inherited the underline positioning and jumped on hover.
 * The Cart is intentionally not targeted: it already renders correctly.
 */
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper .offramp-coupon-heading a.offramp-coupon-offers-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-flow: row nowrap !important;
    white-space: nowrap !important;
    min-height: 44px !important;
    padding: 11px 17px !important;
    line-height: 1.2 !important;
}
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper .offramp-coupon-heading a.offramp-coupon-offers-link::after,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper .offramp-coupon-heading a.offramp-coupon-offers-link:hover::after,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper .offramp-coupon-heading a.offramp-coupon-offers-link:focus::after {
    content: "\2197" !important;
    display: inline-block !important;
    position: static !important;
    flex: 0 0 auto !important;
    float: none !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-bottom: 0 !important;
    transform: none !important;
    line-height: 1 !important;
    transition: none !important;
}
/* At narrow mobile widths, keep the arrow inline without squashing the text. */
@media (max-width: 420px) {
    body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .checkout-coupon-wrapper .offramp-coupon-heading a.offramp-coupon-offers-link {
        padding: 11px 10px !important;
        font-size: 10px !important;
        letter-spacing: .045em !important;
        gap: 7px !important;
    }
}
