/* ================================================
   Saifi Checkout – UI/UX Improvements
   ================================================ */

/* ---- Replace Marcellus with Outfit on checkout + cart ----
   Overriding the CSS variable means every selector in acadia-core.css
   that uses var(--tp-ff-marcellus) automatically inherits Outfit
   — no need to list individual selectors.                         */
body.woocommerce-checkout,
body.woocommerce-cart {
    --tp-ff-marcellus: 'Outfit', sans-serif;
}

/* ---- Page heading + step indicator ---- */
.saifi-checkout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.saifi-checkout-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #003b5c;
    line-height: 1.2;
}
.saifi-checkout-steps {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.saifi-step {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #9ca3af;
    font-weight: 500;
}
.saifi-step--active {
    color: #003b5c;
    font-weight: 600;
}
.saifi-step__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    background: #e5e7eb;
    color: #6b7280;
    flex-shrink: 0;
}
.saifi-step--active .saifi-step__num {
    background: #003b5c;
    color: #fff;
}
.saifi-step-arrow {
    color: #d1d5db;
    font-size: 20px;
    line-height: 1;
}

/* ---- Sticky order sidebar ---- */
.tp-woo-checkout-order-details {
    position: sticky;
    top: 20px;
}

/* ---- Place order button – amber to match site CTA ---- */
#place_order,
.woocommerce #payment #place_order,
.woocommerce-checkout #payment #place_order {
    background: #f59e0b !important;
    border-color: #f59e0b !important;
    color: #fff !important;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background 0.2s ease, border-color 0.2s ease;
}
#place_order:hover,
.woocommerce #payment #place_order:hover,
.woocommerce-checkout #payment #place_order:hover {
    background: #d97706 !important;
    border-color: #d97706 !important;
}

/* ---- Fix subtotal color (match total row, remove teal) ---- */
.woocommerce-checkout-review-order-table .cart-subtotal td,
.woocommerce-checkout-review-order-table .cart-subtotal td * {
    color: #111 !important;
}

/* ---- First Name + Last Name side by side ---- */
.tp-woo-input-field .woocommerce-billing-fields__field-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0 16px;
}
.tp-woo-input-field .woocommerce-billing-fields__field-wrapper .form-row-first,
.tp-woo-input-field .woocommerce-billing-fields__field-wrapper .form-row-last {
    width: calc(50% - 8px) !important;
    float: none !important;
    clear: none !important;
    flex: 0 0 calc(50% - 8px);
}
.tp-woo-input-field .woocommerce-billing-fields__field-wrapper .form-row:not(.form-row-first):not(.form-row-last) {
    width: 100% !important;
    flex: 0 0 100%;
}

/* ---- Hide postcode (not used in Lebanon) ---- */
.saifi-field-hidden {
    display: none !important;
}

/* ---- Product thumbnail in order summary ---- */
.woocommerce-checkout-review-order-table th.product-name,
.woocommerce-checkout-review-order-table td.product-name {
    text-align: left !important;
}
.woocommerce-checkout-review-order-table th.product-total,
.woocommerce-checkout-review-order-table td.product-total {
    text-align: right !important;
}
.saifi-order-product-cell {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    width: 100%;
}
.saifi-order-thumb-wrap {
    flex-shrink: 0;
    line-height: 0;
}
.saifi-order-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: block;
}
.saifi-order-product-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.woocommerce-checkout-review-order-table .product-quantity {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

/* ---- Coupon field in order-review sidebar ---- */
/*
 * form-coupon.php override uses <div class="saifi-coupon-container"> instead
 * of <form> to avoid nested-form browser-stripping.
 * The toggle wrapper is intentionally absent in the override.
 */
.woocommerce-checkout .saifi-coupon-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap; /* allow feedback message to wrap below */
    margin: 16px 0 20px;
    padding: 14px;
    background: #f9fafb;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}
/* Input wrapper — grows to fill available width */
.woocommerce-checkout .saifi-coupon-container .tp-return-customer-input {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 !important;
}
/* Text input */
.woocommerce-checkout .saifi-coupon-container input[name="coupon_code"] {
    width: 100% !important;
    height: 38px !important;
    padding: 0 10px !important;
    font-size: 13px !important;
    margin: 0 !important;
    border-radius: 6px;
    box-sizing: border-box;
}
/* Apply button — navy, matches cart page */
.woocommerce-checkout .saifi-coupon-container .tp-return-customer-btn {
    flex: 0 0 auto;
    height: 38px !important;
    line-height: 38px !important;
    padding: 0 16px !important;
    font-size: 13px !important;
    font-weight: 600;
    white-space: nowrap;
    background: #003b5c !important;
    border-color: #003b5c !important;
    color: #fff !important;
    border-radius: 6px !important;
    margin: 0 !important;
}
.woocommerce-checkout .saifi-coupon-container .tp-return-customer-btn:hover {
    background: #002b44 !important;
    border-color: #002b44 !important;
}
/* Inline feedback message */
.saifi-coupon-msg {
    width: 100%;
    font-size: 12px;
    margin-top: 6px;
    padding: 5px 8px;
    border-radius: 4px;
}
.saifi-coupon-msg--ok {
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}
.saifi-coupon-msg--error {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

/* ---- Secure checkout badge ---- */
.saifi-secure-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    font-size: 12px;
    color: #15803d;
    font-weight: 500;
}
.saifi-secure-badge svg {
    flex-shrink: 0;
}

/* ---- Inline validation states ---- */
.woocommerce-checkout .form-row input.saifi-valid,
.woocommerce-checkout .form-row select.saifi-valid {
    border-color: #22c55e !important;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.12) !important;
}
.woocommerce-checkout .form-row input.saifi-invalid,
.woocommerce-checkout .form-row select.saifi-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12) !important;
}
.saifi-field-error {
    display: block;
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.4;
}

/* ---- Mobile: order summary ABOVE billing form ---- */
@media (max-width: 991px) {
    #customer_details {
        display: flex;
        flex-direction: column;
    }
    #customer_details > .col-lg-7 {
        order: 2;
    }
    #customer_details > .col-lg-5 {
        order: 1;
        margin-bottom: 20px;
    }
    /* Un-stick sidebar on small screens */
    .tp-woo-checkout-order-details {
        position: static;
    }
    /* Full-width name fields on mobile */
    .tp-woo-input-field .woocommerce-billing-fields__field-wrapper .form-row-first,
    .tp-woo-input-field .woocommerce-billing-fields__field-wrapper .form-row-last {
        width: 100% !important;
        flex: 0 0 100%;
    }
}
