/* ===== SLOTH — Navigation Bar ===== */

/* ── Fixed Top Bar ──────────────────────────────────────── */
.navbar-closed {
  position: fixed !important;
  /* 0 élesben — a token akkor nem nulla, ha a környezet-sáv renderelődik. */
  top: var(--env-banner-height);
  left: 0;
  width: 100%;
  height: var(--nav-height);
  background-color: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-nav-top);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  padding: 0 var(--space-4);
  box-sizing: border-box;
  z-index: 50;
  transition: background-color var(--ease-base), border-color var(--ease-base), box-shadow var(--ease-base);
}

/* ── Navbar Slots ───────────────────────────────────────── */
.nav-slot-left {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  position: relative;
}

.nav-slot-right {
  /* A `margin-left: auto` tolja a jobb szélre; korábban egy azóta megszűnt üres középső slot tette. */
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── Menu Button ────────────────────────────────────────── */
.nav-menu-btn {
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--ease-fast);
}

.nav-menu-btn:hover {
  background: var(--bg-muted);
}

.nav-menu-btn--desktop {
  display: none;
}

.nav-avatar-right {
  display: none !important;
}

/* ── Avatar ─────────────────────────────────────────────── */
.avatar-container {
  width: 2.25rem;
  height: 2.25rem;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-wrapper {
  position: absolute;
  inset: 0;
}

.avatar-icon {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  width: 2.25rem;
  height: 2.25rem;
  overflow: hidden;
  object-fit: cover;
  border: none;
  outline: none;
  box-shadow: none;
}

.avatar-icon:hover,
.avatar-icon:focus,
.avatar-icon:focus-visible,
.avatar-icon:active {
  border: none;
  outline: none;
  box-shadow: none;
}

/* ── Page Title (absolutely centered across full navbar width) ── */
.app-title {
  position: absolute;
  left: var(--space-4);
  right: var(--space-4);
  text-align: center;
  pointer-events: none;
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 0;
}

/* ── Menu Toggle Button (legacy wrapper, kept for back-compat) ── */
.menu-icon {
  width: 2.25rem;
  height: 2.25rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-icon button {
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--ease-fast);
}

.menu-icon button:hover {
  background: var(--bg-muted);
}

/* Menu toggle SVG icon */
.menu-hamburger-icon {
  color: var(--text-secondary);
  display: block;
}

/* Back button inline SVG */
.nav-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

/* Legacy img icon fallback */
.menu-icon img,
.navbar-closed .avatar-icon img {
  width: 2.25rem;
  height: 2.25rem;
  object-fit: contain;
}

[data-theme="dark"] .menu-icon img,
[data-theme="dark"] .navbar-closed .back-icon-img {
  filter: invert(1);
}

/* ── Notification dot on menu icon ──────────────────────── */
.nav-notif-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  background: var(--clr-orange);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-nav);
  pointer-events: none;
}

/* ── Side Navigation Menu ───────────────────────────────── */
#menu {
  /* Spacing knobs the height media-queries below tighten on short screens. */
  --nav-pad-y: var(--space-3);
  --nav-item-pad-y: var(--space-2);
  --nav-list-gap: var(--space-1);
  /* Térköz az elemlista és a téma/jogi blokk között; összenyomott menünél szélesebb. */
  --nav-picker-gap: 0px;

  position: fixed;
  top: calc(var(--nav-height) + var(--env-banner-height));
  right: 0;
  height: calc(100dvh - var(--nav-height) - var(--env-banner-height));
  width: max-content;
  min-width: 260px;
  max-width: 320px;
  background-color: var(--bg-menu);
  border-left: 1px solid var(--border);
  z-index: 40;
  transition: transform var(--ease-slow), background-color var(--ease-base);
  padding: var(--nav-pad-y) var(--space-8) var(--nav-pad-y) var(--space-4);
  padding-bottom: max(calc(var(--footer-height) + var(--space-6)), calc(env(safe-area-inset-bottom, 0px) + var(--footer-height) + var(--space-4)));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  transform: translateX(110%);
  overflow-y: auto;
  box-shadow: var(--shadow-menu);
}

/* Compress the menu on short viewports so it scrolls less (small phones). */
@media (max-height: 760px) {
  #menu {
    --nav-pad-y: var(--space-2);
    --nav-item-pad-y: var(--space-1);
    --nav-list-gap: 2px;
    --nav-picker-gap: var(--space-4);
  }
}

@media (max-height: 620px) {
  #menu {
    --nav-pad-y: var(--space-1);
    --nav-item-pad-y: 3px;
    --nav-list-gap: 1px;
  }
  .nav-item-group { font-size: var(--text-sm); }
  .nav-item-icon { width: 1.125rem; height: 1.125rem; }
}

#menu.open {
  transform: translateX(0);
}

#menu ul {
  display: flex;
  flex-direction: column;
  gap: var(--nav-list-gap);
  padding: 0;
  margin: 0;
  margin-bottom: var(--nav-picker-gap);
}

/* ── Nav Item Container ─────────────────────────────────── */
.nav-items-containter {
  position: relative;
}

.nav-item-wrapper {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}

.nav-item {
  width: 100%;
}

.nav-item-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
  padding: var(--nav-item-pad-y, var(--space-2)) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: 500;
  transition: background var(--ease-fast), color var(--ease-fast);
  text-decoration: none;
}

.nav-item-group:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.nav-item-group--danger {
  color: var(--clr-red);
}

.nav-item-group--danger:hover {
  background: var(--clr-red-light);
  color: var(--clr-red);
}

.nav-item-icon {
  width: 1.375rem;
  height: 1.375rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  opacity: 0.75;
  transition: opacity var(--ease-fast);
}

.nav-item-icon svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.nav-item-icon img {
  width: 100%;
  height: 100%;
}

[data-theme="dark"] .nav-item-icon img {
  filter: invert(1);
}

.nav-item-group:hover .nav-item-icon {
  opacity: 1;
}

.nav-item-text {
  flex: 1;
}

/* ── Notification label in nav ───────────────────────────── */
.nav-notif-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-notif-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--clr-orange);
  color: var(--text-inverse);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
}

/* ── Theme picker ────────────────────────────────────────── */
.nav-theme-picker {
  display: flex;
  /* margin-top:auto keeps the theme picker + legal links pinned to the bottom
     when the menu fits, but lets them scroll with the list when it overflows. */
  margin: auto var(--space-4) var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-surface);
  overflow: hidden;
  flex-shrink: 0;
}

.nav-theme-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) var(--space-1);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--ease-fast), color var(--ease-fast);
  line-height: 1;
}

.nav-theme-btn:last-child { border-right: none; }
.nav-theme-btn:hover { background: var(--bg-muted); color: var(--text-primary); }
.nav-theme-btn.active { background: var(--clr-green); color: var(--text-inverse); border-right-color: var(--clr-green); }
.nav-theme-btn.active + .nav-theme-btn { border-left-color: var(--clr-green); }

/* ── Legal links ─────────────────────────────────────────── */
.nav-legal-links {
  display: none; /* hidden on mobile — shown only on larger screens */
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  justify-content: center;
  padding: var(--space-2) 0 0;
  border-top: 1px solid var(--border);
  margin-top: var(--space-2);
  flex-shrink: 0;
  width: 100%;
}

@media (min-height: 600px) {
  .nav-legal-links {
    display: flex;
  }
}

.nav-legal-links a {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-decoration: none;
  text-align: center;
  transition: color var(--ease-fast);
}

.nav-legal-links a:hover {
  color: var(--text-secondary);
}

/* ── Menu Overlay ───────────────────────────────────────── */
#menu-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ease-slow), visibility var(--ease-slow);
  z-index: 30;
}

#menu-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ── Nav Inner Wrapper (centers content to match page layout) ── */
.nav-inner {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  gap: 0;
  position: relative; /* app-title absolute-positions within nav-inner */
}

/* ── Desktop Navigation (1024 px+) ──────────────────────── */
@media (min-width: 1024px) {
  /* Overlay never shown on desktop — clicking beside menu does not close it */
  #menu-overlay {
    display: none !important;
  }

  /* Remove footer-height based bottom padding — no footer on desktop */
  #menu {
    left: 0;
    right: auto;
    width: var(--desktop-nav-width);
    min-width: var(--desktop-nav-width);
    max-width: var(--desktop-nav-width);
    border-left: none;
    border-right: 1px solid var(--border);
    transform: translateX(-110%);
    transition: background-color var(--ease-base);
    padding: var(--space-4);
    padding-bottom: var(--space-8);
  }

  /* Outer bar keeps full-width background; when the desktop sidebar is open,
     align the topbar content with the remaining content canvas. */
  .navbar-closed {
    padding: 0;
  }

  .nav-inner {
    display: grid;
    /* Three columns since the search left the navbar: back/avatar, title,
       menu. The fourth used to hold the search field. */
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--space-4);
    max-width: none;
    margin: 0;
    padding: 0 var(--space-5);
    box-sizing: border-box;
  }

  .nav-slot-left,
  .app-title {
    min-width: 0;
  }

  .nav-slot-left {
    width: auto;
    justify-content: flex-start;
  }

  .app-title {
    position: static;
    left: auto;
    right: auto;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
    display: block;
  }

  .nav-menu-btn--desktop {
    display: flex;
    position: relative;
  }

  .nav-menu-btn--mobile {
    display: none;
  }

  .nav-avatar-left {
    display: none !important;
  }

  .nav-back-container {
    display: flex !important;
  }

  .nav-avatar-right {
    display: flex !important;
  }

  .nav-slot-right {
    margin-left: 0;
    justify-self: end;
    width: auto;
    overflow: visible;
    gap: var(--space-3);
  }

  .nav-legal-links {
    justify-content: flex-start;
  }
}

@media (min-width: 1440px) {
  .nav-inner {
    padding: 0 var(--space-4);
  }
}

/* ── Dark mode toggle button ─────────────────────────────── */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--ease-fast), color var(--ease-fast);
}

.theme-toggle-btn:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.theme-toggle-icon {
  width: 1.375rem;
  height: 1.375rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity var(--ease-fast);
}

.theme-toggle-btn:hover .theme-toggle-icon {
  opacity: 1;
}
