/* VietMart Studio 4.1.4.1 — Safe Mobile Layout Fix
 * Narrow selectors only. Does not alter Flatsome grid columns globally.
 */
@media (max-width: 849px) {
  /* Prevent page-level horizontal scrolling without changing every WooCommerce child. */
  html, body { max-width: 100%; overflow-x: hidden; }

  /* ---------- MINI CART ---------- */
  .mfp-wrap .mfp-content { width: min(94vw, 400px) !important; max-width: min(94vw, 400px) !important; }
  .cart-popup-inner, .widget_shopping_cart { width: 100% !important; max-width: 100% !important; }
  .woocommerce-mini-cart-item { min-width: 0; }
  .woocommerce-mini-cart-item > a:not(.remove),
  .woocommerce-mini-cart-item .quantity { overflow-wrap: break-word; }
  .woocommerce-mini-cart__buttons { display: grid !important; gap: 10px !important; }
  .woocommerce-mini-cart__buttons .button { width: 100% !important; margin: 0 !important; white-space: normal !important; }

  /* ---------- CART PAGE ---------- */
  body.woocommerce-cart .woocommerce-cart-form,
  body.woocommerce-cart .cart-collaterals,
  body.woocommerce-cart .cart_totals { width: 100% !important; max-width: 100% !important; float: none !important; }
  body.woocommerce-cart .coupon { width: 100% !important; }
  body.woocommerce-cart .coupon input,
  body.woocommerce-cart .coupon button,
  body.woocommerce-cart .wc-proceed-to-checkout a { max-width: 100% !important; white-space: normal !important; }

  /* ---------- CHECKOUT ---------- */
  body.woocommerce-checkout form.checkout,
  body.woocommerce-checkout #customer_details,
  body.woocommerce-checkout #order_review,
  body.woocommerce-checkout #order_review_heading,
  body.woocommerce-checkout .col2-set,
  body.woocommerce-checkout .col2-set .col-1,
  body.woocommerce-checkout .col2-set .col-2 {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  body.woocommerce-checkout .form-row-first,
  body.woocommerce-checkout .form-row-last,
  body.woocommerce-checkout .form-row-wide {
    width: 100% !important;
    float: none !important;
  }
  body.woocommerce-checkout input.input-text,
  body.woocommerce-checkout select,
  body.woocommerce-checkout textarea,
  body.woocommerce-checkout .select2-container { width: 100% !important; max-width: 100% !important; }

  /* Keep the review table natural. The previous fixed table widths compressed shipping labels. */
  body.woocommerce-checkout table.shop_table,
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table {
    width: 100% !important;
    table-layout: auto !important;
  }
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table th,
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table td {
    width: auto !important;
    max-width: none !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
  }
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table .product-name { width: 68% !important; text-align: left !important; }
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table .product-total { width: 32% !important; text-align: right !important; }
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals th,
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table tr.shipping th {
    display: block !important;
    width: 100% !important;
    padding-bottom: 8px !important;
  }
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals td,
  body.woocommerce-checkout table.woocommerce-checkout-review-order-table tr.shipping td {
    display: block !important;
    width: 100% !important;
    text-align: left !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  body.woocommerce-checkout ul#shipping_method,
  body.woocommerce-checkout ul.woocommerce-shipping-methods {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
  }
  body.woocommerce-checkout ul#shipping_method li,
  body.woocommerce-checkout ul.woocommerce-shipping-methods li {
    display: grid !important;
    grid-template-columns: 26px minmax(0,1fr) !important;
    gap: 8px !important;
    align-items: start !important;
    width: 100% !important;
    margin: 0 0 12px !important;
    padding: 0 !important;
    text-align: left !important;
  }
  body.woocommerce-checkout ul#shipping_method input,
  body.woocommerce-checkout ul.woocommerce-shipping-methods input { margin: 3px 0 0 !important; }
  body.woocommerce-checkout ul#shipping_method label,
  body.woocommerce-checkout ul.woocommerce-shipping-methods label {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    line-height: 1.45 !important;
  }

  body.woocommerce-checkout #payment,
  body.woocommerce-checkout .woocommerce-checkout-payment { width: 100% !important; max-width: 100% !important; }
  body.woocommerce-checkout .wc_payment_method > label,
  body.woocommerce-checkout .payment_box { max-width: 100% !important; white-space: normal !important; }
  body.woocommerce-checkout #place_order { width: 100% !important; max-width: 100% !important; white-space: normal !important; }

  /* Shipping progress notice: normal sentence flow, never letter-by-letter. */
  body.woocommerce-checkout .vm40-shipping,
  body.woocommerce-cart .vm40-shipping {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }
  body.woocommerce-checkout .vm40-shipping strong,
  body.woocommerce-cart .vm40-shipping strong {
    display: block !important;
    width: 100% !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  /* Cart-only secondary free-shipping notice. The primary progress card is untouched. */
  body.woocommerce-cart .woocommerce-cart-form > .vm-shipping-progress {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 9px 12px !important;
    border: 0 !important;
    border-radius: 9px !important;
    background: #f1f8f3 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }
  body.woocommerce-cart .woocommerce-cart-form > .vm-shipping-progress > .vm-shipping-progress__top,
  body.woocommerce-cart .woocommerce-cart-form > .vm-shipping-progress > .vm-shipping-progress__top > span {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    color: #315c40 !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    text-align: center !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
  }
  body.woocommerce-cart .woocommerce-cart-form > .vm-shipping-progress > .vm-shipping-progress__top > strong,
  body.woocommerce-cart .woocommerce-cart-form > .vm-shipping-progress > .vm-shipping-progress__track {
    display: none !important;
  }

  /* ---------- ORDER COMPLETE / ZELLE ---------- */
  body.woocommerce-order-received .vm411-order-root,
  body.woocommerce-order-received .vm408-zelle-layout,
  body.woocommerce-order-received .vm408-zelle-main,
  body.woocommerce-order-received .vm40-zelle-help {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  body.woocommerce-order-received .vm408-zelle-layout { display: block !important; margin: 16px 0 24px !important; }
  body.woocommerce-order-received .vm408-zelle-main,
  body.woocommerce-order-received .vm40-zelle-help { padding: 17px !important; }
  body.woocommerce-order-received .vm40-zelle-help { margin-top: 18px !important; position: static !important; }
  body.woocommerce-order-received .vm40-zelle-head { display: block !important; }
  body.woocommerce-order-received .vm40-zelle-status { display: inline-flex !important; max-width: 100% !important; margin-top: 12px !important; white-space: normal !important; }
  body.woocommerce-order-received .vm408-pay-grid,
  body.woocommerce-order-received .vm40-zelle-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  body.woocommerce-order-received .vm40-zelle-row,
  body.woocommerce-order-received .vm40-zelle-qr { width: 100% !important; max-width: 100% !important; min-height: 0 !important; padding: 16px !important; }
  body.woocommerce-order-received .vm40-zelle-row strong,
  body.woocommerce-order-received .vm40-zelle-note,
  body.woocommerce-order-received .vm40-zelle-action-note,
  body.woocommerce-order-received .vm40-zelle-confirmed,
  body.woocommerce-order-received .vm40-zelle-help p,
  body.woocommerce-order-received .vm40-zelle-help a {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }
  body.woocommerce-order-received .vm40-copy { position: static !important; transform: none !important; margin-top: 10px !important; }
  body.woocommerce-order-received .vm40-zelle-qr img { display: block !important; width: min(230px, 76vw) !important; max-width: 100% !important; margin: 14px auto 0 !important; }
  body.woocommerce-order-received .vm40-zelle-sent-button { width: 100% !important; max-width: 100% !important; min-width: 0 !important; white-space: normal !important; padding: 14px 16px !important; line-height: 1.3 !important; }

  /* Vertical tracker only within the custom Zelle tracker. */
  body.woocommerce-order-received .vm40-progress { overflow: visible !important; padding: 18px 16px !important; }
  body.woocommerce-order-received .vm40-progress ol { display: block !important; width: 100% !important; min-width: 0 !important; margin: 0 !important; padding: 0 !important; }
  body.woocommerce-order-received .vm40-progress li {
    position: relative !important;
    display: grid !important;
    grid-template-columns: 34px minmax(0,1fr) !important;
    grid-template-rows: auto auto auto !important;
    column-gap: 12px !important;
    min-height: 76px !important;
    padding: 0 0 18px !important;
    text-align: left !important;
    align-items: start !important;
  }
  body.woocommerce-order-received .vm40-progress li:last-child { min-height: 36px !important; padding-bottom: 0 !important; }
  body.woocommerce-order-received .vm40-progress li::after {
    content: "" !important;
    position: absolute !important;
    left: 14px !important;
    top: 28px !important;
    width: 3px !important;
    height: calc(100% - 17px) !important;
    background: #d1d5db !important;
  }
  body.woocommerce-order-received .vm40-progress li.is-complete::after { background: #16a34a !important; }
  body.woocommerce-order-received .vm40-progress li:last-child::after { display: none !important; }
  body.woocommerce-order-received .vm40-progress-dot { grid-column: 1 !important; grid-row: 1 / span 3 !important; width: 30px !important; height: 30px !important; margin: 0 !important; z-index: 2 !important; }
  body.woocommerce-order-received .vm40-progress li strong { grid-column: 2 !important; grid-row: 1 !important; margin: 2px 0 3px !important; text-align: left !important; }
  body.woocommerce-order-received .vm40-progress li small { grid-column: 2 !important; grid-row: 2 !important; text-align: left !important; }
  body.woocommerce-order-received .vm40-progress li em { grid-column: 2 !important; grid-row: 3 !important; justify-self: start !important; margin-top: 6px !important; }

  /* Order action buttons: full-width rows without collapsing table cells. */
  body.woocommerce-order-received .woocommerce-order-details tfoot td:has(a.button.pay),
  body.woocommerce-view-order .woocommerce-order-details tfoot td:has(a.button.pay) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: auto !important;
  }
  body.woocommerce-order-received .woocommerce-order-details a.button.pay,
  body.woocommerce-order-received .woocommerce-order-details a.button.cancel,
  body.woocommerce-view-order .woocommerce-order-details a.button.pay,
  body.woocommerce-view-order .woocommerce-order-details a.button.cancel {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 13px 15px !important;
    justify-content: center !important;
    white-space: normal !important;
    word-break: normal !important;
  }
}
