/**
 * Mobile responsiveness fixes — loaded after all other stylesheets.
 * Scoped overrides for legacy responsive.css conflicts + gap fills.
 */

/* ── Breakpoint tokens (match home-redesign.css) ── */
:root {
  --mp-bp-xs: 575px;
  --mp-bp-sm: 767px;
  --mp-bp-md: 991px;
  --mp-bp-lg: 992px;
  --mp-mobile-nav-h: 88px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ── Global storefront guards ── */
body.mp-light-theme {
  overflow-x: hidden;
  max-width: 100%;
}

body.mp-light-theme img,
body.mp-light-theme video,
body.mp-light-theme canvas,
body.mp-light-theme svg {
  max-width: 100%;
  height: auto;
}

body.mp-light-theme .mp-logo img,
body.mp-light-theme .mp-logo__img,
body.mp-light-theme .mp-cart-table__img,
body.mp-light-theme .mp-product-card__img img {
  height: auto;
}

/* ── Override legacy responsive.css conflicts (storefront only) ── */
@media (max-width: 990px) {
  body.mp-light-theme .products ul li {
    width: auto !important;
    float: none !important;
    margin-right: 0 !important;
  }

  body.mp-light-theme .header_sec .logo,
  body.mp-light-theme .mp-header .logo,
  body.mp-light-theme .mp-header #logo-div {
    width: auto !important;
    max-width: none !important;
    text-align: left !important;
    margin: 0 !important;
  }

  body.mp-light-theme .navbar-nav > li {
    width: auto !important;
    float: none !important;
  }

  body.mp-light-theme .phone {
    width: auto !important;
    float: none !important;
  }

  body.mp-light-theme .alg_rit {
    float: none !important;
    width: 100% !important;
    text-align: center !important;
  }
}

@media (max-width: 639px) {
  body.mp-light-theme .products ul li {
    width: auto !important;
  }

  body.mp-light-theme .list.list-payment {
    width: 100% !important;
    max-width: 320px;
  }
}

/* ── iOS: prevent input zoom (16px minimum) ── */
@media (max-width: 991px) {
  body.mp-light-theme input.form-control,
  body.mp-light-theme select.form-control,
  body.mp-light-theme textarea.form-control,
  body.mp-light-theme .mp-form-input,
  body.mp-light-theme .mp-search-form input,
  body.mp-light-theme .in_search {
    font-size: 16px !important;
  }
}

/* ── Touch-friendly tap targets ── */
@media (max-width: 991px) {
  body.mp-light-theme .mp-cart-qty__btn,
  body.mp-light-theme .mp-cart-remove {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  body.mp-light-theme .mp-product-card__cart {
    min-height: 44px;
    width: 100%;
  }

  body.mp-light-theme .footer-button {
    min-height: 44px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  body.mp-light-theme .btn,
  body.mp-light-theme .mp-btn-primary,
  body.mp-light-theme .mp-btn-outline {
    min-height: 44px;
  }
}

/* ── Catalog layout: sidebar hidden, content full-width on mobile ── */
@media (max-width: 991px) {
  .mp-catalog-page > .row > .col-lg-3,
  .mp-catalog-page > .row > .col-md-3,
  .mp-catalog-page > .row > .col-sm-4,
  .mp-product-page > .row > .col-lg-3,
  .mp-product-page > .row > .col-md-3,
  .mp-product-page > .row > .col-sm-4 {
    display: none !important;
  }

  .mp-catalog-page > .row > .col-lg-9,
  .mp-catalog-page > .row > .col-md-9,
  .mp-catalog-page > .row > .col-sm-8,
  .mp-product-page > .row > .col-lg-9,
  .mp-product-page > .row > .col-md-9,
  .mp-product-page > .row > .col-sm-8,
  .mp-product-page__content {
    width: 100% !important;
    float: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .mp-catalog-page > .row,
  .mp-product-page > .row {
    margin-left: 0;
    margin-right: 0;
  }

  .mp-catalog-page,
  .mp-product-page,
  .mp-cart-page,
  .mp-checkout-page,
  .mp-track-page {
    padding-top: 16px !important;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ── Legacy float product cards inside catalog grids ── */
@media (max-width: 991px) {
  body.mp-light-theme .home-catalog .products > ul > li {
    width: auto !important;
    float: none !important;
    min-height: 0 !important;
  }

  body.mp-light-theme .home-catalog .products .product_card {
    position: relative !important;
    min-height: 0 !important;
  }

  body.mp-light-theme .product_box {
    width: auto !important;
    float: none !important;
    min-height: 0 !important;
  }
}

/* ── Checkout page ── */
.mp-checkout-page {
  max-width: 960px;
}

.mp-checkout-card {
  background: var(--mp-bg-card);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-lg);
  padding: 28px;
  overflow: hidden;
}

.mp-checkout-card h4 {
  color: var(--mp-teal);
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--mp-border);
}

.mp-checkout-card .form-group {
  margin-bottom: 16px;
}

.mp-checkout-card .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--mp-text-muted);
  margin-bottom: 6px;
}

.mp-checkout-card hr {
  border-color: var(--mp-border);
  margin: 24px 0;
}

.mp-checkout-card .checkbox label {
  color: var(--mp-text-muted);
  font-weight: 500;
  font-size: 14px;
}

.mp-checkout-totals {
  background: var(--mp-bg-elevated);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.mp-checkout-totals p {
  margin: 0 0 8px;
  color: var(--mp-text-muted);
  font-size: 14px;
}

.mp-checkout-totals p:last-child {
  margin-bottom: 0;
  color: var(--mp-text);
  font-size: 16px;
}

.mp-checkout-actions {
  margin-top: 16px;
}

body.mp-light-theme .mp-checkout-page .form-control {
  background: var(--mp-bg-elevated) !important;
  color: var(--mp-text) !important;
  border: 1px solid var(--mp-border) !important;
  border-radius: var(--mp-radius);
  box-shadow: none;
  min-height: 44px;
}

body.mp-light-theme .mp-checkout-page .form-control:focus {
  border-color: var(--mp-teal) !important;
  box-shadow: 0 0 0 3px var(--mp-teal-glow);
}

body.mp-light-theme .mp-checkout-page .alert-danger {
  background: rgba(220, 53, 69, 0.15);
  border-color: rgba(220, 53, 69, 0.4);
  color: #f8d7da;
}

body.mp-light-theme .mp-checkout-page .alert-warning {
  background: rgba(255, 136, 64, 0.12);
  border-color: rgba(255, 136, 64, 0.35);
  color: #ffcc99;
}

body.mp-light-theme .mp-checkout-page .btn-success {
  background: var(--mp-teal);
  border-color: var(--mp-teal-dark);
  min-height: 48px;
  padding: 12px 28px;
  font-weight: 600;
  font-size: 15px;
}

body.mp-light-theme .mp-checkout-page .btn-success:hover,
body.mp-light-theme .mp-checkout-page .btn-success:focus {
  background: var(--mp-teal-dark);
  border-color: var(--mp-teal-dark);
}

@media (max-width: 991px) {
  .mp-checkout-card {
    padding: 20px 16px;
  }

  .mp-checkout-card .col-md-6 {
    width: 100%;
    float: none;
    margin-bottom: 8px;
  }

  .mp-checkout-card .col-md-6.text-right,
  .mp-checkout-totals {
    text-align: left !important;
  }

  .mp-checkout-actions {
    text-align: center !important;
  }

  .mp-checkout-actions .btn-success {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 575px) {
  .mp-checkout-page .mp-page-header h2 {
    font-size: 22px;
  }
}

/* ── Modals: clear fixed bottom nav ── */
@media (max-width: 991px) {
  body.mp-light-theme .modal-dialog {
    margin: 12px 12px calc(var(--mp-mobile-nav-h) + env(safe-area-inset-bottom, 0px)) 12px !important;
    max-width: calc(100vw - 24px);
  }

  body.mp-light-theme .modal-body.prescription {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0;
    padding-right: 0;
  }

  body.mp-light-theme .modal-content {
    max-height: calc(100vh - var(--mp-mobile-nav-h) - 48px - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }
}

/* ── Mobile nav panel ── */
@media (max-width: 991px) {
  body.mp-light-theme .mp-mobile-nav.is-open {
    max-height: min(70vh, 480px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.mp-light-theme .mp-mobile-nav__list li a {
    min-height: 48px;
    display: flex;
    align-items: center;
  }
}

/* ── Search suggestions: fit narrow screens ── */
@media (max-width: 575px) {
  body.mp-light-theme .search-suggestions-dropdown {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ── Cart upgrade link: wrap on small screens ── */
@media (max-width: 575px) {
  body.mp-light-theme .mp-cart-upgrade {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.4;
  }

  body.mp-light-theme .mp-cart-table__name strong {
    word-break: break-word;
  }
}

/* ── Lookup / category page headers ── */
@media (max-width: 575px) {
  body.mp-light-theme .home-catalog.mp-catalog-page h2 {
    font-size: 20px;
    line-height: 1.3;
    word-break: break-word;
  }
}

/* ── Account menu dropdown on mobile ── */
@media (max-width: 991px) {
  body.mp-light-theme .mp-account-menu {
    right: 0;
    left: auto;
    min-width: 200px;
    max-width: calc(100vw - 32px);
  }
}

/* ── SweetAlert on mobile ── */
@media (max-width: 575px) {
  .sweet-alert {
    width: calc(100vw - 32px) !important;
    max-width: 400px !important;
    margin-left: 0 !important;
    left: 50% !important;
    transform: translateX(-50%);
  }
}

/* ══════════════════════════════════════════════════════════
   Admin backend (body.black)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 991px) {
  body.black .left-box,
  body.black .right-box {
    width: 100% !important;
    float: none !important;
  }

  body.black .nav-side-menu {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    top: auto !important;
    box-shadow: none;
    margin-bottom: 12px;
  }

  body.black .nav-side-menu .toggle-btn {
    display: block;
  }

  body.black .content_sec {
    margin: 10px 0;
    padding: 0 10px;
    overflow-x: hidden;
  }

  body.black .header_sec .navbar-nav.navbar-right {
    float: none !important;
    text-align: center;
    margin: 0;
  }

  body.black .header_sec .navbar-nav > li {
    display: inline-block;
    float: none;
  }

  body.black .alter_table2,
  body.black .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.black .alter_table2 table {
    min-width: 600px;
  }
}

@media (max-width: 767px) {
  body.black .header_sec .container-fluid > .row > .col-md-12 {
    padding-left: 10px;
    padding-right: 10px;
  }

  body.black .lang_set {
    margin: 0 auto !important;
  }

  body.black .nav-side-menu .brand {
    font-size: 22px;
    text-align: left;
    padding-left: 16px;
  }

  body.black form .col-md-6,
  body.black form .col-md-4,
  body.black form .col-md-3 {
    width: 100%;
    float: none;
  }
}

/* ── Track order results table ── */
@media (max-width: 767px) {
  body.mp-light-theme .mp-track-results {
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.mp-light-theme .mp-track-table {
    display: block;
    overflow-x: auto;
    min-width: 480px;
  }
}

/* ── Footer copyright clearance for bottom nav ── */
@media (max-width: 991px) {
  body.mp-light-theme .mp-footer .copy,
  body.mp-light-theme footer .copy {
    margin-bottom: calc(var(--mp-mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Product page tabs scroll on narrow screens ── */
@media (max-width: 575px) {
  body.mp-light-theme .mp-product-tabs__nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    scrollbar-width: none;
  }

  body.mp-light-theme .mp-product-tabs__nav::-webkit-scrollbar {
    display: none;
  }
}

/* ── Prevent horizontal scroll from wide pre/code blocks ── */
body.mp-light-theme pre,
body.mp-light-theme code,
body.mp-light-theme .pdt_content2 {
  overflow-x: auto;
  word-break: break-word;
}

/* ══════════════════════════════════════════════════════════
   Phase 11 — Site-wide mobile responsive polish
   ══════════════════════════════════════════════════════════ */

/* Shared page shell — replaces inline padding on views */
.mp-page-shell {
  padding-top: 20px;
  padding-bottom: 40px;
  box-sizing: border-box;
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 991px) {
  .mp-page-shell {
    padding-top: 16px;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Sticky bottom nav — authoritative show/hide */
  body.mp-light-theme .footer-buttons {
    display: flex !important;
    position: fixed !important;
    z-index: 1040;
  }

  body.mp-light-theme .mp-layout {
    min-width: 0;
    overflow-x: hidden;
  }

  body.mp-light-theme .container {
    padding-left: 16px;
    padding-right: 16px;
    max-width: 100%;
  }

  /* Header: compact actions on small phones */
  body.mp-light-theme .mp-header .mp-header-actions {
    gap: 8px !important;
  }
  body.mp-light-theme .mp-header .mp-header-action__icon,
  body.mp-light-theme .mp-header .mp-cart-widget__icon {
    font-size: 18px !important;
  }
  body.mp-light-theme .mp-header-action__label--name {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Product grids */
  .mp-products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Promo banners stack */
  .mp-promo-row {
    flex-direction: column !important;
    gap: 12px;
  }
  .mp-promo-row a,
  .mp-promo-row img {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Section headers */
  .mp-section-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .mp-section-header h2 {
    font-size: 22px;
    line-height: 1.25;
  }

  /* Footer newsletter + grid */
  .mp-footer__top {
    flex-direction: column;
    gap: 20px;
  }
  .mp-footer__newsletter {
    width: 100%;
  }
  .mp-footer__newsletter-btn {
    width: 100%;
    text-align: center;
  }

  .mp-footer__disclaimer {
    padding: 14px 14px;
  }
  .mp-footer__disclaimer-title {
    font-size: 13px;
  }
  .mp-footer__disclaimer-list li {
    font-size: 11px;
  }

  /* Legal / policy pages */
  .mp-legal-page {
    padding-left: 0;
    padding-right: 0;
  }
  .mp-legal-content {
    padding: 20px 16px;
  }

  /* Auth pages use contact layout */
  .mp-auth-page.container {
    padding: 20px 16px calc(110px + env(safe-area-inset-bottom, 0px));
  }

  /* Top bar: stack on tablets */
  body.mp-light-theme .mp-topbar .container > .row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px;
  }
  body.mp-light-theme .mp-topbar__right {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Product detail: full-width CTAs */
  .mp-product-packs__btn,
  .mp-product-hero .mp-btn-primary,
  .mp-product-hero .mp-btn-outline {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 575px) {
  .mp-products-grid {
    grid-template-columns: 1fr !important;
  }

  body.mp-light-theme .mp-header .mp-header-actions {
    gap: 6px !important;
  }
  body.mp-light-theme .mp-header .mp-header-action__label {
    font-size: 9px !important;
  }
  body.mp-light-theme .mp-header .mp-logo__line {
    font-size: 13px !important;
  }
  body.mp-light-theme .mp-header .mp-logo__img {
    width: 34px !important;
    height: 34px !important;
  }

  .mp-hero--v3 .mp-hero__title {
    font-size: clamp(1.5rem, 7vw, 2rem) !important;
  }
  .mp-hero--v3 .mp-hero__actions {
    flex-direction: column;
    align-items: stretch;
  }
  .mp-hero--v3 .mp-hero__actions .mp-btn-primary,
  .mp-hero--v3 .mp-hero__actions .mp-btn-outline {
    width: 100%;
    text-align: center;
  }

  .mp-contact-hero__title {
    font-size: 24px;
  }
  .mp-contact-quicklinks__chip {
    font-size: 12px;
    padding: 8px 12px;
  }

  .mp-track-page__subtitle {
    font-size: 14px;
    padding: 0 4px;
  }
}

@media (min-width: 992px) {
  body.mp-light-theme .footer-buttons {
    display: none !important;
  }
}

/* Track results: stacked card rows on phones */
@media (max-width: 767px) {
  body.mp-light-theme .mp-track-table {
    min-width: 0 !important;
    display: block;
    border: none;
    background: transparent;
  }
  body.mp-light-theme .mp-track-table thead {
    display: none;
  }
  body.mp-light-theme .mp-track-table tbody,
  body.mp-light-theme .mp-track-table tr,
  body.mp-light-theme .mp-track-table td {
    display: block;
    width: 100%;
  }
  body.mp-light-theme .mp-track-table tr {
    background: var(--mp-bg-card);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    margin-bottom: 12px;
    padding: 12px 14px;
  }
  body.mp-light-theme .mp-track-table td {
    padding: 6px 0 !important;
    border: none !important;
    white-space: normal !important;
    text-align: left !important;
  }
  body.mp-light-theme .mp-track-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--mp-text-muted);
    margin-bottom: 2px;
  }
}

/* Mobile categories overlay */
@media (max-width: 991px) {
  body.mp-light-theme .mobile-categories-overlay {
    padding: 12px;
    align-items: stretch;
  }
  body.mp-light-theme .mobile-categories-content {
    width: 100% !important;
    max-width: 100% !important;
    left: 12px !important;
    right: 12px !important;
  }
}
