/**
 * Vaulten PWA — global bottom tab bar (Home · Modules · Alerts · Search)
 * Shown on mobile / standalone; defers to module-specific bars when present.
 */
.v1-pwa-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9000;
  padding: 6px max(8px, env(safe-area-inset-left, 0px))
    max(6px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-right, 0px));
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.06);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.v1-pwa-bottom-nav__inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  max-width: 520px;
  margin: 0 auto;
}

.v1-pwa-bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 4px 6px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #64748b;
  text-decoration: none;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.v1-pwa-bottom-nav__item:hover,
.v1-pwa-bottom-nav__item:focus-visible {
  color: #175e7d;
  background: rgba(23, 94, 125, 0.06);
  outline: none;
}

.v1-pwa-bottom-nav__item.is-active {
  color: #175e7d;
}

.v1-pwa-bottom-nav__item.is-active .v1-pwa-bottom-nav__icon {
  background: rgba(23, 94, 125, 0.12);
  color: #175e7d;
}

.v1-pwa-bottom-nav__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 10px;
  color: inherit;
}

.v1-pwa-bottom-nav__icon svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

.v1-pwa-bottom-nav__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Search sheet */
.v1-pwa-bottom-nav-search {
  position: fixed;
  inset: 0;
  z-index: 9100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s;
}

.v1-pwa-bottom-nav-search.is-open {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

.v1-pwa-bottom-nav-search__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  border: 0;
  padding: 0;
  cursor: pointer;
}

.v1-pwa-bottom-nav-search__panel {
  position: relative;
  margin: 0 max(8px, env(safe-area-inset-right, 0px)) calc(64px + env(safe-area-inset-bottom, 0px))
    max(8px, env(safe-area-inset-left, 0px));
  padding: 14px 14px 12px;
  background: #fff;
  border-radius: 16px 16px 14px 14px;
  box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.14);
  max-height: min(70vh, 420px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.v1-pwa-bottom-nav-search__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v1-pwa-bottom-nav-search__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
  color: #0f172a;
  background: #f8fafc;
}

.v1-pwa-bottom-nav-search__input:focus {
  outline: 2px solid rgba(23, 94, 125, 0.35);
  outline-offset: 0;
  border-color: #175e7d;
  background: #fff;
}

.v1-pwa-bottom-nav-search__close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: #f1f5f9;
  color: #475569;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.v1-pwa-bottom-nav-search__results {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.v1-pwa-bottom-nav-search__results:empty::before {
  content: "Type to find a module…";
  display: block;
  padding: 8px 4px;
  font-size: 0.875rem;
  color: #94a3b8;
}

.v1-pwa-bottom-nav-search__hit {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: #0f172a;
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 600;
}

.v1-pwa-bottom-nav-search__hit:hover,
.v1-pwa-bottom-nav-search__hit:focus-visible {
  background: #f1f5f9;
  color: #175e7d;
  outline: none;
}

.v1-pwa-bottom-nav-search__hit small {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
}

@media (max-width: 900px), (display-mode: standalone) {
  .v1-pwa-bottom-nav {
    display: block;
  }

  body.v1-pwa-bottom-nav-active {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.v1-pwa-bottom-nav-active .wrap {
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }
}

/* Module-specific bottom bars take precedence */
body.inv-staff-module-page .v1-pwa-bottom-nav,
body:has(.tenant-sidebar) .v1-pwa-bottom-nav,
body:has(.v1-admin-shell) .v1-pwa-bottom-nav {
  display: none !important;
}

body.inv-staff-module-page.v1-pwa-bottom-nav-active,
body:has(.tenant-sidebar).v1-pwa-bottom-nav-active,
body:has(.v1-admin-shell).v1-pwa-bottom-nav-active {
  padding-bottom: 0 !important;
}
