/**
 * BackyCheck Partner Coupon Widget Styles
 */

/* Widget Container */
.backy-coupon-widget {
    margin-bottom: 20px;
    font-family: inherit;
}

/* Form State */
.backy-coupon-form {
    width: 100%;
}

.backy-coupon-input-wrapper {
    display: flex;
    align-items: stretch;
    max-width: 430px;
    border-radius: 10px !important;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.backy-coupon-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #B9B9B9 !important;
    border-right: none !important;
    border-radius: 10px 0 0 10px !important;
    font-size: 14px !important;
    outline: none;
    transition: border-color 0.2s ease;
    min-width: 0;
}

.backy-coupon-input:focus {
    border-color: #4CAF50;
}

.backy-coupon-input::placeholder {
    color: #999;
}

.backy-coupon-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* Apply / Validating button — locked to our brand palette so Elementor's
   global accent color (typically pink/red) can't leak through. */
.backy-coupon-submit,
.backy-coupon-submit:link,
.backy-coupon-submit:visited {
    padding: 12px 20px !important;
    background-color: #8BC53F !important;
    background-image: none !important;
    color: #004525 !important;
    border: 0 !important;
    border-radius: 0 10px 10px 0 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease !important;
    white-space: nowrap !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    padding-inline: 56px !important;
    box-shadow: none !important;
    text-shadow: none !important;
    transform: none !important;
}

.backy-coupon-submit:hover:not(:disabled),
.backy-coupon-submit:focus:not(:disabled) {
    background-color: #004525 !important;
    color: #ffffff !important;
    transform: none !important;
    box-shadow: none !important;
}

/* "Validating..." state — keep brand color, just dim it so the user sees
   activity without the button turning gray/pink/Elementor-accent. */
.backy-coupon-submit:disabled {
    background-color: #8BC53F !important;
    color: #004525 !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* Message Display - Hidden by default, shown via wrapper class */
.backy-coupon-message {
    display: none;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 10px !important;
    font-size: 13px;
    max-width: 430px;
}

/* Show message when wrapper has the appropriate class */
.backy-coupon-widget.has-message .backy-coupon-message {
    display: block;
}

.backy-coupon-message.error {
    background-color: #ffebee;
    color: #c62828;
    border-left: 3px solid #c62828;
}

.backy-coupon-message.success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border-left: 3px solid #4CAF50;
}

/* Validated State */
.backy-coupon-validated {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: #e8f5e9;
    border: 2px solid #4CAF50;
    border-radius: 10px !important;
    max-width: 430px;
}

/* Success "check" badge — locked colors so neither Elementor's global SVG
   styling nor a theme reset can recolor it. */
.backy-coupon-success-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    background-color: #8BC53F !important;
    background-image: none !important;
    color: #ffffff !important;
    border: 0 !important;
    border-radius: 50% !important;
    font-size: 16px !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

/* Force the SVG check to render in solid white. Multiple selectors so any
   Elementor / theme rule targeting svg, path, or fill is overridden. */
.backy-coupon-success-icon svg,
.backy-coupon-success-icon svg * {
    color: #ffffff !important;
    stroke: #ffffff !important;
    fill: none !important;
}

.backy-coupon-success-icon svg {
    width: 14px !important;
    height: 14px !important;
    display: block !important;
}

/* Safety net: if the legacy `&#10004;` char ever renders (e.g. page cache
   served stale HTML), tint it white instead of letting WP's emoji <img>
   show up green-on-transparent. WP's emoji <img> has class="emoji" — hide it. */
.backy-coupon-success-icon img.emoji {
    display: none !important;
}

.backy-coupon-success-text {
    flex: 1;
    font-size: 14px !important;
    color: #2e7d32;
}

.backy-coupon-success-text strong {
    font-weight: 600;
}

/* Remove (X) button — same visual language as the mini-cart delete:
   24x24 chip, low-opacity brand green at rest, intensifies on hover.
   Uses an inline SVG (no font-character alignment glitch). */
.backy-coupon-remove,
.backy-coupon-remove:focus,
.backy-coupon-remove:active {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    background: rgba(139, 197, 63, 0.18) !important;
    background-color: rgba(139, 197, 63, 0.18) !important;
    background-image: none !important;
    border: 0 !important;
    border-radius: 50% !important;
    color: #004525 !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    text-align: center !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    outline: none !important;
    transform: none !important;
    transition: background-color 0.2s !important;
}

.backy-coupon-remove:hover {
    background: rgba(139, 197, 63, 0.7) !important;
    background-color: rgba(139, 197, 63, 0.7) !important;
    color: #004525 !important;
    border: 0 !important;
    transform: none !important;
    box-shadow: none !important;
}

.backy-coupon-remove:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

.backy-coupon-remove svg {
    width: 14px;
    height: 14px;
    pointer-events: none;
}

/* Coupon Required Notice (shown on disabled products) */
.backy-coupon-required-notice {
    display: block;
    color: #f57c00;
    font-size: 0.9em;
    margin-top: 10px;
    padding: 10px;
    background: #fff8e1;
    border-left: 3px solid #ff9800;
    border-radius: 4px !important;
}

/* Disabled state for products when coupon not validated */
.backy-coupon-not-validated .product-items,
.backy-coupon-not-validated .product {
    position: relative;
}

.backy-coupon-not-validated .add_to_cart_button,
.backy-coupon-not-validated .ue-ajax-add-to-cart,
.backy-coupon-not-validated .single_add_to_cart_button,
.backy-coupon-not-validated a[href*="add-to-cart="] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}


/* Responsive adjustments */
@media (max-width: 480px) {
    .backy-coupon-input-wrapper {
        flex-direction: column;
        border-radius: 10px !important;
    }

    .backy-coupon-input {
        border-right: 2px solid #e0e0e0;
        border-bottom: none;
        border-radius: 10px 10px 0 0 !important;
    }

    .backy-coupon-submit {
        border-radius: 0 0 10px 10px !important;
    }

    .backy-coupon-validated {
        flex-wrap: wrap;
    }

    .backy-coupon-success-text {
        flex-basis: calc(100% - 80px);
    }
}

/* ==================================================================================
   MINI-CART (custom, client-side) — independent of UE mini-cart widget.
   Renderable via [backy_mini_cart] shortcode.
   ================================================================================== */

.backy-mini-cart {
    box-sizing: border-box;
    background-color: #e5f1da;
    border-radius: 12px;
    padding: 16px 18px;
    color: #1f3a23;
    font-family: inherit;
    width: 100%;
    max-width: 380px;
    display: block;
}

.backy-mini-cart *,
.backy-mini-cart *::before,
.backy-mini-cart *::after {
    box-sizing: border-box;
}

.backy-mini-cart__container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Header */
.backy-mini-cart__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(0, 90, 35, 0.15);
}

.backy-mini-cart__title {
    font-size: 16px;
    font-weight: 700;
    color: #0e3b1a;
    margin: 0;
}

/* Items list */
.backy-mini-cart__items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    transition: all 0.3s;
    margin-bottom: 8px;
}

.backy-mini-cart__items::-webkit-scrollbar {
    width: 4px;
}

.backy-mini-cart__items::-webkit-scrollbar-track {
    background: transparent;
}

.backy-mini-cart__items::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 4px;
}

/* Individual item */
.backy-mini-cart__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    transition: opacity 0.25s;
}

.backy-mini-cart__item.is-removing {
    opacity: 0.4;
    pointer-events: none;
}

.backy-mini-cart__item-image-wrapper {
    flex-shrink: 0;
    min-width: 45px;
    max-width: 45px;
    display: block;
    line-height: 0;
}

.backy-mini-cart__item-image {
    min-width: 45px;
    max-width: 45px;
    height: auto;
    object-fit: contain;
    display: block;
}

.backy-mini-cart__item-content {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}

.backy-mini-cart__item-body {
    flex: 1;
    min-width: 0;
}

.backy-mini-cart__item-title {
    display: block;
    font-size: 14px;
    line-height: 1.3;
    color: #0e3b1a;
    text-decoration: none;
    margin-bottom: 2px;
    word-break: break-word;
}

.backy-mini-cart__item-price {
    font-size: 14px;
    font-weight: 600;
    color: #0e3b1a;
}

/* Struck original price — 1px smaller + muted so it recedes. */
.backy-mini-cart__item-price del {
    color: #888;
    font-weight: 400;
    font-size: 13px;
    margin-right: 4px;
}

/* Discounted price the customer pays — 2px larger so it stands out. */
.backy-mini-cart__item-price ins {
    text-decoration: none;
    color: #0e3b1a;
    font-size: 16px;
    font-weight: 700;
}

/* Delete button — visible at rest (low-opacity green chip) and intensifies on
   hover. Locked against Elementor's global button overrides. */
.backy-mini-cart__item-delete,
.backy-mini-cart__item-delete:focus,
.backy-mini-cart__item-delete:active {
    flex-shrink: 0 !important;
    cursor: pointer !important;
    background: rgba(139, 197, 63, 0.18) !important;
    background-color: rgba(139, 197, 63, 0.18) !important;
    background-image: none !important;
    border: 0 !important;
    border-radius: 50% !important;
    box-shadow: none !important;
    text-shadow: none !important;
    outline: none !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #004525 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    font-size: 14px !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    transform: none !important;
    transition: background-color 0.2s !important;
}

.backy-mini-cart__item-delete:hover {
    background: rgba(139, 197, 63, 0.7) !important;
    background-color: rgba(139, 197, 63, 0.7) !important;
    color: #004525 !important;
    transform: none !important;
    box-shadow: none !important;
}

.backy-mini-cart__item-delete svg {
    width: 14px;
    height: 14px;
    pointer-events: none;
}

/* Bundle items get a smaller scale (matches the old per-key CSS pattern) */
.backy-mini-cart__item.is-bundle .backy-mini-cart__item-image,
.backy-mini-cart__item.is-bundle .backy-mini-cart__item-image-wrapper {
    min-width: 35px;
    max-width: 35px;
}

.backy-mini-cart__item.is-bundle .backy-mini-cart__item-title,
.backy-mini-cart__item.is-bundle .backy-mini-cart__item-price {
    font-size: 14px;
}

/* Footer */
.backy-mini-cart__footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 90, 35, 0.15);
}

.backy-mini-cart__empty {
    text-align: left;
    padding: 8px 0;
    color: #5a6b5e;
    font-size: 14px;
}

/* Auto-hide the empty message when items exist (CSS :has() — JS fallback also toggles). */
.backy-mini-cart__items:has(.backy-mini-cart__item) ~ .backy-mini-cart__footer .backy-mini-cart__empty {
    display: none !important;
}

.backy-mini-cart__gst {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
    color: #4a5a4e;
    margin-bottom: 4px;
}

.backy-mini-cart__subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 6px;
    margin-bottom: 12px;
    font-weight: 700;
    font-size: 15px;
    color: #0e3b1a;
}

.backy-mini-cart__subtotal-amount .woocommerce-Price-amount {
    font-weight: 700;
}

/* Checkout button — black uppercase text by default, white on hover.
   Locked down to keep Elementor's global button styles from leaking in. */
.backy-mini-cart__checkout,
.backy-mini-cart__checkout:link,
.backy-mini-cart__checkout:visited {
    display: block !important;
    width: 100% !important;
    background-color: #8BC53F !important;
    color: #004525 !important;
    text-align: center !important;
    padding: 12px 16px !important;
    border: 0 !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    text-decoration: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    transition: background-color 0.2s, color 0.2s, opacity 0.2s, filter 0.2s !important;
}

.backy-mini-cart__checkout:hover,
.backy-mini-cart__checkout:focus {
    background-color: #004525 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    box-shadow: none !important;
    transform: none !important;
}

.backy-mini-cart__checkout.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(60%);
    background-color: #bcd3a6;
}

/* ================================================================
   MINI-CART RECONCILE LOADER
   Shown while the JS verifies that localStorage matches the WC session
   on every page load with the mini-cart. Prevents flashing stale items
   to the user when Azure PHP latency leaves the server cart out of sync.
   ================================================================ */
.backy-mini-cart {
    position: relative;
}
.backy-mini-cart__loader {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
}
.backy-mini-cart.is-loading .backy-mini-cart__loader {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.backy-mini-cart__loader-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0, 69, 37, 0.15);
    border-top-color: #8BC53F;
    border-radius: 50%;
    animation: backyMiniCartSpin 0.85s linear infinite;
}
@keyframes backyMiniCartSpin {
    to { transform: rotate(360deg); }
}
