/*! mk-mobile-responsive.css — MotamedKala mobile overflow / layout fixes
 * Loaded last from app/user blades so it overrides theme CSS safely.
 */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden !important;
}

#app,
#app > div,
.main,
.page-wrapper,
.site-wrapper {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  overscroll-behavior-x: none;
}

/* Global containment: prevent flex/grid children from forcing horizontal scroll */
img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

table {
  max-width: 100%;
}

.container,
.container-fluid,
.row,
[class*="col-"],
.card,
.card-body,
.modal-dialog,
.modal-content,
.main-content,
.page-content,
#app,
#app > div {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.row {
  margin-right: calc(var(--bs-gutter-x, 1.5rem) * -0.5);
  margin-left: calc(var(--bs-gutter-x, 1.5rem) * -0.5);
}

/* Long unbroken strings (Persian/English titles, URLs) */
a,
p,
span,
h1,
h2,
h3,
h4,
h5,
h6,
.cart-item--title,
.cart-item--title a,
.product-information,
.checkout-row-label,
.checkout-row-value {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ========== Cart / Checkout / Shipping / Payment ========== */
@media (max-width: 991.98px) {
  /* Desktop cart thumbnail is flex:0 0 250px — overflows tablets & large phones */
  .cart-item {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
    gap: 12px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }

  .cart-item .cart-item--thumbnail {
    flex: 0 0 auto !important;
    width: 88px !important;
    max-width: 88px !important;
    margin-bottom: 0 !important;
  }

  .cart-item .cart-item--thumbnail img {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
  }

  .cart-item .cart-item--detail {
    flex: 1 1 calc(100% - 110px) !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    text-align: start !important;
  }

  .cart-item .cart-item--detail .cart-item--title,
  .cart-item .cart-item--detail .cart-item--title a {
    text-align: start !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  .cart-item .cart-item--detail .cart-item--data ul li {
    justify-content: flex-start !important;
    flex-wrap: wrap;
  }

  .cart-item .cart-item--detail .cart-item--price--actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px;
    width: 100%;
    justify-content: space-between !important;
    align-items: center !important;
  }

  .cart-item .cart-item--detail .cart-item--price--actions .cart-item--actions {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px;
    width: auto !important;
    justify-content: flex-start !important;
  }

  .cart-item .cart-item--detail .cart-item--price--actions .cart-item--actions .num-block {
    flex: 0 0 auto !important;
    margin: 0 !important;
  }

  .cart-item .cart-item--detail .cart-item--price {
    flex: 1 1 auto !important;
    margin-top: 0 !important;
    text-align: end !important;
  }

  /* Stepper / tabs: allow horizontal scroll instead of overflowing page */
  .cart .nav-tabs,
  .nav.nav-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    width: 100%;
    max-width: 100%;
    scrollbar-width: none;
  }

  .cart .nav-tabs::-webkit-scrollbar,
  .nav.nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .cart .nav-tabs .nav-item,
  .nav.nav-tabs .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .cart .nav-tabs .nav-link,
  .nav.nav-tabs .nav-link {
    white-space: nowrap;
    padding-inline: 12px !important;
  }

  /* Sidebar / summary */
  .cart-sidebar,
  .checkout,
  .checkout-row,
  .discount-container,
  .wallet-container,
  .time-and-send-container,
  .payment-gateways-list,
  .address-container,
  .consignment-container {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  .checkout-row,
  .cart-sidebar .checkout .checkout-row {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px 10px;
    padding: 8px 6px !important;
  }

  .checkout-row-label,
  .checkout-row-value,
  .checkout-row-value--small {
    min-width: 0;
    max-width: 100%;
  }

  .checkout-row-value {
    font-size: 15px !important;
  }

  .checkout-row-value--small {
    font-size: 13px !important;
  }

  .white-space-nowrap,
  .custom-radio-label.white-space-nowrap,
  .price-container.white-space-nowrap {
    white-space: normal !important;
  }

  /* Discount code: input + button stack on narrow screens */
  .form-element-row.with-btn {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px;
    position: relative;
  }

  .form-element-row.with-btn .form-control {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
  }

  .discount-container .form-element-row .btn {
    position: static !important;
    width: 100%;
    margin-top: 0;
  }

  /* Payment gateway radios */
  .payment-gateway-radio-box,
  .custom-radio .custom-radio-label,
  .custom-radio .custom-radio-label .label {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100%;
    box-sizing: border-box;
  }

  .custom-radio .custom-radio-label .label .icon {
    flex: 0 0 auto;
  }

  .custom-radio .custom-radio-label .label .detail {
    flex: 1 1 140px;
    min-width: 0 !important;
  }

  .custom-radio .custom-radio-label .label .detail .title,
  .custom-radio .custom-radio-label .label .detail .subtitle {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .time-and-send-container .radio-send-method .custom-radio .custom-radio-label .label {
    padding: 8px 12px !important;
    width: 100%;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
  }

  /* Shipping consignments */
  .consignment-container .consignments .consignment .consignment-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 100%;
  }

  .consignment-container .consignments .consignment .consignment-items .item-full {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    padding: 12px !important;
  }

  .consignment-container .consignments .consignment .consignment-items .item-full .thumbnail {
    width: 72px !important;
    min-width: 72px !important;
    height: 72px !important;
    min-height: 72px !important;
  }

  .consignment-container .consignments .consignment .consignment-items .item-full .body {
    flex: 1 1 160px;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 0 4px !important;
  }

  .consignment-container .consignments .consignment .consignment-items .item-full .body h4 {
    max-width: 100% !important;
  }

  .consignment-container .consignments .consignment .consignment-items .item-full .body .cart-item--data ul li,
  .consignment-container .consignments .consignment .consignment-items .item-full .body .cart-item--price {
    white-space: normal !important;
  }

  /* Address cards / map */
  .address-container .modal .map-container,
  .order-addresses .modal .map-container,
  .map-container {
    width: 100% !important;
    max-width: 100% !important;
    height: min(55vh, 320px) !important;
  }

  .user-address-item,
  .add-address-container,
  .address-bar-map-container {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Payment status banners */
  .payment-status {
    flex-wrap: wrap !important;
    gap: 8px;
  }

  /* Wallet rows */
  .wallet-container-show,
  .checkout-row.wallet-container-show {
    flex-wrap: wrap !important;
    justify-content: space-between !important;
  }

  .cart-sidebar .wallet-container .wallet-container-show .checkout-row-value div:last-child span:last-child {
    white-space: normal !important;
  }
}

@media (max-width: 575.98px) {
  .cart-item .cart-item--thumbnail {
    width: 72px !important;
    max-width: 72px !important;
  }

  .cart-item .cart-item--detail {
    flex-basis: calc(100% - 90px) !important;
  }

  .num-block .num-in {
    width: 100px !important;
    height: 42px !important;
  }

  .checkout-row-value {
    font-size: 14px !important;
  }

  .btn.btn-block {
    width: 100%;
  }
}

/* ========== Product show / add to cart ========== */
@media (max-width: 991.98px) {
  .product-base-content-container,
  .product-gallery,
  .product-information,
  .product-actions,
  .product-content,
  .product-sidebar,
  .gallery-img-container,
  .images-container,
  .slider-container,
  .seller-list-container {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .seller-list-container .seller-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .seller-list-container .seller-table .seller-item {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
    gap: 8px 12px;
    padding: 12px !important;
    width: 100%;
    box-sizing: border-box;
  }

  .seller-list-container .seller-table .seller-item .seller-item-col {
    flex: 1 1 140px !important;
    min-width: 0 !important;
    margin: 4px 0 !important;
  }

  .seller-list-container .seller-table .seller-item .seller-item-col--action,
  .seller-list-container .seller-table .seller-item .seller-item-col--price {
    flex: 1 1 100% !important;
  }

  .price-count-container,
  .price-container {
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap !important;
  }

  .product-navigation-bottom {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box;
  }

  .product-navigation-bottom .d-flex {
    flex-wrap: wrap;
    gap: 8px;
  }

  .product-navigation-bottom .add-to-cart,
  .product-navigation-bottom .btn {
    max-width: 100%;
  }

  .color-container,
  .type-container {
    max-width: 100%;
  }
}

/* ========== Header / menus / banners ========== */
@media (max-width: 991.98px) {
  .mega-menu,
  .header-four,
  .top-banner-section,
  .main-menu,
  .category-menu {
    max-width: 100vw;
  }

  .mega-menu .container,
  .header-four .container {
    padding-inline: 12px;
  }

  /* Avoid fixed language switcher covering content awkwardly */
  .mk-lang-switcher {
    top: 6px !important;
    inset-inline-end: 6px !important;
  }

  .mk-lang-switcher .mk-lang-menu {
    min-width: 140px !important;
    max-width: calc(100vw - 24px);
  }
}

/* ========== Modals / forms / misc ========== */
@media (max-width: 991.98px) {
  .modal-dialog {
    margin: 0.5rem auto;
    width: calc(100% - 1rem);
    max-width: calc(100% - 1rem) !important;
  }

  .modal-body {
    max-width: 100%;
    overflow-x: hidden;
  }

  input,
  select,
  textarea,
  .form-control {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Swiper / carousels shouldn't expand page */
  .swiper,
  .swiper-wrapper,
  .swiper-slide {
    max-width: 100%;
  }

  /* Simplebar / sticky sidebars */
  .simplebar-container,
  .comments-sidebar-sticky {
    max-width: 100%;
  }
}

/* Tiny phones */
@media (max-width: 379.98px) {
  .container {
    padding-inline: 10px !important;
  }

  .cart-item .cart-item--detail .cart-item--price--actions {
    flex-direction: column;
    align-items: stretch !important;
  }

  .cart-item .cart-item--detail .cart-item--price {
    text-align: start !important;
  }
}


/* ========== Homepage product carousels / cards ========== */
@media (max-width: 991.98px) {
  .category-products-box-container,
  .category-products-box--card,
  .category-products-box--slider,
  .amazing-product-container,
  .product-slider,
  .swiper {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: hidden;
  }

  .category-products-box-container .category-products-box--card .col-lg-3,
  .category-products-box-container .category-products-box--card .col-lg-9 {
    width: 100% !important;
    max-width: 100% !important;
  }

  .category-products-box-container .category-products-box--card .category-products-box--data .body {
    padding: 16px !important;
  }

  .category-products-box-container .category-products-box--card .category-products-box--data .body .he {
    white-space: normal !important;
  }

  /* Keep Swiper-managed widths; clip inside the carousel, not the page */
  .category-products-box--slider,
  .category-products-box--slider .body,
  .amazing-product-container,
  .product-slider,
  .swiper {
    overflow: hidden !important;
    max-width: 100% !important;
  }

  .category-products-box--slider .swiper-slide,
  .amazing-product-container .swiper-slide,
  .product-slider .swiper-slide {
    box-sizing: border-box;
    min-width: 0 !important;
  }

  .product,
  .category-products-box-container .product,
  .amazing-product-container .product {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    overflow: hidden;
  }

  .product .product-thumbnail,
  .category-products-box-container .product .product-thumbnail,
  .amazing-product-container .product .product-thumbnail {
    margin-bottom: 12px !important;
    padding: 12px 8px !important;
    width: 100% !important;
    box-sizing: border-box;
  }

  .product .product-thumbnail img,
  .category-products-box-container .product .product-thumbnail img,
  .amazing-product-container .product .product-thumbnail img,
  .product-slider .product .product-thumbnail img,
  .archive-products .product .product-thumbnail img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 140px !important;
  }

  .product .product-title,
  .category-products-box-container .product .product-title {
    font-size: 13px !important;
    line-height: 1.45 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 0 !important;
    margin-bottom: 8px !important;
  }

  .product .product-body,
  .product .product-footer,
  .product-body .product-footer {
    max-width: 100%;
    min-width: 0;
  }

  .product .product-footer,
  .product-body .product-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    padding-inline: 4px;
  }

  .product-body .product-footer .product-price-now,
  .product .product-footer .product-price-now {
    white-space: normal !important;
    font-size: 13px !important;
    letter-spacing: 0 !important;
  }

  .category-products-box-container .product .discount-percent,
  .product .discount-percent {
    position: static !important;
    display: inline-flex !important;
    margin-top: 4px;
    right: auto !important;
    bottom: auto !important;
  }

  /* Search bar: avoid cramped nested button overflow */
  .header-search,
  .search-form,
  .main-search,
  form.search {
    max-width: 100%;
  }

  .header-search .form-control,
  .search-form .form-control {
    min-width: 0 !important;
  }
}

@media (max-width: 575.98px) {
  .product .product-thumbnail img,
  .category-products-box-container .product .product-thumbnail img {
    max-height: 120px !important;
  }

  .category-products-box-container .product .product-thumbnail {
    padding: 10px 6px !important;
  }
}
