/**
 * RA99 mobile cart — modal sticky footer + mini-cart.
 * Desktop (>=769px) unchanged.
 */
@media (max-width: 768px) {
  /* —— UniShop #modal-cart: header / scrollable products / sticky footer —— */
  body.modal-open {
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  #modal-cart.modal {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: 1070 !important;
    padding-top: max(8px, env(safe-area-inset-top, 0px)) !important;
    padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
    padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
    overflow: hidden !important;
    background: rgba(0, 0, 0, 0.45);
  }

  #modal-cart.modal:before {
    display: none !important;
    height: 0 !important;
    content: none !important;
  }

  #modal-cart .modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    vertical-align: top !important;
    height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px) !important;
    height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px) !important;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px) !important;
  }

  #modal-cart .modal-content {
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-radius: 12px !important;
    background: #fff !important;
    box-shadow: 0 10px 40px rgba(10, 45, 72, 0.28) !important;
  }

  #modal-cart .modal-header {
    flex: 0 0 auto !important;
    z-index: 2;
    background: #fff !important;
    border-bottom: 1px solid rgba(11, 78, 128, 0.1);
  }

  #modal-cart .modal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding: 12px 14px 10px !important;
    background: #fff !important;
    -webkit-overflow-scrolling: touch;
  }

  /* AJAX injects .header-cart__wrapper + .header-cart__footer-bar into .modal-body */
  #modal-cart .modal-body > .header-cart__wrapper,
  #modal-cart .header-cart__wrapper {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    border-bottom: 0 !important;
  }

  #modal-cart .modal-body > .header-cart__footer-bar {
    flex: 0 0 auto !important;
  }

  #modal-cart .header-cart__footer-bar {
    flex: 0 0 auto !important;
    position: relative;
    z-index: 3;
    margin: 0 -2px;
    padding: 12px 2px max(10px, env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid rgba(11, 78, 128, 0.12);
    box-shadow: 0 -6px 16px rgba(10, 45, 72, 0.06);
  }

  #modal-cart .header-cart__totals {
    margin: 0 0 12px !important;
  }

  #modal-cart .header-cart__totals-item {
    display: flex !important;
    justify-content: center !important;
    font-size: 1.2em;
    font-weight: 700;
    color: #0b4e80;
  }

  #modal-cart .header-cart__buttons {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 8px;
    width: 100% !important;
  }

  #modal-cart .header-cart__buttons .btn-default {
    display: none !important;
  }

  /* Full-width checkout CTA with visible UA/RU label */
  #modal-cart .header-cart__buttons .btn-primary,
  #modal-cart .header-cart__checkout-btn,
  #modal-cart a.btn-primary.header-cart__checkout-btn,
  #modal-cart a.btn-lg.btn-primary {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    box-sizing: border-box !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    margin: 0 !important;
    padding: 0 16px !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    letter-spacing: normal !important;
    white-space: normal !important;
    text-align: center !important;
    text-decoration: none !important;
    text-indent: 0 !important;
    text-transform: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    border-radius: 12px !important;
    color: #ffffff !important;
    background: linear-gradient(135deg, #0b4e80 0%, #13639f 100%) !important;
    writing-mode: horizontal-tb !important;
    -webkit-text-fill-color: #ffffff !important;
  }

  #modal-cart .header-cart__checkout-btn::before,
  #modal-cart .header-cart__checkout-btn::after,
  #modal-cart .header-cart__buttons .btn-primary::before,
  #modal-cart .header-cart__buttons .btn-primary::after {
    content: none !important;
    display: none !important;
  }

  /* —— RA99 chrome mini-cart: same sticky-footer pattern —— */
  .ra99-mini-cart__panel,
  #headerCartDropdown.ra99-mini-cart__panel {
    position: fixed !important;
    left: max(8px, env(safe-area-inset-left, 0px)) !important;
    right: max(8px, env(safe-area-inset-right, 0px)) !important;
    top: max(12px, env(safe-area-inset-top, 0px)) !important;
    bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
    width: auto !important;
    /* do NOT use height:auto !important — it defeats top/bottom stretch */
    height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px) !important;
    height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px) !important;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px) !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    -webkit-overflow-scrolling: touch;
    z-index: 1200 !important;
    box-sizing: border-box !important;
    background: #fff !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 40px rgba(10, 45, 72, 0.28) !important;
  }

  .ra99-mini-cart__panel .ra99-mini-cart__inner,
  #headerCartDropdown.ra99-mini-cart__panel .ra99-mini-cart__inner,
  #headerCartBody {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
    padding: 14px 14px 10px !important;
    overflow: hidden;
  }

  #headerCartBody .header-cart__item {
    flex: 0 0 auto;
  }

  /* scroll only the items area: items before footer */
  #headerCartBody {
    overflow: hidden;
  }

  #headerCartBody > .header-cart__item,
  #headerCartBody > .header-cart__line {
    /* collected via scroll wrapper simulation: overflow on body until footer */
  }

  .ra99-mini-cart__footer--simple,
  #headerCartBody .header-cart__footer,
  #headerCartBody .ra99-mini-cart__footer--simple {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    display: flex !important;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    gap: 12px;
    margin-top: auto;
    padding: 12px 0 4px !important;
    border-top: 1px solid rgba(11, 78, 128, 0.12);
    background: #fff;
  }

  /* Scroll products; keep footer pinned at bottom of panel */
  #headerCartBody {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  #headerCartBody > .header-cart__line,
  #headerCartBody > .header-cart__item {
    flex: 0 0 auto;
  }

  /* scrollable products region: everything before footer */
  #headerCartBody {
    overflow-y: auto !important;
  }

  .ra99-mini-cart__footer--simple,
  #headerCartBody .ra99-mini-cart__footer--simple,
  #headerCartBody .header-cart__footer {
    position: sticky !important;
    bottom: 0 !important;
    margin-top: auto !important;
    background: #fff !important;
  }

  .ra99-mini-cart__footer--simple > strong,
  #headerCartBody .header-cart__footer > strong {
    display: block;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.3;
    color: #0b4e80;
  }

  .ra99-mini-cart__checkout-btn,
  #headerCartBody .ra99-mini-cart__checkout-btn,
  body.ra99-simple-cart-preview .ra99-mini-cart__checkout-btn,
  #headerCartBody .header-cart__footer .btn-primary {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    min-height: 54px;
    height: auto !important;
    padding: 14px 18px !important;
    font-size: 1.05rem !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    border-radius: 12px !important;
    text-align: center;
    text-decoration: none !important;
    white-space: normal !important;
    writing-mode: horizontal-tb !important;
    color: #fff !important;
    background: linear-gradient(135deg, #0b4e80 0%, #13639f 100%) !important;
  }

  /* Cart / checkout page polish (unchanged intent) */
  html {
    scroll-padding-top: max(12px, env(safe-area-inset-top, 0px));
  }

  body.ra99-catalog-preview #checkout-cart,
  body.ra99-catalog-preview #unicheckout,
  body.ra99-catalog-preview .checkout-cart-page,
  #checkout-cart,
  #unicheckout,
  .checkout-cart-page {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
  }

  #checkout-cart .unicheckout-sticky,
  .checkout-cart-page .unicheckout-sticky,
  #unicheckout .unicheckout-sticky {
    position: static !important;
    top: auto !important;
  }

  #checkout-cart .unicheckout-sticky__confirm-btn,
  .checkout-cart-page .unicheckout-sticky__confirm-btn {
    min-height: 52px;
    font-size: 1.05rem;
    font-weight: 800;
  }

  /* Products scroll; footer pinned (sibling of .ra99-mini-cart__items) */
  #headerCartBody {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  #headerCartBody > .ra99-mini-cart__items {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #headerCartBody > .ra99-mini-cart__footer--simple,
  #headerCartBody > .header-cart__footer {
    position: relative !important;
    bottom: auto !important;
    flex: 0 0 auto !important;
    margin-top: 0 !important;
  }

}

/* Desktop + all viewports: checkout CTA text must stay white on blue */
.ra99-mini-cart__checkout-btn,
a.ra99-mini-cart__checkout-btn,
a.btn-primary.ra99-mini-cart__checkout-btn,
#headerCartBody .ra99-mini-cart__checkout-btn,
#headerCartDropdown .ra99-mini-cart__checkout-btn,
#modal-cart .header-cart__checkout-btn,
#modal-cart a.btn-primary.header-cart__checkout-btn {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
.ra99-mini-cart__checkout-btn:link,
.ra99-mini-cart__checkout-btn:visited,
.ra99-mini-cart__checkout-btn:hover,
.ra99-mini-cart__checkout-btn:focus,
.ra99-mini-cart__checkout-btn:active,
#modal-cart .header-cart__checkout-btn:link,
#modal-cart .header-cart__checkout-btn:visited,
#modal-cart .header-cart__checkout-btn:hover,
#modal-cart .header-cart__checkout-btn:focus,
#modal-cart .header-cart__checkout-btn:active {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* Desktop: footer-bar is a harmless wrapper */
.header-cart__footer-bar {
  display: block;
}
