/* Sprint 642 — Mobile Commerce Overlay System
   Coordinates cart, AI, bottom nav, RFQ and safe content area.
   Mobile-only. Desktop behavior remains untouched. */

@media(max-width:767px){
  :root{
    --tf-mobile-safe:env(safe-area-inset-bottom,0px);
    --tf-mobile-nav-h:70px;
    --tf-mobile-edge:12px;
    --tf-mobile-gap:10px;
    --tf-mobile-ai:56px;
    --tf-mobile-rfq-w:72px;
    --tf-mobile-cart-h:84px;
  }

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

  /*
   * Reserve one coordinated bottom zone.
   * Prevents page content and category cards from hiding beneath fixed UI.
   */
  body{
    padding-bottom:calc(var(--tf-mobile-nav-h) + var(--tf-mobile-cart-h) + 34px + var(--tf-mobile-safe))!important;
  }

  /* ---------------------------------------------------------
     Bottom navigation shell
     --------------------------------------------------------- */
  :is(
    .mobile-bottom-nav,.tf-mobile-bottom-nav,.app-bottom-nav,.bottom-nav,
    .mobile-nav,.mobile-tabbar,.mobile-tab-bar,[data-mobile-bottom-nav]
  ){
    position:fixed!important;
    z-index:1160!important;
    left:var(--tf-mobile-edge)!important;
    right:calc(var(--tf-mobile-edge) + var(--tf-mobile-rfq-w) + 8px)!important;
    bottom:calc(10px + var(--tf-mobile-safe))!important;
    width:auto!important;
    height:var(--tf-mobile-nav-h)!important;
    min-height:var(--tf-mobile-nav-h)!important;
    max-height:var(--tf-mobile-nav-h)!important;
    margin:0!important;
    padding:6px 8px!important;
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    align-items:stretch!important;
    gap:2px!important;
    overflow:hidden!important;
    border:1px solid #d8e2ed!important;
    border-radius:22px!important;
    background:rgba(255,255,255,.98)!important;
    box-shadow:0 14px 38px rgba(11,36,69,.15)!important;
    backdrop-filter:blur(14px)!important;
  }

  :is(
    .mobile-bottom-nav,.tf-mobile-bottom-nav,.app-bottom-nav,.bottom-nav,
    .mobile-nav,.mobile-tabbar,.mobile-tab-bar,[data-mobile-bottom-nav]
  ) :is(a,button){
    min-width:0!important;
    min-height:0!important;
    height:100%!important;
    padding:5px 4px!important;
    margin:0!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    gap:3px!important;
    border:0!important;
    border-radius:16px!important;
    background:transparent!important;
    color:#102e52!important;
    box-shadow:none!important;
    font-size:10px!important;
    font-weight:850!important;
    line-height:1.05!important;
    text-align:center!important;
  }

  :is(
    .mobile-bottom-nav,.tf-mobile-bottom-nav,.app-bottom-nav,.bottom-nav,
    .mobile-nav,.mobile-tabbar,.mobile-tab-bar,[data-mobile-bottom-nav]
  ) :is(a,button).active,
  :is(
    .mobile-bottom-nav,.tf-mobile-bottom-nav,.app-bottom-nav,.bottom-nav,
    .mobile-nav,.mobile-tabbar,.mobile-tab-bar,[data-mobile-bottom-nav]
  ) :is(a,button)[aria-current="page"]{
    background:#fff4ce!important;
    color:#0d3974!important;
  }

  :is(
    .mobile-bottom-nav,.tf-mobile-bottom-nav,.app-bottom-nav,.bottom-nav,
    .mobile-nav,.mobile-tabbar,.mobile-tab-bar,[data-mobile-bottom-nav]
  ) :is(svg,.icon){
    width:24px!important;
    height:24px!important;
    flex:0 0 auto!important;
  }

  /* ---------------------------------------------------------
     RFQ fixed action — dedicated right-side slot
     --------------------------------------------------------- */
  :is(.mobile-rfq,.rfq-fab,.mobile-rfq-fab,[data-mobile-rfq]){
    position:fixed!important;
    z-index:1170!important;
    right:var(--tf-mobile-edge)!important;
    bottom:calc(10px + var(--tf-mobile-safe))!important;
    width:var(--tf-mobile-rfq-w)!important;
    height:var(--tf-mobile-nav-h)!important;
    min-width:var(--tf-mobile-rfq-w)!important;
    min-height:var(--tf-mobile-nav-h)!important;
    margin:0!important;
    padding:5px!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    gap:3px!important;
    border:2px solid #f3bd36!important;
    border-radius:22px!important;
    background:#ffbf2f!important;
    color:#0b2c54!important;
    box-shadow:0 14px 34px rgba(11,36,69,.16)!important;
    font-size:10px!important;
    font-weight:900!important;
  }
  :is(.mobile-rfq,.rfq-fab,.mobile-rfq-fab,[data-mobile-rfq]) :is(svg,.icon){
    width:25px!important;
    height:25px!important;
  }

  /* ---------------------------------------------------------
     Compact floating cart bar
     --------------------------------------------------------- */
  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ){
    position:fixed!important;
    z-index:1140!important;
    left:var(--tf-mobile-edge)!important;
    right:var(--tf-mobile-edge)!important;
    bottom:calc(var(--tf-mobile-nav-h) + 22px + var(--tf-mobile-safe))!important;
    width:auto!important;
    min-width:0!important;
    height:var(--tf-mobile-cart-h)!important;
    min-height:var(--tf-mobile-cart-h)!important;
    max-height:var(--tf-mobile-cart-h)!important;
    margin:0!important;
    padding:10px 76px 10px 12px!important;
    display:grid!important;
    grid-template-columns:48px minmax(0,1fr) auto!important;
    align-items:center!important;
    gap:10px!important;
    overflow:hidden!important;
    border:1px solid #d9e3ed!important;
    border-radius:20px!important;
    background:rgba(255,255,255,.985)!important;
    box-shadow:0 16px 40px rgba(11,36,69,.15)!important;
    backdrop-filter:blur(12px)!important;
    color:#162e4c!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(.cart-icon,.icon-cart,.cart-badge-icon){
    width:48px!important;
    height:48px!important;
    min-width:48px!important;
    min-height:48px!important;
    display:grid!important;
    place-items:center!important;
    border-radius:50%!important;
    background:#fff4ce!important;
    color:#10335e!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(.cart-icon,.icon-cart,.cart-badge-icon) svg{
    width:24px!important;
    height:24px!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(h2,h3,strong,.title,.cart-title){
    margin:0!important;
    color:#172f4f!important;
    font-size:16px!important;
    line-height:1.1!important;
    font-weight:900!important;
    white-space:nowrap!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(p,small,.subtitle,.cart-subtitle){
    margin:3px 0 0!important;
    color:#70839a!important;
    font-size:11px!important;
    line-height:1.2!important;
    white-space:nowrap!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(.view-cart,.cart-cta,a[href*="/cart"],button[data-view-cart]){
    min-width:104px!important;
    min-height:48px!important;
    padding:0 14px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    border:0!important;
    border-radius:15px!important;
    background:#0e3979!important;
    color:#fff!important;
    font-size:12px!important;
    font-weight:900!important;
    text-decoration:none!important;
    white-space:nowrap!important;
  }

  /* Kill legacy giant cart artwork/panel dimensions */
  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(.cart-illustration,.cart-hero,.large-cart-icon){
    display:none!important;
  }

  /* ---------------------------------------------------------
     AI assistant — small circular/rounded fab above cart
     --------------------------------------------------------- */
  :is(
    .ai-fab,.tf-ai-fab,.ai-chat-fab,.floating-ai,.ai-assistant-fab,
    .mobile-ai-fab,[data-ai-fab],[data-ai-chat-toggle]
  ){
    position:fixed!important;
    z-index:1180!important;
    right:calc(var(--tf-mobile-edge) + 8px)!important;
    bottom:calc(var(--tf-mobile-nav-h) + var(--tf-mobile-cart-h) + 32px + var(--tf-mobile-safe))!important;
    width:var(--tf-mobile-ai)!important;
    height:var(--tf-mobile-ai)!important;
    min-width:var(--tf-mobile-ai)!important;
    min-height:var(--tf-mobile-ai)!important;
    max-width:var(--tf-mobile-ai)!important;
    max-height:var(--tf-mobile-ai)!important;
    padding:0!important;
    margin:0!important;
    display:grid!important;
    place-items:center!important;
    border:2px solid #fff!important;
    border-radius:18px!important;
    background:#0f57b8!important;
    color:#fff!important;
    box-shadow:0 12px 30px rgba(7,54,117,.25)!important;
    overflow:visible!important;
    font-size:0!important;
  }

  :is(
    .ai-fab,.tf-ai-fab,.ai-chat-fab,.floating-ai,.ai-assistant-fab,
    .mobile-ai-fab,[data-ai-fab],[data-ai-chat-toggle]
  ) :is(svg,.icon){
    width:25px!important;
    height:25px!important;
  }

  :is(
    .ai-fab,.tf-ai-fab,.ai-chat-fab,.floating-ai,.ai-assistant-fab,
    .mobile-ai-fab,[data-ai-fab],[data-ai-chat-toggle]
  )::after{
    content:"AI"!important;
    position:absolute!important;
    right:6px!important;
    bottom:5px!important;
    color:#fff!important;
    font-size:9px!important;
    font-weight:900!important;
    line-height:1!important;
  }

  /* online dot */
  :is(
    .ai-fab,.tf-ai-fab,.ai-chat-fab,.floating-ai,.ai-assistant-fab,
    .mobile-ai-fab,[data-ai-fab],[data-ai-chat-toggle]
  )::before{
    content:""!important;
    position:absolute!important;
    right:-1px!important;
    top:-1px!important;
    width:10px!important;
    height:10px!important;
    border:2px solid #fff!important;
    border-radius:50%!important;
    background:#22c77a!important;
  }

  /* ---------------------------------------------------------
     AI chat drawer/panel
     --------------------------------------------------------- */
  :is(.ai-chat-panel,.ai-chat-drawer,.tf-ai-chat-panel,.mobile-ai-chat,[data-ai-chat-panel]){
    position:fixed!important;
    z-index:1300!important;
    left:var(--tf-mobile-edge)!important;
    right:var(--tf-mobile-edge)!important;
    bottom:calc(var(--tf-mobile-nav-h) + 18px + var(--tf-mobile-safe))!important;
    width:auto!important;
    max-width:none!important;
    max-height:min(68vh,560px)!important;
    border:1px solid #d6e1ec!important;
    border-radius:20px!important;
    background:#fff!important;
    box-shadow:0 22px 58px rgba(8,32,62,.22)!important;
    overflow:hidden!important;
  }

  /* ---------------------------------------------------------
     Product/category content must never sit behind overlays
     --------------------------------------------------------- */
  main,
  .site-main,
  .page-content,
  .category-page,
  .subcategory-page,
  .products-page,
  .tf-home-v3{
    min-width:0!important;
  }
}

/* Small phones */
@media(max-width:390px){
  :root{
    --tf-mobile-nav-h:66px;
    --tf-mobile-edge:8px;
    --tf-mobile-ai:52px;
    --tf-mobile-rfq-w:68px;
    --tf-mobile-cart-h:78px;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ){
    padding:8px 64px 8px 10px!important;
    grid-template-columns:42px minmax(0,1fr) auto!important;
    gap:8px!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(.cart-icon,.icon-cart,.cart-badge-icon){
    width:42px!important;
    height:42px!important;
    min-width:42px!important;
    min-height:42px!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(h2,h3,strong,.title,.cart-title){
    font-size:14px!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(p,small,.subtitle,.cart-subtitle){
    font-size:10px!important;
  }

  :is(
    .mobile-cart-bar,.mobile-cart-summary,.floating-cart,.floating-cart-bar,
    .quick-cart-bar,.cart-ready-bar,.mobile-cart-dock,[data-mobile-cart-bar]
  ) :is(.view-cart,.cart-cta,a[href*="/cart"],button[data-view-cart]){
    min-width:86px!important;
    min-height:44px!important;
    padding:0 10px!important;
    font-size:11px!important;
  }
}
