/* Global Responsive Hardening Layer
   Loaded last to safely override rigid legacy rules without redesigning the UI. */

:root {
  --rm-space-1: 0.5rem;
  --rm-space-2: 0.75rem;
  --rm-space-3: 1rem;
  --rm-space-4: 1.25rem;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  min-width: 0;
}

img,
picture,
video,
canvas,
svg,
iframe {
  max-width: 100%;
  height: auto;
}

/* Keep iframes usable on smaller screens (maps/videos/forms embeds). */
iframe {
  width: 100%;
}

/* Better line wrapping for long urls/content from forms and admin-like text blocks. */
p,
li,
td,
blockquote,
.cp-alert,
.testimonial-quote {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Forms and touch targets */
input,
select,
textarea,
button,
.btn {
  max-width: 100%;
}

button,
.btn,
a.btn,
input[type="submit"] {
  min-height: 42px;
}

.form-control,
select.form-control,
textarea.form-control {
  font-size: 16px;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Force safer behavior on very narrow screens while preserving desktop table style. */
@media (max-width: 767px) {
  table,
  .table,
  .table.table-bordered {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }

  .table thead,
  .table tbody,
  .table tr {
    min-width: 100%;
  }
}

/* Header/search/nav */
.header .navbar-form .form-control {
  width: min(100%, 300px);
}

.menu > ul > li > a {
  line-height: 1.25;
}

@media (max-width: 991px) {
  .header .right ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .header .right ul li {
    margin-left: 0;
  }

  .header .search-area {
    margin-top: 10px;
  }

  .header .navbar-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .header .navbar-form .form-group {
    width: min(100%, 360px);
    margin-bottom: 0;
  }

  .header .navbar-form .form-control {
    width: 100%;
  }

  .top .left ul,
  .top .right ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 12px;
    padding-left: 0;
  }
}

/* Home + mega menu */
@media (max-width: 959px) {
  .menu-mobile {
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.2;
  }

  .menu > ul > li > a {
    padding: 12px 16px;
    line-height: 1.3;
  }

  .menu > ul > li > ul.normal-sub {
    padding: 8px 16px;
  }
}

@media (max-width: 991px) {
  .mg-ambition-inner,
  .mg-about-grid {
    gap: 18px;
  }
}

@media (max-width: 767px) {
  .mg-solutions-grid {
    grid-template-columns: 1fr;
  }

  .mg-catalog-download-btn {
    width: 100%;
    justify-content: center;
  }

  .mg-lead-modal-dialog {
    width: calc(100vw - 20px);
    max-width: 560px;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
  }

  .mg-lead-grid {
    grid-template-columns: 1fr;
  }
}

/* Card/media/image hardening */
.card_image img,
.product .item .photo,
.product .item .thumb .photo {
  object-fit: cover;
}

.card_image img {
  height: clamp(150px, 28vw, 220px);
}

/* Partner/testimonial sliders with fixed legacy heights */
.service .slider,
.service .slidere,
.service .slidere .slidee {
  max-width: 100%;
}

.service .slider .slide,
.service .slider .slide img,
.service .slidere .slidee .item,
.service .slidere .slidee .photo,
.service .slidere .slidee img {
  max-width: 100%;
}

/* Cart/checkout */
.cart table img {
  width: clamp(56px, 16vw, 100px);
}

.cart input[type="number"] {
  width: clamp(64px, 18vw, 90px);
}

@media (max-width: 767px) {
  .cart .table th,
  .cart .table td,
  .user-content .table th,
  .user-content .table td {
    padding: 10px;
  }

  .cart-buttons ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-left: 0;
    margin-bottom: 0;
  }

  .cart-buttons ul li,
  .cart-buttons ul li a,
  .cart-buttons ul li input {
    width: 100%;
  }
}

/* Catalogue/category/product pages */
#left {
  max-width: 100%;
}


@media (min-width: 992px) {
  .product.product-cat .row {
    display: flex;
    flex-wrap: wrap;
  }

  .product.product-cat .item.item-product-cat {
    width: 33.333333% !important;
    float: left !important;
    clear: none !important;
    margin: 0 !important;
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .product.product-cat .item.item-product-cat {
    width: 50% !important;
    float: left !important;
    clear: none !important;
    margin: 0 !important;
  }
}

@media (max-width: 767px) {
  .product.product-cat .item.item-product-cat {
    width: 100% !important;
    float: left !important;
    clear: none !important;
    margin: 0 !important;
  }
}

.product .breadcrumb ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

#prod-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#prod-pager a {
  flex: 0 0 auto;
}

@media (max-width: 991px) {
  .product.product-cat .item,
  .product .item {
    margin-bottom: 18px;
  }

  .page .col-md-3 + .col-md-9 h3 {
    line-height: 1.35;
  }
}

@media (max-width: 767px) {
  .page .col-md-3 {
    margin-bottom: 16px;
  }

  .prod-slider li {
    min-height: 220px;
    background-size: cover;
    background-position: center;
  }

  .product .p-title h2 {
    font-size: 1.35rem;
    line-height: 1.3;
  }
}

/* Checkout + dashboard */
.user-sidebar,
.user-content {
  max-width: 100%;
}

@media (max-width: 991px) {
  .user-sidebar {
    margin-bottom: 18px;
  }

  .select2-container {
    width: 100% !important;
  }
}

@media (max-width: 767px) {
  .user-sidebar ul li a,
  .user-content h3,
  .page h3.special {
    overflow-wrap: anywhere;
  }
}

/* Contact page */
@media (max-width: 991px) {
  .cp-hero__inner,
  .cp-main {
    overflow: hidden;
  }

  .cp-hero__title {
    font-size: clamp(1.9rem, 6vw, 2.8rem);
    line-height: 1.15;
  }

  .cp-hero__pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
}

@media (max-width: 767px) {
  .cp-map iframe {
    min-height: 260px;
  }

  .cp-form-wrap,
  .cp-info-card {
    padding: 16px;
  }
}

/* Footer safety */
.footer,
.footer-bottom {
  overflow-x: clip;
}

.footer-bottom .copyright,
.footer-bottom .copyright a {
  white-space: normal;
}

/* Smooth, light interactions */
a,
.btn,
input,
textarea,
select {
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Breakpoints */
@media (min-width: 576px) {
  body {
    font-size: 0.97rem;
  }
}

@media (min-width: 768px) {
  body {
    font-size: 1rem;
  }
}

@media (min-width: 992px) {
  body {
    font-size: 1rem;
  }
}

@media (min-width: 1200px) {
  body {
    font-size: 1.02rem;
  }
}

@media (min-width: 1536px) {
  body {
    font-size: 1.04rem;
  }

  .container {
    width: min(92vw, 1360px);
  }
}
