/* Нижнее мобильное меню. Работает только до 767px. */
:root {
  --mnav-accent: #0e6a86;   /* активный пункт, кнопки */
  --mnav-alert: #d4452a;    /* бейджи счётчиков */
  --mnav-ink: #1d2a31;
  --mnav-muted: #6b7a83;
  --mnav-line: #dfe6ea;
  --mnav-h: 58px;
}

#mnav, .mnav-sheet, .mnav-backdrop { display: none; }

@media (max-width: 767px) {
  body { padding-bottom: calc(var(--mnav-h) + env(safe-area-inset-bottom, 0px)); }
  body.mnav-lock { overflow: hidden; }

  /* Скрываем плавающие виджеты обратной связи/чата на мобильных, чтобы не перекрывали нижнее меню */
  #uptocall-mini, jdiv, .jivo-btn, #jivo-iframe-container, [class^="jivo-"], #back-top {
    display: none !important;
  }

  #mnav {
    display: flex; position: fixed; z-index: 1040; left: 0; right: 0; bottom: 0;
    height: calc(var(--mnav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff; border-top: 1px solid var(--mnav-line);
  }
  .mnav-item {
    flex: 1 1 0; min-width: 0; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 0 2px; margin: 0; border: 0; background: none;
    color: var(--mnav-muted); font: 500 11px/1 "Open Sans", Arial, sans-serif;
    text-decoration: none; -webkit-tap-highlight-color: transparent; cursor: pointer;
  }
  .mnav-item svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .mnav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mnav-item:hover, .mnav-item:focus { color: var(--mnav-ink); text-decoration: none; }
  .mnav-item:focus-visible { outline: 2px solid var(--mnav-accent); outline-offset: -4px; }

  /* Аватар профиля в нижнем меню */
  .mnav-avatar-wrap {
    position: relative; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  }
  .mnav-avatar {
    width: 24px; height: 24px; border-radius: 50%; object-fit: cover; border: 1.5px solid var(--mnav-accent); display: block;
  }
  .mnav-avatar-fallback {
    width: 24px; height: 24px; border-radius: 50%; background: var(--mnav-accent); color: #fff;
    font: 700 12px/24px "Open Sans", Arial, sans-serif; text-align: center; text-transform: uppercase;
  }
  .mnav-online-dot {
    position: absolute; right: -1px; bottom: -1px; width: 8px; height: 8px; border-radius: 50%;
    background: #22c55e; border: 1.5px solid #fff;
  }

  /* Текущий раздел: цвет + полоска сверху */
  .mnav-item.is-active { color: var(--mnav-accent); }
  .mnav-item.is-active::before {
    content: ""; position: absolute; top: -1px; left: 22%; right: 22%; height: 3px;
    background: var(--mnav-accent); border-radius: 0 0 3px 3px;
  }

  .mnav-badge {
    position: absolute; top: 6px; left: calc(50% + 6px);
    min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box;
    border-radius: 9px; background: var(--mnav-alert); color: #fff;
    font: 700 10px/17px "Open Sans", Arial, sans-serif; text-align: center;
  }
  .mnav-badge[hidden] { display: none; }

  /* Подложка и шторки */
  .mnav-backdrop { display: block; position: fixed; inset: 0; z-index: 1050; background: rgba(15, 28, 35, .45); }
  .mnav-backdrop[hidden] { display: none; }

  .mnav-sheet {
    display: block; position: fixed; z-index: 1060; left: 0; right: 0; bottom: 0;
    max-height: 80vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: #fff; border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(100%); visibility: hidden;
    transition: transform .22s ease-out, visibility 0s linear .22s;
  }
  .mnav-sheet.is-open { transform: none; visibility: visible; transition-delay: 0s; }
  .mnav-sheet[hidden] { display: block; }

  .mnav-sheet > header {
    position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 10px; background: #fff; border-bottom: 1px solid var(--mnav-line);
  }
  .mnav-sheet h3 { margin: 0; font: 700 17px/1.2 "Open Sans", Arial, sans-serif; color: var(--mnav-ink); }
  .mnav-close { border: 0; background: none; font-size: 28px; line-height: 1; color: var(--mnav-muted); padding: 0 4px; cursor: pointer; }
  .mnav-sheet-body { padding: 8px 16px 18px; }

  /* Каталог */
  .mnav-cat > a, .mnav-sub a {
    display: block; color: var(--mnav-ink); text-decoration: none;
  }
  .mnav-cat > a { padding: 13px 0; font: 600 15px/1.3 "Open Sans", Arial, sans-serif; border-bottom: 1px solid var(--mnav-line); }
  .mnav-sub { margin: 0; padding: 4px 0 8px 14px; list-style: none; border-bottom: 1px solid var(--mnav-line); }
  .mnav-sub a { padding: 8px 0; font: 400 14px/1.3 "Open Sans", Arial, sans-serif; color: var(--mnav-muted); }
  .mnav-cat > a + .mnav-sub { margin-top: -1px; }

  /* Поиск */
  .mnav-search { display: flex; gap: 8px; padding-top: 10px; }
  .mnav-search input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--mnav-line); border-radius: 8px; font-size: 16px; }
  .mnav-search input:focus { outline: 2px solid var(--mnav-accent); border-color: transparent; }
  .mnav-search button { height: 44px; padding: 0 18px; border: 0; border-radius: 8px; background: var(--mnav-accent); color: #fff; font-weight: 600; }

  /* Вход */
  .mnav-note { margin: 10px 0 14px; color: var(--mnav-muted); font-size: 14px; line-height: 1.45; }
  #mnav-tg-widget { min-height: 44px; margin-bottom: 14px; }
  .mnav-link { display: block; padding: 12px 0; border-top: 1px solid var(--mnav-line); color: var(--mnav-accent); font-weight: 600; }
}

@media (prefers-reduced-motion: reduce) {
  .mnav-sheet { transition: none; }
}
