/* ── Mobile bottom navigation ────────────────────────────────────────────────
   Visas på mobil (<768px) och alltid i native-appen (.is-native-app).
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --bottom-nav-h: 56px;
  --bottom-nav-safe: env(safe-area-inset-bottom, 0px);
}

/* ── Bottom nav bar ──────────────────────────────────────────────────────── */
#bottomNav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-h) + var(--bottom-nav-safe));
  padding-bottom: var(--bottom-nav-safe);
  background: var(--color-bg-surface);
  border-top: 1px solid var(--color-border);
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.07);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* Show only on real touch devices (phone/tablet) — NOT on Mac/PC with narrow window.
   hover:none + pointer:coarse = touchscreen. A Mac with a narrow browser still has
   hover:hover + pointer:fine (mouse), so it never triggers here. */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
  #bottomNav { display: flex; }
}

/* Always show in native Capacitor app regardless of viewport */
.is-native-app #bottomNav { display: flex; }

/* Landning / inlogg — ingen app-meny längst ner */
body:has(#authPage.active) #bottomNav,
body:has(#authPage.active) #moreSheet {
  display: none !important;
}

/* Hide topbar top-nav on real mobile devices when bottom nav is shown */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
  .top-nav { display: none !important; }
  .topbar-logo { margin-right: auto; }

  /* Extra padding so content doesn't hide behind bottom nav */
  #appContent,
  .app-main,
  #mainContent {
    padding-bottom: calc(var(--bottom-nav-h) + var(--bottom-nav-safe) + 8px);
  }
}

.is-native-app .top-nav { display: none !important; }
.is-native-app #appContent,
.is-native-app .app-main,
.is-native-app #mainContent {
  padding-bottom: calc(var(--bottom-nav-h) + var(--bottom-nav-safe) + 8px);
}

/* ── Nav items ───────────────────────────────────────────────────────────── */
.bottom-nav-items {
  display: flex;
  width: 100%;
  align-items: stretch;
  height: var(--bottom-nav-h);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  padding: 6px 4px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.15s;
  flex-shrink: 0;
}

.bottom-nav-item:active {
  opacity: 0.7;
}

.bottom-nav-item.active {
  color: var(--color-brand);
}

.bottom-nav-item.active svg {
  stroke-width: 2.3;
}

/* Active dot indicator */
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--color-brand);
  border-radius: 0 0 3px 3px;
}

/* Badge (unread count etc.) */
.bottom-nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  background: #DC2626;
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--color-bg-surface);
}

/* ── "Mer"-sheet ──────────────────────────────────────────────────────────── */
#moreSheet {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

#moreSheet.open { display: block; }

.more-sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}

.more-sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg-surface);
  border-radius: 20px 20px 0 0;
  padding: 16px 20px calc(16px + var(--bottom-nav-safe));
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.more-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.more-sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.more-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: none;
  background: var(--color-bg-subtle, #F3F4F6);
  border-radius: 12px;
  color: var(--color-text-primary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.more-sheet-item:active { background: var(--color-brand-subtle); color: var(--color-brand); }

.more-sheet-item svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
