/**
 * Shared Digikala-style mobile bottom tabbar for ACC portals.
 * Visible only at max-width: 720px. Desktop keeps top nav.
 */
:root {
  --acc-tabbar-h: 62px;
  --acc-tabbar-bg: #ffffff;
  --acc-tabbar-border: #e8ece9;
  --acc-tabbar-ink: #6b7280;
  --acc-tabbar-active: #1f6b4a;
  --acc-tabbar-shadow: 0 -4px 20px rgba(15, 23, 20, 0.08);
}

.acc-portal-tabbar {
  display: none;
}

@media (max-width: 720px) {
  .acc-portal-tabbar {
    display: flex;
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 110;
    height: calc(var(--acc-tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    margin: 0;
    background: var(--acc-tabbar-bg);
    border-top: 1px solid var(--acc-tabbar-border);
    box-shadow: var(--acc-tabbar-shadow);
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    direction: rtl;
    -webkit-tap-highlight-color: transparent;
    /* iOS Safari fixed-position repaint/flicker fix during address-bar show/hide on scroll */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    will-change: transform;
    opacity: 1;
  }

  .acc-portal-tabbar[hidden],
  .acc-portal-tabbar.is-hidden {
    display: none !important;
  }

  .acc-portal-tabbar__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: var(--acc-tabbar-h);
    padding: 6px 2px;
    border: 0;
    background: transparent;
    color: var(--acc-tabbar-ink);
    text-decoration: none;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    position: relative;
  }

  .acc-portal-tabbar__item:active {
    opacity: 0.75;
  }

  .acc-portal-tabbar__item.is-active {
    color: var(--acc-tabbar-active);
    font-weight: 700;
  }

  .acc-portal-tabbar__icon {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    position: relative;
  }

  .acc-portal-tabbar__icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .acc-portal-tabbar__item.is-active .acc-portal-tabbar__icon svg {
    stroke-width: 2.1;
  }

  .acc-portal-tabbar__label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 2px;
  }

  .acc-portal-tabbar__badge {
    position: absolute;
    top: -4px;
    inset-inline-start: 55%;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    direction: ltr;
  }

  /* Reserve space so content isn't under the bar */
  body.acc-has-tabbar {
    padding-bottom: calc(var(--acc-tabbar-h) + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.acc-has-tabbar #acc-chat-launcher,
  body.acc-has-tabbar .acc-chat-launcher {
    bottom: calc(var(--acc-tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px) !important;
  }

  body.acc-has-tabbar #sp-track-float {
    bottom: calc(var(--acc-tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px) !important;
  }

  body.acc-has-tabbar .svc-toast,
  body.acc-has-tabbar .sp-toast,
  body.acc-has-tabbar #sp-toast {
    bottom: calc(var(--acc-tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px) !important;
  }

  /* Hide primary top tabs when bottom bar carries them */
  body.acc-has-tabbar .svc-ws-tabs--main,
  body.acc-has-tabbar.acc-tabbar-hide-top-tabs .el-tabs,
  body.acc-has-tabbar.acc-tabbar-hide-top-tabs .ws-tabs,
  body.acc-has-tabbar.acc-tabbar-hide-top-tabs .edu-header__nav,
  body.acc-has-tabbar.acc-tabbar-hide-top-tabs .edu-tabs,
  body.acc-has-tabbar.acc-tabbar-hide-top-tabs .ga-ws-nav,
  body.acc-has-tabbar.acc-tabbar-hide-top-tabs .em-main-tabs {
    display: none !important;
  }

  /* Checkout / sticky action bars sit above tabbar */
  body.acc-has-tabbar .sp-bar {
    bottom: calc(var(--acc-tabbar-h) + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.acc-has-tabbar.acc-tabbar-compact .acc-portal-tabbar {
    opacity: 0.97;
  }

  /* Reduce iOS auto-zoom on focused inputs near tabbar pages */
  body.acc-has-tabbar input,
  body.acc-has-tabbar select,
  body.acc-has-tabbar textarea {
    font-size: 16px;
  }

  .acc-portal-tabbar__item {
    touch-action: manipulation;
  }
}

/* Brand accents per portal body class */
body.svc-body { --acc-tabbar-active: #0284c7; }
body.melk-body { --acc-tabbar-active: #0e7490; }
body.edu-body { --acc-tabbar-active: #0f766e; }
body.ws-body,
body.wholesale-body { --acc-tabbar-active: #b45309; }
body.el-body,
body.election-body { --acc-tabbar-active: #1d4ed8; }
body.growth-body { --acc-tabbar-active: #0d7377; }
body.erp-applied-body,
body.hl-body { --acc-tabbar-active: #0ea5e9; }
body.vs-body { --acc-tabbar-active: #8b5cf6; }
