/* Мобильный нижний таббар (референс М.Видео) — только ≤1319 / compact */

.zp-tabbar {
  display: none;
}

@media (max-width: 1319px) {
  .zp-tabbar,
  html.nav--compact .zp-tabbar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2100;
    padding: 0 0 env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid rgba(72, 42, 131, 0.1);
    box-shadow: 0 -8px 28px rgba(35, 18, 77, 0.08);
    transform: translate3d(0, 0, 0);
    transition: transform 0.22s ease, opacity 0.22s ease;
    opacity: 1;
    pointer-events: auto;
  }

  /* !important: иначе html.nav--compact .zp-tabbar (0,2,1) перебивает .zp-tabbar.is-hidden */
  .zp-tabbar.is-hidden,
  html.nav--compact .zp-tabbar.is-hidden {
    transform: translate3d(0, 110%, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .zp-tabbar__inner {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: stretch;
    min-height: 52px;
    max-width: 560px;
    margin: 0 auto;
    padding: 4px 2px 6px;
    box-sizing: border-box;
  }

  .zp-tabbar__item {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    margin: 0;
    padding: 4px 1px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #5c5470;
    text-decoration: none;
    cursor: pointer;
    font-family: var(--zp-font-ui, "Nunito", system-ui, sans-serif);
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .zp-tabbar__item:hover,
  .zp-tabbar__item:focus-visible {
    outline: none;
    background: rgba(100, 64, 191, 0.08);
    color: #3b135c;
  }

  .zp-tabbar__item.is-active {
    color: #6440bf;
  }

  .zp-tabbar__ico {
    display: block;
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
  }

  .zp-tabbar__label {
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
  }

  .zp-tabbar__badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 22px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #6440bf;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
  }

  .zp-tabbar__badge[hidden] {
    display: none !important;
  }

  @keyframes zp-tabbar-badge-ping {
    0%,
    100% {
      transform: scale(1);
    }
    35% {
      transform: scale(1.3);
    }
    70% {
      transform: scale(0.9);
    }
  }

  .zp-tabbar__badge.is-ping {
    animation: zp-tabbar-badge-ping 0.55s ease 2;
  }

  @media (prefers-reduced-motion: reduce) {
    .zp-tabbar__badge.is-ping {
      animation: none;
    }
  }

  /* Шапка: корзина и профиль уезжают вниз в таббар */
  body.has-zp-tabbar .nav-tray > .zp-cart-badge,
  body.has-zp-tabbar .nav-tray > .zp-nav-profile,
  html.nav--compact body.has-zp-tabbar .nav-tray > .zp-cart-badge,
  html.nav--compact body.has-zp-tabbar .nav-tray > .zp-nav-profile {
    display: none !important;
  }

  /* Гамбургер уходит в таббар «Меню» */
  body.has-zp-tabbar #navToggle,
  body.has-zp-tabbar .nav-toggle,
  html.nav--compact body.has-zp-tabbar .nav-toggle,
  html.nav--compact body.home-layout-ref.has-zp-tabbar .nav-toggle,
  body.home-layout-ref.has-zp-tabbar .nav-toggle {
    display: none !important;
  }

  /* Лого: левый край + +10% к высоте (референс mobile header logo) */
  html.nav--compact body.home-layout-ref.has-zp-tabbar .nav,
  body.home-layout-ref.has-zp-tabbar .nav {
    grid-template-columns: 1fr auto !important;
    gap: 8px 12px;
    padding-left: 12px;
    padding-right: 16px;
  }

  html.nav--compact body.home-layout-ref.has-zp-tabbar .brand,
  body.home-layout-ref.has-zp-tabbar .brand {
    grid-column: 1 !important;
    grid-row: 1;
    justify-self: start !important;
    min-width: 0;
  }

  html.nav--compact body.home-layout-ref.has-zp-tabbar .brand-full-logo__img,
  body.home-layout-ref.has-zp-tabbar .brand-full-logo__img {
    height: clamp(29.04px, calc(44.77 / 714 * 100vw), 44.77px) !important;
    max-width: min(198px, 52vw);
    object-position: left center !important;
  }

  html.nav--compact body.home-layout-ref.has-zp-tabbar .nav-tray__login--mobile,
  html.nav--compact body.home-layout-ref.has-zp-tabbar .nav-tray > .zp-nav-bonus--mobile,
  body.home-layout-ref.has-zp-tabbar .nav-tray__login--mobile {
    grid-column: 2 !important;
    justify-self: end !important;
  }

  /* Плавающий FAB чата на мобилке скрыт — чат из таббара */
  body.has-zp-tabbar .zp-site-chat-fab,
  body.has-zp-tabbar #zpSiteChatFab {
    display: none !important;
  }

  /* Стеку мессенджеров место над таббаром */
  body.has-zp-tabbar .zp-site-chat-launcher {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
  }

  /* Панель чата — на весь экран; под клавиатуру — CSS vars из visualViewport */
  body.has-zp-tabbar .zp-site-chat,
  body.has-zp-tabbar.zp-site-chat-open .zp-site-chat {
    top: var(--zp-chat-vv-top, 0px) !important;
    right: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    width: 100% !important;
    height: var(--zp-chat-vv-h, 100svh) !important;
    max-height: var(--zp-chat-vv-h, 100svh) !important;
    border-radius: 0 !important;
    /* Выше scrim (12040) и таббара (2100), иначе чат закрыт тёмной подложкой */
    z-index: 12100 !important;
  }

  body.has-zp-tabbar .zp-site-chat__messages,
  body.has-zp-tabbar.zp-site-chat-open .zp-site-chat__messages {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  body.has-zp-tabbar .zp-site-chat__composer,
  body.has-zp-tabbar.zp-site-chat-open .zp-site-chat__composer {
    flex-shrink: 0 !important;
  }

  body.has-zp-tabbar .zp-site-chat.is-kb-open .zp-site-chat__composer {
    padding-bottom: 8px !important;
  }

  body.zp-lk-chat-open.has-zp-tabbar {
    padding-bottom: 0 !important;
  }

  body.zp-lk-chat-open .zp-tabbar,
  html.nav--compact body.zp-lk-chat-open .zp-tabbar,
  body.zp-site-chat-open .zp-tabbar,
  html.nav--compact body.zp-site-chat-open .zp-tabbar {
    transform: translate3d(0, 110%, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body.zp-site-chat-open.has-zp-tabbar {
    padding-bottom: 0 !important;
  }

  /* Отступ контента снизу, чтобы не перекрывался таббаром */
  body.has-zp-tabbar {
    --zp-tabbar-offset: calc(58px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  /* Мобильное меню: панель заканчивается над таббаром (мессенджеры не перекрыты) */
  body.has-zp-tabbar.home-layout-ref .nav-mobile-panel,
  body.has-zp-tabbar.home-layout-ref .nav-mobile-panel.nav-mobile-panel--bank-ref {
    height: calc(100dvh - var(--zp-tabbar-offset, 58px)) !important;
    max-height: calc(100dvh - var(--zp-tabbar-offset, 58px)) !important;
  }

  body.has-zp-tabbar.home-layout-ref .nav-mobile-drawer-foot,
  body.has-zp-tabbar.home-layout-ref .nav-mobile-drawer-zp,
  body.has-zp-tabbar.home-layout-ref .nav-mobile-drawer-footer {
    /* safe-area уже в высоте таббара / offset панели */
    padding-bottom: 16px;
  }
}

@media (min-width: 1320px) {
  html:not(.nav--compact) .zp-tabbar {
    display: none !important;
  }

  html:not(.nav--compact) body.has-zp-tabbar {
    padding-bottom: 0;
  }
}
