/**
 * Intent Retarget — Optimized Checkout styles.
 * Everything is scoped under body.ir-co-on (set by checkout-optimize.js only when the
 * stepper actually activates), so degraded/native checkouts are never affected.
 * Mobile-first; desktop refinements in the min-width query at the bottom.
 */

body.ir-co-on .ir-co-hidden { display: none !important; }

/* ── Overall layout: one centered, readable column like a standard wizard ──
   The JS gathers every checkout piece (progress, OTP panel, coupon/login toggles and
   the form itself) into #ir-co-shell, so they all share ONE width and center axis no
   matter how the theme nests its containers. */
body.ir-co-on #ir-co-shell {
  max-width: 720px;
  width: 100%;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 0 16px;
  box-sizing: border-box;
  float: none;
}
body.ir-co-on .woocommerce-notices-wrapper {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

/* Coupon entry belongs with payment (step 3); login prompt with verify (step 1). */
body.ir-co-step-1 .woocommerce-form-coupon-toggle,
body.ir-co-step-1 form.checkout_coupon,
body.ir-co-step-2 .woocommerce-form-coupon-toggle,
body.ir-co-step-2 form.checkout_coupon,
body.ir-co-step-2 .woocommerce-form-login-toggle,
body.ir-co-step-2 form.woocommerce-form-login,
body.ir-co-step-3 .woocommerce-form-login-toggle,
body.ir-co-step-3 form.woocommerce-form-login {
  display: none !important;
}

/* CartFlows Instant Checkout hoists #payment (and shipping) out of #order_review.
   Belt-and-suspenders hide via body step class so Payment can't leak under Verify
   even if a node was missed by the JS step list. */
body.ir-co-step-1 #payment,
body.ir-co-step-2 #payment,
body.ir-co-step-1 .wcf-payment-option-heading,
body.ir-co-step-2 .wcf-payment-option-heading,
body.ir-co-step-1 #payment_options_heading,
body.ir-co-step-2 #payment_options_heading,
body.ir-co-step-1 #wcf-ic-shipping,
body.ir-co-step-2 #wcf-ic-shipping,
body.ir-co-step-1 .wcf-shipping-option-heading,
body.ir-co-step-2 .wcf-shipping-option-heading,
body.ir-co-step-1 #wcf_shipping_options_heading,
body.ir-co-step-2 #wcf_shipping_options_heading,
body.ir-co-step-1 .wcf-ic-layout-right-column,
body.ir-co-step-2 .wcf-ic-layout-right-column {
  display: none !important;
}

/* ── Progress header ─────────────────────────────────────────────────────── */
body.ir-co-on #ir-co-progress {
  display: flex;
  gap: 0;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  counter-reset: ir-step;
}
body.ir-co-on #ir-co-progress li {
  flex: 1;
  position: relative;
  text-align: center;
  padding: 6px 4px 2px;
  color: #8a8f98;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}
body.ir-co-on #ir-co-progress li::before {
  counter-increment: ir-step;
  content: counter(ir-step);
  display: block;
  width: 28px;
  height: 28px;
  line-height: 28px;
  margin: 0 auto 6px;
  border-radius: 50%;
  background: #eef0f2;
  color: #6b7280;
  font-size: 13px;
  border: 2px solid #e2e5e9;
  position: relative;
  z-index: 1;
}
/* Connector line between the dots. */
body.ir-co-on #ir-co-progress li + li::after {
  content: "";
  position: absolute;
  top: 20px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: #e2e5e9;
}
body.ir-co-on #ir-co-progress li.ir-co-active { color: #111827; }
body.ir-co-on #ir-co-progress li.ir-co-active::before {
  background: var(--ir-co-accent, #cc1939);
  border-color: var(--ir-co-accent, #cc1939);
  color: #fff;
}
body.ir-co-on #ir-co-progress li.ir-co-done { color: #128c46; }
body.ir-co-on #ir-co-progress li.ir-co-done::before {
  content: "\2713";
  background: #e9fbf0;
  border-color: #25d366;
  color: #128c46;
}

/* ── OTP panel (step 1) ──────────────────────────────────────────────────── */
body.ir-co-on #ir-co-otp,
#ir-co-otp {
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 10px;
  padding: 20px 16px;
  margin: 0 0 20px;
  box-sizing: border-box;
}
#ir-co-otp h3 { margin: 0 0 4px; font-size: 18px; }
#ir-co-otp .ir-co-optional { font-size: 12px; font-weight: 400; color: #6b7280; }
#ir-co-otp p { margin: 0 0 14px; font-size: 14px; color: #4b5563; }
#ir-co-otp input[type="tel"],
#ir-co-otp input[type="text"] {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  border: 1px solid #cfd4da;
  border-radius: 8px;
  margin: 0 0 10px;
  background: #fff;
}
#ir-co-otp input:focus { outline: 2px solid var(--ir-co-accent, #cc1939); border-color: var(--ir-co-accent, #cc1939); }
#ir-co-otp .button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  background: var(--ir-co-accent, #cc1939);
  border: none;
  color: #fff;
  cursor: pointer;
}
#ir-co-otp .button:hover { filter: brightness(0.9); }
#ir-co-otp .button:disabled { opacity: .6; cursor: default; }
#ir-co-otp #ir-co-resend { display: inline-block; margin-top: 10px; font-size: 13px; }
#ir-co-otp #ir-co-error {
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 3px solid #dc2626;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 10px 0 0;
}
#ir-co-otp .ir-co-links {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid #eef0f2;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#ir-co-otp .ir-co-links a { color: #6b7280; text-decoration: underline; }
#ir-co-verified { margin-bottom: 16px; }

/* ── Step panels: keep WooCommerce's own markup, just present it cleanly ───
   Astra's modern checkout pins the two columns with ID selectors
   (#customer_details.col2-set at 55% float:left, #order_review at 40% float:right),
   which out-specifies class rules — match the IDs and force ONE full-width column. */
body.ir-co-on form.checkout .col2-set,
body.ir-co-on form.checkout #customer_details.col2-set,
body.ir-co-on.woocommerce-checkout form #customer_details.col2-set,
body.ir-co-on form.checkout #order_review,
body.ir-co-on.woocommerce-checkout form #order_review,
body.ir-co-on form.checkout #order_review_heading,
body.ir-co-on.woocommerce-checkout form #order_review_heading {
  width: 100% !important;
  float: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  clear: both !important;
}
body.ir-co-on form.checkout .col2-set .col-1,
body.ir-co-on form.checkout .col2-set .col-2,
body.ir-co-on.woocommerce-checkout form #customer_details.col2-set .col-1,
body.ir-co-on.woocommerce-checkout form #customer_details.col2-set .col-2 {
  width: 100% !important;
  float: none !important;
  margin: 0 0 12px;
}
body.ir-co-on form.checkout .col2-set .col-2 { margin-top: 8px; }
body.ir-co-on form.checkout h3,
body.ir-co-on #customer_details h3 {
  font-size: 18px;
  margin: 6px 0 14px;
  padding: 0 0 10px;
  border-bottom: 1px solid #eef0f2;
  font-weight: 700;
}
/* The lead-capture email popup fights the checkout for attention — never show it here. */
body.ir-co-on #ir-popup-overlay { display: none !important; }
body.ir-co-on form.checkout .form-row { margin-bottom: 14px; }
/* Half-width pairs (first/last name) share the row with an even gutter. */
body.ir-co-on form.checkout .form-row-first { float: left; width: 48.5% !important; }
body.ir-co-on form.checkout .form-row-last { float: right; width: 48.5% !important; }
body.ir-co-on form.checkout .form-row-wide { clear: both; }
body.ir-co-on form.checkout .form-row label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 5px;
  color: #374151;
}
body.ir-co-on form.checkout .form-row input.input-text,
body.ir-co-on form.checkout .form-row textarea,
body.ir-co-on form.checkout .form-row select {
  width: 100%;
  font-size: 16px; /* iOS */
  padding: 11px 12px;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid #cfd4da;
  background: #fff;
  color: #111827;
  box-shadow: none;
  line-height: 1.4; /* themes with tall line-heights clip <select> text */
  height: auto;
  min-height: 46px;
}
body.ir-co-on form.checkout .form-row input.input-text:focus,
body.ir-co-on form.checkout .form-row textarea:focus,
body.ir-co-on form.checkout .form-row select:focus {
  outline: 2px solid var(--ir-co-accent, #cc1939);
  border-color: var(--ir-co-accent, #cc1939);
}
/* Country/State selects — beat Astra/WooCommerce select2 skins.
   Astra sets `.select2-selection--single { padding: .8em; height: auto }` which makes the
   field taller than text inputs and pushes the label inward. Reset that and drive ALL
   spacing from the rendered text + one shared chevron. */
body.ir-co-on form.checkout .form-row select,
body.ir-co-on.woocommerce-js form .form-row select,
body.ir-co-on.woocommerce-page form .form-row select {
  height: 46px !important;
  min-height: 46px !important;
  max-height: 46px !important;
  line-height: 24px !important;
  padding: 11px 44px 11px 12px !important;
  margin: 0 !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-color: #fff !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%236b7280' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 16px 16px !important;
  border: 1px solid #cfd4da !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  color: #111827 !important;
  font-size: 16px !important;
  cursor: pointer;
}
body.ir-co-on form.checkout .form-row select::-ms-expand { display: none; }

body.ir-co-on .select2-container,
body.ir-co-on.woocommerce-js .select2-container,
body.ir-co-on form.checkout .form-row .select2-container {
  width: 100% !important;
  margin: 0 !important;
  line-height: normal !important;
}
body.ir-co-on .select2-container .select2-selection--single,
body.ir-co-on.woocommerce-js .select2-container .select2-selection--single,
body.ir-co-on.woocommerce-page .select2-container .select2-selection--single {
  height: 46px !important;
  min-height: 46px !important;
  max-height: 46px !important;
  padding: 0 !important; /* kill Astra's .8em padding */
  margin: 0 !important;
  border: 1px solid #cfd4da !important;
  border-radius: 8px !important;
  background-color: #fff !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%236b7280' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 16px 16px !important;
  box-shadow: none !important;
  outline: none !important;
  display: flex !important;
  align-items: center !important;
}
body.ir-co-on .select2-container--focus .select2-selection--single,
body.ir-co-on .select2-container--open .select2-selection--single,
body.ir-co-on.woocommerce-js .select2-container--focus .select2-selection--single,
body.ir-co-on.woocommerce-js .select2-container--open .select2-selection--single {
  border-color: var(--ir-co-accent, #cc1939) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ir-co-accent, #cc1939) 25%, transparent) !important;
}
body.ir-co-on .select2-container .select2-selection__rendered,
body.ir-co-on.woocommerce-js .select2-container .select2-selection__rendered,
body.ir-co-on.woocommerce-js .select2-container--default .select2-selection--single .select2-selection__rendered {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  line-height: 44px !important;
  height: 44px !important;
  padding: 0 44px 0 12px !important; /* match text-input horizontal padding */
  margin: 0 !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  color: #111827 !important;
  text-align: left !important;
}
/* Hide Select2's triangle AND Astra's leftover arrow slot. */
body.ir-co-on .select2-container .select2-selection__arrow,
body.ir-co-on.woocommerce-js .select2-container .select2-selection__arrow,
body.ir-co-on.woocommerce-js .select2-container--default .select2-selection--single .select2-selection__arrow {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
body.ir-co-on .select2-container .select2-selection__clear {
  display: none !important; /* "×" clear clutters a required country/state field */
}

/* Open menu (Select2 appends this near <body>). */
body.ir-co-on .select2-dropdown,
body.ir-co-on.woocommerce-js .select2-dropdown {
  border: 1px solid #cfd4da !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 28px rgb(17 24 39 / 14%) !important;
  overflow: hidden;
  font-size: 15px;
  z-index: 100001 !important;
  margin-top: 4px;
}
body.ir-co-on .select2-search--dropdown { padding: 8px !important; }
body.ir-co-on .select2-search__field,
body.ir-co-on.woocommerce-js .select2-search__field {
  font-size: 16px !important;
  min-height: 40px !important;
  padding: 8px 10px !important;
  border: 1px solid #cfd4da !important;
  border-radius: 6px !important;
  outline: none !important;
  box-shadow: none !important;
}
body.ir-co-on .select2-search__field:focus { border-color: var(--ir-co-accent, #cc1939) !important; }
body.ir-co-on .select2-results__option,
body.ir-co-on.woocommerce-js .select2-results__option {
  padding: 11px 14px !important;
  font-size: 15px !important;
  color: #111827 !important;
  line-height: 1.35 !important;
}
body.ir-co-on .select2-results__option--highlighted[aria-selected],
body.ir-co-on .select2-results__option--highlighted[data-selected],
body.ir-co-on.woocommerce-js .select2-results__option--highlighted[aria-selected],
body.ir-co-on.woocommerce-js .select2-results__option--highlighted[data-selected] {
  background: var(--ir-co-accent, #cc1939) !important;
  color: #fff !important;
}
body.ir-co-on .select2-results__option[aria-selected="true"]:not(.select2-results__option--highlighted),
body.ir-co-on .select2-results__option[data-selected="true"]:not(.select2-results__option--highlighted) {
  background: #f3f4f6 !important;
  color: #111827 !important;
}
body.ir-co-on form.checkout .woocommerce-checkout-review-order-table { width: 100%; }
body.ir-co-on form.checkout #order_review { overflow-x: auto; }

/* ── Step nav buttons ────────────────────────────────────────────────────── */
body.ir-co-on .ir-co-nav {
  display: flex;
  flex-direction: column-reverse; /* primary action on top on mobile */
  gap: 10px;
  margin: 18px 0 8px;
  clear: both;
}
body.ir-co-on .ir-co-nav .button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  text-align: center;
}
body.ir-co-on .ir-co-nav .ir-co-next {
  background: var(--ir-co-accent, #cc1939);
  border: none;
  color: #fff;
}
body.ir-co-on .ir-co-nav .ir-co-next:hover { filter: brightness(0.9); }
body.ir-co-on .ir-co-nav .ir-co-back {
  background: #fff;
  border: 1px solid #cfd4da;
  color: #374151;
}
.ir-co-pin-hint { font-size: 12px; color: #128c46; margin: 4px 0 0; clear: both; }

/* ── Desktop refinements ─────────────────────────────────────────────────── */
@media (min-width: 768px) {
  body.ir-co-on #ir-co-progress li { font-size: 13px; }
  #ir-co-otp { padding: 24px; }
  #ir-co-otp .ir-co-inline { display: flex; gap: 10px; }
  #ir-co-otp .ir-co-inline input { margin: 0; flex: 1; }
  #ir-co-otp .ir-co-inline .button { width: auto; white-space: nowrap; }
  #ir-co-otp .ir-co-links { flex-direction: row; gap: 24px; }
  body.ir-co-on .ir-co-nav { flex-direction: row; justify-content: space-between; }
  body.ir-co-on .ir-co-nav .button { width: auto; min-width: 200px; }
  body.ir-co-on .ir-co-nav .ir-co-back { min-width: 120px; }
}
