/**
 * parent-tab-bar.css — Bottom tab bar for parent PWA + native (mobile).
 * Desktop keeps sidebar; tab bar hidden from md breakpoint up.
 */

/* ── Mobile tab bar (PWA + native) ─────────────────────────────────────── */
@media (max-width: 767px) {
  /* Hide while a full-screen modal overlay is open — the tab bar sits above
     modal z-indexes and would otherwise cover modal content and stay tappable.
     body.modal-open is set deterministically by modal-open-observer.js;
     the :has() rule covers pages without the observer. */
  body.modal-open .native-tab-bar,
  body:has(> .fixed.inset-0:not(.hidden)) .native-tab-bar {
    visibility: hidden;
  }

  body.has-native-tab-bar .native-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.12);
    z-index: 10200;
    pointer-events: auto;
  }

  body.has-native-tab-bar .native-tab-bar .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: #8E8E93;
    font-size: 10px;
    padding: 6px 10px;
    min-width: 56px;
    transition: color 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  body.has-native-tab-bar .native-tab-bar .tab-icon {
    font-size: 22px;
    line-height: 1;
  }

  body.has-native-tab-bar .native-tab-bar .tab-item.active {
    color: #d8b35d;
  }

  body.has-native-tab-bar .native-tab-bar .tab-item:focus-visible {
    outline: 2px solid #e3c36b;
    outline-offset: 2px;
    border-radius: 12px;
  }

  body.has-native-tab-bar .native-tab-bar .tab-item:disabled,
  body.has-native-tab-bar .native-tab-bar .tab-item[aria-disabled="true"] {
    opacity: 0.4;
    pointer-events: none;
  }

  /* Six-tab layout (Hem·Schema·För dig·Skatt·Extra·Mer) */
  body.has-native-tab-bar .native-tab-bar.tab-bar--many .tab-item {
    min-width: 0;
    flex: 1 1 0;
    max-width: 72px;
    padding: 6px 2px;
    font-size: 9px;
  }

  body.has-native-tab-bar .native-tab-bar.tab-bar--many .tab-icon {
    font-size: 20px;
  }

  body.has-native-tab-bar .native-tab-bar.tab-bar--many .tab-label {
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }

  html.dark body.has-native-tab-bar .native-tab-bar,
  body.dark.has-native-tab-bar .native-tab-bar {
    background: rgba(28, 28, 30, 0.92);
    border-top-color: rgba(255, 255, 255, 0.1);
  }

  html.dark body.has-native-tab-bar .native-tab-bar .tab-item,
  body.dark.has-native-tab-bar .native-tab-bar .tab-item {
    color: #8E8E93;
  }

  html.dark body.has-native-tab-bar .native-tab-bar .tab-item.active,
  body.dark.has-native-tab-bar .native-tab-bar .tab-item.active {
    color: #d8b35d;
  }

  /* Main content clearance above tab bar */
  body.has-native-tab-bar main {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Hide duplicate legacy bottom nav + hamburger when tab bar active */
  body.has-native-tab-bar .parent-bottom-nav {
    display: none !important;
  }

  body.has-native-tab-bar .mobile-topbar,
  body.has-native-tab-bar .mobile-hamburger,
  body.has-native-tab-bar .mobile-dropdown {
    display: none !important;
  }

  /* Floating help above tab bar */
  body.has-native-tab-bar #helpBtn,
  body.has-native-tab-bar #hbBtn {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 64px) !important;
    z-index: 10001 !important;
  }

  body.has-native-tab-bar #globalFeedbackBtn,
  body.has-native-tab-bar .global-feedback-fab {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px) !important;
    right: max(16px, env(safe-area-inset-right, 0px)) !important;
    z-index: 10001 !important;
  }

  /* Mobile FAB defaults (before tab bar mounts) */
  #globalFeedbackBtn,
  .global-feedback-fab {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
    right: max(16px, env(safe-area-inset-right, 0px));
    z-index: 10001;
  }

  body:not(.has-native-tab-bar) #globalFeedbackBtn,
  body:not(.has-native-tab-bar) .global-feedback-fab {
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  }

  #hbBtn {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 64px);
    z-index: 10001;
  }
}

/* Desktop with mouse: sidebar only, no tab bar */
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  body.has-native-tab-bar .native-tab-bar {
    display: none !important;
  }
}
