/*
 * OnlyFanOuts - Navigation Component: env banner, user menu, topbar icons and counts.
 *
 * @author Sander Tamaela
 * @created 2026-02-14
 * @modified 2026-09-25
 */

/* Environment banner */
.env-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  width: 100vw;
  text-align: center;
  padding: 4px 0;
  font-size: 13px;
  font-weight: 600;
}
body:has(.env-banner) {
  padding-top: 26px;
}
.env-staging { background: #22c55e; color: #000; }
.env-live { background: #dc2626; color: #fff; }
.env-banner-link { color: inherit; margin-left: 8px; text-decoration: underline; }
.env-banner-link:hover { opacity: 0.8; }

/* Main nav bar - edge-to-edge to match sidebar/topbar positioning.
   Negative margins counteract body padding so brand & logout align
   at the same 20px offset as the sidebar brand block and topbar. */
.ofo-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 65px;
  padding: 0 20px;
  margin: -20px -20px 20px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
}
/* When env banner is active, body padding-top is 26px (not 20px) to clear
   the fixed banner.  Don't negate it - let the nav sit below the banner. */
body:has(.env-banner) .ofo-nav {
  margin-top: 0;
}

.ofo-nav-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.ofo-nav-brand-wrap {
  display: flex;
  flex-direction: column;
}
.ofo-nav-brand {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 16px;
  text-decoration: none;
  display: block;
  line-height: 1.1;
}
.ofo-nav-brand:hover { text-decoration: none; }
.ofo-nav-tagline {
  font-size: 9px;
  color: var(--gray-400);
  font-weight: 400;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

.ofo-nav-items {
  display: flex;
  gap: 16px;
  align-items: center;
}

/* Nav links */
.ofo-nav-link {
  color: var(--gray-600);
  text-decoration: none;
  transition: color 0.2s;
}
.ofo-nav-link:hover {
  color: var(--blue-500);
  text-decoration: none;
}
.ofo-nav-link.active {
  color: var(--blue-500);
  font-weight: 600;
}

/* Dropdown trigger (link + arrow) */
.ofo-nav-link.has-dropdown {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ofo-nav-arrow {
  font-size: 10px;
  color: var(--gray-400);
}

/* Top-level dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  z-index: 1000;
  padding: 4px 0;
}

.nav-dropdown-item {
  display: block;
  padding: 8px 12px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s;
}
.nav-dropdown-item:hover {
  background: var(--gray-100);
  text-decoration: none;
}

/* Sub-dropdown with arrow */
.nav-dropdown-item.has-children {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-sub-arrow {
  font-size: 10px;
  color: var(--gray-400);
  margin-left: 8px;
}

/* Nested sub-dropdown */
.nav-sub-dropdown {
  position: relative;
}

.nav-sub-dropdown-menu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 1001;
  padding: 4px 0;
}

.nav-sub-dropdown-item {
  display: block;
  padding: 8px 12px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.2s;
}
.nav-sub-dropdown-item:hover {
  background: var(--gray-100);
  text-decoration: none;
}

/* Right side */
.ofo-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* User menu */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 4px;
}

.user-menu-email {
  color: var(--gray-500);
  font-size: 14px;
}

.user-menu-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: #fff;
}
.user-menu-badge.admin    { background: var(--purple-500); }
.user-menu-badge.verified { background: #16a34a; }
.user-menu-badge.unverified { background: #dc2626; }

.user-menu-arrow {
  color: var(--gray-400);
  font-size: 10px;
}

.user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 1000;
}

.user-menu-section {
  padding: 8px 12px;
  border-top: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
  font-size: 12px;
  color: var(--gray-500);
}
.user-menu-section:first-child { border-top: none; }

.user-menu-item {
  display: block;
  padding: 8px 12px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s;
}
.user-menu-item:hover {
  background: var(--gray-100);
  text-decoration: none;
}

/* Admin count (new accounts awaiting approval). Same red pill as
   .topbar-notification-badge so every "needs your attention" number in the
   topbar reads as one thing; inline rather than absolutely positioned because
   it sits in a text row, not on an icon. */
.user-menu-count {
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* The same count on a sidebar item (stopped Google Sheets syncs). */
.ofo-sidebar-count { margin-left: 6px; vertical-align: 1px; }
.user-menu-item--count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Topbar notification badge (admin requeue alerts) */
.topbar-notification {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  text-decoration: none;
  padding: 4px;
  margin-right: 4px;
  transition: color 0.2s;
}
.topbar-notification:hover {
  color: var(--gray-700);
  text-decoration: none;
}
/* Generic warning / alert color modifiers - reusable across any topbar
   notification that needs to surface a non-default status. Warn = amber
   (something needs attention), alert = red (something is broken). */
.topbar-notification--warn {
  color: #d97706;
}
.topbar-notification--warn:hover {
  color: #b45309;
}
.topbar-notification--alert {
  color: #dc2626;
}
.topbar-notification--alert:hover {
  color: #b91c1c;
}
.topbar-notification-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Auth action buttons in nav */
.nav-btn {
  display: inline-block;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s, border-color 0.2s;
}
.nav-btn:hover { text-decoration: none; }

.nav-btn-login {
  background: var(--blue-500);
  border: 1px solid var(--blue-500);
  color: #fff;
}
.nav-btn-login:hover { background: var(--blue-600); }

.nav-btn-logout {
  background: #fff;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-btn-logout:hover { border-color: var(--gray-400); }
.nav-btn-logout svg { display: block; }

.nav-btn-return-admin {
  background: var(--purple-500);
  border: 1px solid var(--purple-500);
  color: #fff;
  margin-right: 8px;
}
.nav-btn-return-admin:hover { background: var(--purple-600); }

/* ── Accessibility: focus-visible outlines (keyboard only) ── */
.ofo-nav-link:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.nav-dropdown-item:focus-visible,
.nav-sub-dropdown-item:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: -2px;
}
.user-menu-trigger:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.user-menu-item:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: -2px;
}
.nav-btn:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}
.ofo-nav-brand:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Mobile: match sidebar brand height (48px) ── */
@media (max-width: 767px) {
  .ofo-nav {
    height: 48px;
    padding: 0 12px;
    margin: -20px -20px 12px;
  }

  .ofo-nav-items {
    display: none;
  }

  .ofo-nav-right .user-menu-email {
    display: none;
  }

  .topbar-notification {
    min-width: 44px;
    min-height: 44px;
  }

  /* Tighten the icon-row spacing on mobile. Desktop uses gap: 16px on the
     topbar (overridden below in sidebar.css mobile block) AND margin-right:
     4px on each notification - effective ~20px between items. With 44x44
     tap targets each visible 18px glyph already has 13px of padding around
     it, so the extra gap reads as "floating individuals" rather than a
     tools group. Drop the redundant margin here; topbar gap is tightened
     in sidebar.css to avoid losing to its later-loaded ruleset. */
  .ofo-topbar .topbar-notification {
    margin-right: 0;
  }

  /* Visual separator between page-tool icons and the account cluster
     (user-menu + logout), rendered as a 1px x 18px gray-200 line via
     a ::before on .user-menu. .user-menu becomes a flex container so the
     pseudo-element aligns alongside its existing .user-menu-trigger
     child. The dropdown panel inside is position: absolute so it doesn't
     affect the flex flow. */
  .ofo-topbar .user-menu {
    display: flex;
    align-items: center;
  }
  .ofo-topbar .user-menu::before {
    content: '';
    display: block;
    width: 1px;
    height: 18px;
    background: var(--gray-200);
    margin-right: 10px;
  }

  /* Loosen the dot+arrow cluster to match the icon-row density - the dots
     felt cramped at 6px against the more spacious icon row. */
  .ofo-topbar .user-menu-trigger {
    gap: 8px;
  }

  /* Collapse Admin/Verified/Unverified text badges to colored dots on mobile.
     The class carries the color (.admin/.verified/.unverified) so dropping
     the text doesn't lose the state cue. font-size:0 hides the visual text
     but leaves it readable to screen readers, so a11y stays intact. */
  .ofo-topbar .user-menu-badge,
  .ofo-nav .user-menu-badge {
    font-size: 0;
    padding: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
  }

  /* Logout: icon-only on mobile. aria-label on the <a> carries the meaning
     for assistive tech once the visible "Logout" word is hidden. Strip the
     button chrome (border + white background) so it visually matches the
     adjacent .topbar-notification icons - the row reads as a strip of icons
     instead of "icons + boxed button". Tap target stays the same 44x44 the
     other icons use. */
  .ofo-topbar .nav-btn-logout .nav-btn-label,
  .ofo-nav .nav-btn-logout .nav-btn-label {
    display: none;
  }
  .ofo-topbar .nav-btn-logout,
  .ofo-nav .nav-btn-logout {
    padding: 0;
    gap: 0;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--gray-500);
  }
  .ofo-topbar .nav-btn-logout:hover,
  .ofo-nav .nav-btn-logout:hover {
    color: var(--gray-700);
    border-color: transparent;
  }

  /* Notification badge: the 18px icon is centered in a 44x44 tap target on
     mobile, leaving ~13px of empty space above it - so the absolutely-
     positioned badge (top: -4px relative to the box, fine on desktop) ends
     up floating high above the icon. Re-anchor closer to the visible icon
     corner. */
  .topbar-notification-badge {
    top: 6px;
    right: 6px;
  }
}
