/* UX-MOBILE-APPLY-FIX-2 — mobile refinements for product, cart, checkout.
   Loaded separately with filemtime() cache-busting, after main style.css.
   Breakpoints: 600px, 500px, 430px, 390px. Preserves desktop 1366px. */

/* ===== up to 600px ============================================ */
@media (max-width: 600px) {
  /* --- GENERAL: no horizontal overflow, full width --- */
  .woocommerce-cart main,
  .woocommerce-checkout main,
  .single-product main,
  .single-product .wp-site-blocks main {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow-x: hidden !important;
  }

  .woocommerce-cart .woocommerce,
  .woocommerce-checkout .woocommerce,
  .single-product .woocommerce {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
}

/* ===== up to 500px ============================================ */
@media (max-width: 500px) {
  /* --- CHECKOUT: wider blocks, reduced padding, full-width --- */
  form.checkout {
    width: 100% !important;
    max-width: 100% !important;
  }

  .woocommerce-checkout .col2-set {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .woocommerce-checkout .col2-set .col-1,
  .woocommerce-checkout .col2-set .col-2 {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    flex: none !important;
    padding: 0 !important;
  }

  .woocommerce-checkout .woocommerce-billing-fields,
  .woocommerce-checkout .woocommerce-shipping-fields,
  .woocommerce-checkout .woocommerce-additional-fields,
  .woocommerce-checkout .woocommerce-checkout-review-order {
    width: 100% !important;
    max-width: 100% !important;
    padding: 6px 8px !important;
    border-radius: 4px !important;
    box-sizing: border-box !important;
  }

  .woocommerce-checkout .woocommerce-checkout-payment {
    width: 100% !important;
    max-width: 100% !important;
    padding: 6px 8px !important;
    box-sizing: border-box !important;
    border-radius: 4px !important;
  }

  .woocommerce-checkout .woocommerce-billing-fields h3,
  .woocommerce-checkout .woocommerce-shipping-fields h3,
  .woocommerce-checkout #order_review_heading {
    font-size: 0.95rem !important;
    margin: 4px 0 6px !important;
  }

  .woocommerce-checkout .form-row {
    margin-bottom: 6px !important;
    width: 100% !important;
  }

  .woocommerce-checkout .form-row label {
    font-size: 0.78rem !important;
    margin-bottom: 2px !important;
    line-height: 1.2 !important;
  }

  .woocommerce-checkout .form-row input,
  .woocommerce-checkout .form-row select,
  .woocommerce-checkout .form-row textarea {
    width: 100% !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 16px !important;
    border-radius: 4px !important;
    box-sizing: border-box !important;
  }

  .woocommerce-checkout .form-row-first,
  .woocommerce-checkout .form-row-last {
    width: 100% !important;
    float: none !important;
  }

  .woocommerce-checkout .form-row-wide {
    width: 100% !important;
    clear: both !important;
  }

  .woocommerce-checkout .select2-container {
    width: 100% !important;
  }

  .woocommerce-checkout .select2-container .select2-selection {
    min-height: 40px !important;
    border-radius: 4px !important;
  }

  .woocommerce-checkout .select2-container .select2-selection .select2-selection__rendered {
    line-height: 40px !important;
    font-size: 0.88rem !important;
  }

  .woocommerce-checkout #customer_details {
    margin-bottom: 10px !important;
  }

  .woocommerce-checkout .woocommerce-checkout-review-order-table {
    width: 100% !important;
    min-width: 0 !important;
    display: block !important;
    overflow: visible !important;
    font-size: 0.82rem !important;
  }

  .woocommerce-checkout .woocommerce-checkout-review-order-table th,
  .woocommerce-checkout .woocommerce-checkout-review-order-table td {
    padding: 5px 4px !important;
  }

  .woocommerce-checkout .woocommerce-checkout-review-order-table .product-name {
    word-break: break-word !important;
  }

  .woocommerce-checkout #order_review {
    width: 100% !important;
    float: none !important;
  }

  /* --- CHECKOUT: payment methods --- */
  .woocommerce-checkout .wc_payment_methods {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .woocommerce-checkout .wc_payment_methods li {
    padding: 4px 0 !important;
    margin: 0 !important;
  }

  .woocommerce-checkout .wc_payment_methods li label {
    font-size: 0.82rem !important;
    line-height: 1.25 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 4px 0 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
  }

  .woocommerce-checkout .wc_payment_methods li label img {
    max-width: 90px !important;
    height: auto !important;
  }

  .woocommerce-checkout .wc_payment_methods li input[type="radio"] {
    flex: 0 0 18px !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
  }

  .woocommerce-checkout .wc_payment_methods li .payment_box {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 8px 10px !important;
    margin: 4px 0 0 !important;
    font-size: 0.78rem !important;
    line-height: 1.3 !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
  }

  .woocommerce-checkout .wc_payment_methods li .payment_box p {
    margin: 0 0 4px !important;
    font-size: 0.78rem !important;
    line-height: 1.3 !important;
  }

  .woocommerce-checkout .woocommerce-checkout-payment button,
  .woocommerce-checkout #place_order {
    width: 100% !important;
    min-height: 48px !important;
    font-size: 1rem !important;
    padding: 12px 16px !important;
    border-radius: 4px !important;
    margin-top: 4px !important;
    display: block !important;
  }

  .woocommerce-checkout .place-order {
    padding: 0 !important;
    margin: 0 !important;
  }

  .woocommerce-checkout .woocommerce-terms-and-conditions-wrapper {
    padding: 4px 0 !important;
  }

  .woocommerce-checkout .woocommerce-privacy-policy-text {
    font-size: 0.72rem !important;
    line-height: 1.2 !important;
    margin: 2px 0 4px !important;
  }

  .woocommerce-checkout .woocommerce-privacy-policy-text p {
    font-size: 0.72rem !important;
    margin: 0 !important;
  }

  .woocommerce-checkout .woocommerce-checkout-payment .form-row.place-order {
    margin-top: 4px !important;
  }

  /* --- CHECKOUT: shipping method radios --- */
  .woocommerce-checkout #shipping_method li {
    padding: 3px 0 !important;
  }

  .woocommerce-checkout #shipping_method li label {
    font-size: 0.82rem !important;
    line-height: 1.2 !important;
    word-break: break-word !important;
  }

  .woocommerce-checkout #shipping_method li input[type="radio"] {
    flex: 0 0 18px !important;
    width: 18px !important;
    height: 18px !important;
    margin-right: 4px !important;
  }

  .woocommerce-checkout .woocommerce-shipping-methods {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
  }

  .woocommerce-checkout .woocommerce-shipping-methods li {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
  }

  /* --- CART: product cards, full-width, legible --- */
  .woocommerce-cart .woocommerce-cart-form {
    width: 100% !important;
    max-width: 100% !important;
  }

  .woocommerce-cart table.shop_table {
    min-width: 0 !important;
    width: 100% !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item {
    display: grid !important;
    grid-template-columns: 64px 1fr !important;
    gap: 6px 10px !important;
    padding: 10px !important;
    margin-bottom: 8px !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-thumbnail {
    width: 64px !important;
    padding: 0 !important;
    border: none !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-thumbnail img,
  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-thumbnail a img {
    width: 64px !important;
    height: auto !important;
    max-width: 100% !important;
    display: block !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-name {
    font-size: 0.82rem !important;
    padding-right: 10px !important;
    line-height: 1.15 !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-price {
    font-size: 0.76rem !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-quantity .quantity input.qty {
    width: 56px !important;
    min-height: 32px !important;
    font-size: 0.85rem !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-subtotal {
    font-size: 0.85rem !important;
    padding-top: 6px !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-remove a {
    width: 24px !important;
    height: 24px !important;
    font-size: 0.95rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .woocommerce-cart td.product-name dl.variation,
  .woocommerce-cart td.product-name .wc-item-meta {
    font-size: 0.72rem !important;
  }

  .woocommerce-cart .coupon {
    padding: 10px !important;
    gap: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .woocommerce-cart .coupon label {
    font-size: 0.78rem !important;
  }

  .woocommerce-cart .coupon input#coupon_code {
    width: 100% !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 0.85rem !important;
    box-sizing: border-box !important;
  }

  .woocommerce-cart .coupon button,
  .woocommerce-cart button[name="update_cart"] {
    min-height: 40px !important;
    font-size: 0.85rem !important;
  }

  .woocommerce-cart .actions {
    gap: 8px !important;
  }

  .woocommerce-cart .cart_totals {
    padding: 10px !important;
    margin-top: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .woocommerce-cart .cart_totals h2 {
    font-size: 1rem !important;
    margin-bottom: 10px !important;
  }

  .woocommerce-cart .cart_totals table tr {
    padding: 5px 0 !important;
  }

  .woocommerce-cart .cart_totals table tr th {
    font-size: 0.78rem !important;
  }

  .woocommerce-cart .cart_totals table tr td {
    font-size: 0.82rem !important;
  }

  .woocommerce-cart .cart_totals .order-total th,
  .woocommerce-cart .cart_totals .order-total td {
    font-size: 0.95rem !important;
  }

  .woocommerce-cart .cart_totals .shipping ul {
    margin: 0 !important;
  }

  .woocommerce-cart .cart_totals .shipping li {
    gap: 6px !important;
    padding: 6px 0 !important;
  }

  .woocommerce-cart .cart_totals .shipping li input[type="radio"] {
    flex: 0 0 22px !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
  }

  .woocommerce-cart .cart_totals .shipping li label {
    font-size: 0.82rem !important;
    line-height: 1.25 !important;
    cursor: pointer !important;
  }

  .woocommerce-cart .cart_totals .shipping-calculator-form {
    gap: 6px !important;
    width: 100% !important;
  }

  .woocommerce-cart .cart_totals .shipping-calculator-form select,
  .woocommerce-cart .cart_totals .shipping-calculator-form input {
    width: 100% !important;
    min-height: 40px !important;
    font-size: 0.85rem !important;
    box-sizing: border-box !important;
  }

  .woocommerce-cart .cart_totals .shipping-calculator-form button {
    min-height: 40px !important;
    width: 100% !important;
  }

  .woocommerce-cart .shipping-calculator-button {
    font-size: 0.78rem !important;
  }

  .woocommerce-cart .woocommerce-shipping-destination {
    font-size: 0.76rem !important;
    line-height: 1.25 !important;
  }

  .woocommerce-cart .shipping th {
    font-size: 0.78rem !important;
  }

  .woocommerce-cart .wc-proceed-to-checkout {
    margin-top: 12px !important;
  }

  .woocommerce-cart .wc-proceed-to-checkout a {
    width: 100% !important;
    min-height: 50px !important;
    font-size: 1.05rem !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }

  .woocommerce-cart .woocommerce-message,
  .woocommerce-cart .woocommerce-info {
    font-size: 0.82rem !important;
    padding: 8px 10px !important;
    margin-bottom: 8px !important;
  }

  /* --- CART: cart-collaterals full width --- */
  .woocommerce-cart .cart-collaterals {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* --- PRODUCT: compact CEP calculator --- */
  .single-product .summary {
    width: 100% !important;
    max-width: 100% !important;
  }

  .single-product .product {
    padding: 8px !important;
  }

  .single-product .product > .wp-block-columns.alignwide > .wp-block-column:nth-child(2) {
    padding: 10px !important;
    margin-top: 8px !important;
    border-radius: 6px !important;
  }

  .single-product h1.product_title,
  .single-product .wp-block-post-title {
    font-size: 1.2rem !important;
    margin-bottom: 6px !important;
  }

  .single-product .price {
    font-size: 1.2rem !important;
  }

  .single-product div.product .woocommerce-product-gallery {
    margin-bottom: 8px !important;
  }

  .single-product div.product .woocommerce-product-gallery img.wp-post-image,
  .single-product div.product .woocommerce-product-gallery__image img {
    max-height: 300px !important;
    width: auto !important;
  }

  .single-product .product form.cart,
  .single-product .product .variations_form {
    margin-top: 6px !important;
  }

  .single-product div.product form.cart .variations label {
    font-size: 0.74rem !important;
    margin-bottom: 3px !important;
  }

  .single-product div.product form.cart select,
  .single-product div.product form.cart table.variations select {
    width: 100% !important;
    min-height: 38px !important;
    height: 38px !important;
    padding: 5px 8px !important;
    font-size: 0.85rem !important;
  }

  .single-product div.product form.cart .reset_variations {
    font-size: 0.68rem !important;
    margin: 2px 0 6px !important;
  }

  .single-product div.product form.cart .quantity input.qty,
  .single-product .quantity input.qty {
    width: 60px !important;
    min-height: 38px !important;
    height: 38px !important;
    font-size: 0.85rem !important;
  }

  .single-product div.product form.cart .single_add_to_cart_button {
    width: 100% !important;
    min-height: 42px !important;
    font-size: 0.85rem !important;
  }

  /* --- PRODUCT: eleven-shipping-calc block --- */
  .eleven-product-shipping {
    width: 100% !important;
    max-width: 100% !important;
  }

  .eleven-shipping-calc {
    padding: 10px !important;
    margin-top: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .eleven-shipping-calc-title {
    font-size: 0.82rem !important;
    margin: 0 0 6px !important;
  }

  .eleven-shipping-calc-form {
    gap: 6px !important;
  }

  .eleven-shipping-calc-input {
    width: 100% !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 0.9rem !important;
    box-sizing: border-box !important;
  }

  .eleven-shipping-calc-btn {
    width: 100% !important;
    min-height: 40px !important;
    font-size: 0.88rem !important;
  }

  .eleven-shipping-calc-header {
    padding: 6px 8px !important;
    margin-bottom: 8px !important;
    gap: 4px !important;
  }

  .eleven-shipping-header-cep {
    font-size: 0.78rem !important;
  }

  .eleven-shipping-header-change,
  .eleven-shipping-header-clear {
    font-size: 0.7rem !important;
    padding: 3px 6px !important;
  }

  .eleven-shipping-result-list {
    gap: 6px !important;
  }

  .eleven-shipping-rate-card {
    padding: 8px 10px !important;
    gap: 8px !important;
  }

  .eleven-shipping-rate-radio {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
  }

  .eleven-shipping-rate-card.eleven-shipping-rate-selected .eleven-shipping-rate-radio {
    box-shadow: inset 0 0 0 2.5px #fff !important;
  }

  .eleven-shipping-rate-label {
    font-size: 0.8rem !important;
  }

  .eleven-shipping-rate-time {
    font-size: 0.72rem !important;
  }

  .eleven-shipping-rate-cost {
    font-size: 0.95rem !important;
  }

  .eleven-shipping-calc-loading {
    font-size: 0.78rem !important;
    padding: 8px !important;
  }

  .eleven-shipping-calc-warning,
  .eleven-shipping-calc-error {
    padding: 8px 10px !important;
    font-size: 0.78rem !important;
    margin-top: 6px !important;
  }

  .single-product .wp-block-columns.alignwide {
    margin: 0 !important;
  }

  /* --- RELATED products mobile --- */
  .eleven-v8-related-products {
    margin-top: 24px !important;
    margin-left: -8px !important;
    margin-right: -8px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    padding-top: 16px !important;
  }

  .eleven-v8-related-carousel {
    margin: 0 -8px !important;
  }

  .eleven-v8-related-track {
    gap: 12px !important;
    padding: 0 8px 8px !important;
  }

  .eleven-v8-related-slide {
    flex: 0 0 75% !important;
  }

  .eleven-v8-related-head h2 {
    font-size: 1.2rem !important;
  }

  .eleven-v8-related-head p {
    font-size: 0.78rem !important;
  }

  .eleven-v8-related-nav button {
    width: 28px !important;
    height: 28px !important;
    font-size: 16px !important;
  }

  .eleven-v8-related-actions {
    margin-top: 16px !important;
  }

  .eleven-v8-related-actions a {
    font-size: 0.88rem !important;
    min-height: 40px !important;
  }
}

/* ===== up to 430px ============================================ */
@media (max-width: 430px) {
  .woocommerce-cart main,
  .woocommerce-checkout main,
  .single-product main,
  .single-product .wp-site-blocks main {
    width: calc(100% - 6px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .woocommerce-cart .woocommerce-cart-form,
  .woocommerce-checkout .checkout.woocommerce-checkout {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ===== up to 390px ============================================ */
@media (max-width: 390px) {
  .woocommerce-cart main,
  .woocommerce-checkout main,
  .single-product main,
  .single-product .wp-site-blocks main {
    width: calc(100% - 4px) !important;
    margin: 6px auto !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item {
    grid-template-columns: 54px 1fr !important;
    padding: 8px !important;
    gap: 4px 8px !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-thumbnail {
    width: 54px !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-thumbnail img,
  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-thumbnail a img {
    width: 54px !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-name {
    font-size: 0.76rem !important;
  }

  .woocommerce-cart table.shop_table tbody tr.cart_item td.product-subtotal {
    font-size: 0.8rem !important;
  }

  .woocommerce-checkout .woocommerce-billing-fields,
  .woocommerce-checkout .woocommerce-shipping-fields,
  .woocommerce-checkout .woocommerce-additional-fields,
  .woocommerce-checkout .woocommerce-checkout-review-order {
    padding: 4px 6px !important;
  }

  .woocommerce-checkout .woocommerce-checkout-payment {
    padding: 4px 6px !important;
  }

  .woocommerce-checkout .wc_payment_methods li label {
    font-size: 0.78rem !important;
  }

  .woocommerce-checkout .wc_payment_methods li .payment_box {
    padding: 6px 8px !important;
  }

  .eleven-shipping-calc {
    padding: 8px !important;
  }

  .eleven-shipping-rate-card {
    padding: 6px 8px !important;
  }

  .single-product .product {
    padding: 6px !important;
  }

  .single-product h1.product_title,
  .single-product .wp-block-post-title {
    font-size: 1.1rem !important;
  }
}

/* ===== preserve desktop 1366px ================================ */
@media (min-width: 769px) {
  .woocommerce-cart main,
  .woocommerce-checkout main,
  .single-product main,
  .single-product .wp-site-blocks main {
    width: min(var(--es-shell-max), calc(100% - (var(--es-shell-pad) * 2))) !important;
  }
}

/* PRODUCT-GALLERY-REFORM-1: keep the gallery rail compact after mobile overrides. */
@media (max-width: 600px) {
  body.single-product div.product .woocommerce-product-gallery.woocommerce-product-gallery--with-images {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 58px !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 0 0 10px !important;
  }

  body.single-product div.product .woocommerce-product-gallery .flex-viewport {
    width: 100% !important;
    max-width: 100% !important;
  }

  body.single-product div.product .woocommerce-product-gallery__image img,
  body.single-product div.product .woocommerce-product-gallery img.wp-post-image {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: min(520px, 68vh) !important;
    margin: 0 auto !important;
    object-fit: contain !important;
  }
}
