/**
 * LelexTea Phase 11.3 — Two-stage flow in one Classic Checkout.
 *
 * Progressive enhancement:
 * staged visibility starts only after JavaScript adds .lelextea-flow-ready.
 */

/* Do not show an inactive stepper before the controller is ready. */
body:not(.lelextea-flow-ready) .lelextea-checkout-flow-steps {
  display: none !important;
}

/* ============================================================
   Step indicator
   ============================================================ */

body.lelextea-commerce-checkout .lelextea-checkout-flow-steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 18px 0 26px;
}

body.lelextea-commerce-checkout .lelextea-flow-step-line {
  display: block;
  height: 2px;
  background: var(--ltc-border, #d9dcd5);
}

body.lelextea-commerce-checkout .lelextea-flow-step {
  min-height: 50px;
  padding: 10px 12px;
  border: 1px solid var(--ltc-border, #d9dcd5);
  border-radius: var(--ltc-radius, 6px);
  background: #fff;
  color: var(--ltc-text, #20251f);
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
}

body.lelextea-commerce-checkout .lelextea-flow-step.is-active {
  border-color: var(--ltc-primary, #2f4a32);
  background: var(--ltc-primary, #2f4a32);
  color: #fff;
}

body.lelextea-commerce-checkout .lelextea-flow-step[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

/* ============================================================
   Neutralize the old desktop two-column Checkout layout
   ============================================================ */

body.lelextea-commerce-checkout.lelextea-flow-ready form.checkout,
body.lelextea-commerce-checkout.lelextea-flow-ready form.woocommerce-checkout {
  display: block !important;
  grid-template-columns: none !important;
  gap: 0 !important;
}

body.lelextea-commerce-checkout.lelextea-flow-ready #customer_details,
body.lelextea-commerce-checkout.lelextea-flow-ready #order_review_heading,
body.lelextea-commerce-checkout.lelextea-flow-ready #order_review {
  position: static !important;
  float: none !important;
  clear: both !important;
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.lelextea-commerce-checkout.lelextea-flow-ready #customer_details {
  display: block !important;
}

body.lelextea-commerce-checkout.lelextea-flow-ready #customer_details .col-1,
body.lelextea-commerce-checkout.lelextea-flow-ready #customer_details .col-2 {
  float: none !important;
  width: 100% !important;
  max-width: none !important;
}

/* ============================================================
   STEP 1 — Customer details and shipping
   ============================================================ */

body.lelextea-flow-ready.lelextea-checkout-step-1 #order_review_heading,
body.lelextea-flow-ready.lelextea-checkout-step-1 #payment,
body.lelextea-flow-ready.lelextea-checkout-step-1 #lelextea-step-two-actions {
  display: none !important;
}

body.lelextea-flow-ready.lelextea-checkout-step-1 #customer_details,
body.lelextea-flow-ready.lelextea-checkout-step-1 #order_review,
body.lelextea-flow-ready.lelextea-checkout-step-1 #lelextea-step-one-actions {
  display: block !important;
}

/* Hide products while keeping the tfoot that contains Avada's nested totals table. */
body.lelextea-flow-ready.lelextea-checkout-step-1
.woocommerce-checkout-review-order-table > thead,
body.lelextea-flow-ready.lelextea-checkout-step-1
.woocommerce-checkout-review-order-table > tbody {
  display: none !important;
}

/* Inside Avada's nested totals table, expose only the two shipping rows. */
body.lelextea-flow-ready.lelextea-checkout-step-1
.awb-cart-totals-table > tbody > tr {
  display: none !important;
}

body.lelextea-flow-ready.lelextea-checkout-step-1
.awb-cart-totals-table > tbody > tr.lelextea-shipping-heading-row,
body.lelextea-flow-ready.lelextea-checkout-step-1
.awb-cart-totals-table > tbody > tr.lelextea-shipping-methods-row {
  display: table-row !important;
}

body.lelextea-flow-ready.lelextea-checkout-step-1
.woocommerce-checkout-review-order-table {
  margin-bottom: 0 !important;
}

body.lelextea-flow-ready.lelextea-checkout-step-1 #order_review {
  margin-top: 18px !important;
}

body.lelextea-flow-ready.lelextea-checkout-step-1
.awb-checkout-totals-wrapper > td {
  padding: 0 !important;
  border: 0 !important;
}

body.lelextea-commerce-checkout .lelextea-step-one-actions {
  clear: both;
  margin: 18px 0 32px;
}

body.lelextea-commerce-checkout .lelextea-continue-payment {
  width: 100%;
  min-height: 54px;
  padding: 12px 18px;
  white-space: normal;
}

body.lelextea-commerce-checkout .lelextea-continue-payment.is-loading {
  opacity: .7;
  cursor: wait;
}

body.lelextea-commerce-checkout .lelextea-flow-notice {
  margin: 0 0 16px !important;
}

/* ============================================================
   STEP 2 — Summary, total and payment
   ============================================================ */

body.lelextea-flow-ready.lelextea-checkout-step-2 #customer_details,
body.lelextea-flow-ready.lelextea-checkout-step-2 #lelextea-step-one-actions {
  display: none !important;
}

body.lelextea-flow-ready.lelextea-checkout-step-2 #order_review_heading,
body.lelextea-flow-ready.lelextea-checkout-step-2 #order_review,
body.lelextea-flow-ready.lelextea-checkout-step-2 #payment,
body.lelextea-flow-ready.lelextea-checkout-step-2 #lelextea-step-two-actions {
  display: block !important;
}

body.lelextea-commerce-checkout .lelextea-step-two-actions {
  clear: both;
  margin: 0 0 22px;
}

body.lelextea-commerce-checkout .lelextea-address-summaries {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0 0 14px;
}

body.lelextea-commerce-checkout .lelextea-address-summary {
  padding: 15px;
  border: 1px solid var(--ltc-border, #d9dcd5);
  border-radius: var(--ltc-radius, 6px);
  background: var(--ltc-bg-soft, #f7f6f1);
}

body.lelextea-commerce-checkout .lelextea-address-summary strong {
  display: block;
  margin-bottom: 7px;
}

body.lelextea-commerce-checkout .lelextea-address-summary p {
  margin: 0;
  color: var(--ltc-muted, #62685f);
  overflow-wrap: anywhere;
}

body.lelextea-commerce-checkout .lelextea-checkout-edit-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

body.lelextea-commerce-checkout
.lelextea-checkout-edit-buttons .button {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  white-space: normal;
  text-align: center;
}

/* ============================================================
   Responsive refinements
   ============================================================ */

@media (min-width: 768px) {
  body.lelextea-commerce-checkout .lelextea-address-summaries {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.lelextea-commerce-checkout .lelextea-checkout-edit-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  body.lelextea-commerce-checkout .lelextea-checkout-flow-steps {
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
    gap: 5px;
  }

  body.lelextea-commerce-checkout .lelextea-flow-step {
    min-height: 54px;
    padding: 8px 7px;
    font-size: 14px;
  }
}
