/* =========================================================
   Mobile bottom navigation (footer_global.php .mnav)
   Everything stays inside the bar, so page-level sticky bars
   can sit directly on top without hiding anything.
   Other CSS uses var(--mnav-h) to stack above it.
   ========================================================= */
:root {
  --mnav-h: 0px;
}

.mnav {
  display: none;
}

@media (max-width: 767.98px) {
  :root {
    --mnav-h: calc(62px + env(safe-area-inset-bottom, 0px));
  }

  .mnav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    height: var(--mnav-h);
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid #e8edf2;
    box-shadow: 0 -6px 20px rgba(24, 55, 74, 0.08);
  }

  .mnav__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    color: #1f2d3a;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mnav__item:hover,
  .mnav__item:focus {
    color: #1f2d3a;
    text-decoration: none;
  }

  .mnav__item:focus-visible {
    outline: 2px solid #22b14c;
    outline-offset: -4px;
    border-radius: 12px;
  }

  .mnav__label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mnav__media {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    transition: transform 0.15s ease, background-color 0.15s ease;
  }

  .mnav__item:active .mnav__media {
    transform: scale(0.9);
  }

  .mnav__media > img {
    width: auto;
    max-width: 26px;
    height: auto;
    max-height: 26px;
  }

  /* Active page */
  .mnav__item.is-active {
    color: #15803d;
  }

  .mnav__item.is-active .mnav__media {
    background: #e9f8ee;
  }

  .mnav__item.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    right: 32%;
    left: 32%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: #22b14c;
  }

  /* Pharmacist: round avatar + online dot (no more overflowing photo) */
  .mnav__avatar {
    display: block;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border-radius: 50%;
    background: #eef6f1;
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #22b14c;
  }

  .mnav__avatar img {
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: 50% 0;
    transform: scale(1.55);
    transform-origin: 50% 6%;
  }

  .mnav__dot {
    position: absolute;
    right: -2px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #22c55e;
  }

  /* Referral: badge image kept inside the bar + amount pill */
  .mnav__media--refer {
    width: 40px;
  }

  .mnav__media--refer > img {
    max-width: 36px;
    max-height: 34px;
    border-radius: 8px;
  }

  .mnav__badge {
    position: absolute;
    top: -5px;
    right: -16px;
    padding: 1px 5px;
    border: 1.5px solid #fff;
    border-radius: 999px;
    background: #e11d48;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.35;
    white-space: nowrap;
  }

  /* Keep page content clear of the bar */
  .footer {
    margin-bottom: var(--mnav-h) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mnav__media {
    transition: none;
  }
}
