/* Phone-only bottom nav + anchor menu */

.nk-user-menu-toggle {
  white-space: nowrap;
}

.nk-top-nav-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 0.75rem;
  width: 100%;
}

.nk-top-nav-brand {
  justify-self: start;
}

.nk-top-nav-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.65rem;
  justify-self: center;
}

.nk-top-nav-balance {
  min-width: 0;
}

.nk-desktop-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  margin: 0.9rem auto 0;
  align-items: flex-start;
  justify-content: flex-start;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  width: fit-content;
  max-width: 100%;
}

.nk-nav-group {
  --nk-nav-accent-rgb: 108, 117, 125;
  flex: 0 0 auto;
  min-width: fit-content;
  padding: 0 0 0.55rem;
  border: 0;
  border-bottom: 3px solid rgba(var(--nk-nav-accent-rgb), 0.9);
  border-radius: 0;
  background: transparent;
}

.nk-nav-group[data-tone="capture"] { --nk-nav-accent-rgb: 91, 178, 255; }
.nk-nav-group[data-tone="analyze"] { --nk-nav-accent-rgb: 74, 201, 139; }
.nk-nav-group[data-tone="plan"] { --nk-nav-accent-rgb: 255, 193, 92; }
.nk-nav-group[data-tone="manage"] { --nk-nav-accent-rgb: 148, 163, 184; }
.nk-nav-group[data-tone="settings"] { --nk-nav-accent-rgb: 111, 207, 199; }

.nk-nav-group-title {
  margin-bottom: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.nk-nav-group-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.nk-desktop-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.05rem;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  line-height: 1.15;
  transition: color 0.15s ease;
}

.nk-desktop-nav-link:hover,
.nk-desktop-nav-link:focus {
  background: transparent;
  color: rgb(var(--nk-nav-accent-rgb));
}

.nk-desktop-nav-link.is-active {
  background: transparent;
  color: rgb(var(--nk-nav-accent-rgb));
  font-weight: 700;
}

.nk-desktop-nav-icon {
  line-height: 1;
}

@media (max-width: 991.98px) {
  .nk-top-nav-header {
    grid-template-columns: 1fr;
  }

  .nk-top-nav-brand,
  .nk-top-nav-controls {
    justify-self: start;
  }

  .nk-desktop-nav {
    display: flex;
    flex-wrap: wrap;
  }

  .nk-nav-group {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 13rem;
  }
}

/* Mobile Bottom-Nav (Neufassung).
   Klassisches position:fixed direkt auf der Nav -- ohne 100svh/dvh-
   Container-Trick, der das Menue beim Scrollen mitbewegt hat.
   position:fixed; bottom:0 bleibt am visuellen Viewport-Boden, auch
   waehrend die URL-Leiste rein-/ausblendet. */
.nk-bottom-nav-host {
  display: none;
}

.nk-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  min-height: 48px;
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-sizing: border-box;
}

.nk-bottom-nav .nk-bottom-item {
  flex: 1 1 0;
  min-width: 0;
  text-decoration: none;
  /* Bootstrap py-2 (0.5rem) ist hier zu üppig - das Menü ist sonst höher
     als seine Buttons brauchen. */
  padding-top: 0.25rem !important;
  padding-bottom: 0.25rem !important;
}

.nk-bottom-nav .nk-bottom-icon {
  display: block;
  line-height: 1;
  font-size: 1.05rem;
}

.nk-bottom-nav .nk-bottom-label {
  display: block;
  font-size: 0.68rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* Phone only (Bootstrap xs) */
@media (max-width: 575.98px) {
  .nk-top-nav-actions {
    display: none !important;
  }

  .nk-bottom-nav-host {
    display: block;
  }
  .nk-bottom-nav {
    display: block;
  }

  /* Body bekommt unten Platz, damit das fixierte Menue nichts abdeckt. */
  body {
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 0)) !important;
  }

  /* Footer auf Phones ausblenden - das Bottom-Menue ist die einzige Nav. */
  footer.nk-footer {
    display: none !important;
  }

  main.nk-main {
    padding-bottom: 0.75rem;
  }

  a.nk-jump[href^="#"] {
    display: none !important;
  }
}

/* ---------------------------------------------------------------------------
 * nk-sheet: Bottom-Sheet ohne Bootstrap-Offcanvas
 *
 * Funktioniert in Firefox, Chrome, Safari und im Capacitor-WebView. Verwendet
 * keine 100dvh-Tricks, sondern ein fixed-positioniertes Backdrop + Panel.
 * Aktivierung via JS: Element bekommt Klasse `is-open` und das `hidden`
 * Attribut wird entfernt.
 * --------------------------------------------------------------------------- */

.nk-sheet {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: block;
}

.nk-sheet[hidden] {
  display: none;
}

.nk-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.nk-sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
  transform: translateY(100%);
  transition: transform 0.22s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nk-sheet.is-open .nk-sheet-backdrop {
  opacity: 1;
}

.nk-sheet.is-open .nk-sheet-panel {
  transform: translateY(0);
}

.nk-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid #eee;
}

.nk-sheet-title {
  margin: 0;
  font-size: 1.05rem;
}

.nk-sheet-close {
  appearance: none;
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: #555;
}

.nk-sheet-body {
  overflow-y: auto;
  padding: 0.5rem 1rem 1rem;
  -webkit-overflow-scrolling: touch;
}

/* Wenn ein Sheet offen ist, Hintergrund-Scroll sperren. Reduces Firefox-Glitches. */
body.nk-sheet-locked {
  overflow: hidden;
  /* iOS-WebView reagiert nicht immer auf overflow:hidden; touch-action puffert. */
  touch-action: none;
}

/* Aktive Bottom-Tab Hervorhebung */
.nk-bottom-nav .nk-bottom-item.is-active {
  color: #5bb2ff !important;
  font-weight: 600;
}

.nk-bottom-nav .nk-bottom-item.is-active .nk-bottom-icon {
  transform: translateY(-1px);
}

/* Capacitor-Erkennung: <html data-nk-app="1"> wird von nk_app.js gesetzt.
   In der App blenden wir Login/Account-Erstellen-Links aus, da diese in
   der App ueber den Login-Screen laufen. Header-Brand ebenfalls schlanker. */
html[data-nk-app="1"] body { padding-top: env(safe-area-inset-top, 0); }
html[data-nk-app="1"] .nk-app-hide { display: none !important; }

