/* ==========================================================
   Demo — Public Navbar Page Styles (Complete)
   - Mobile hamburger dropdown & user menu MUST sit above
     sidebar and sidebar-tab via explicit z-index scale.
   ========================================================== */


/* ==========================================================
   Outer nav bar
   ========================================================== */
.nav {
  position: fixed;              /* stick to top */
  top: 0; left: 0; right: 0;
  z-index: var(--z-nav);        /* above sidebar base */
  background: var(--c-bg);
  height: var(--nav-height);
  border-bottom: none;
  box-shadow: none;
  overflow: visible;            /* allow dropdowns/panels to render */
  transition: border-bottom 0.25s ease, box-shadow 0.25s ease;
  z-index: var(--z-nav) !important;
}

/* Inner flex container */
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  padding: 0 clamp(10px, 3vw, var(--pad));
  overflow: visible;            /* keep menus from being clipped */
  white-space: nowrap;          /* prevent wrapping */
}

/* ---------- Brand ---------- */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--c-brand);
  transition: color 0.2s ease;
  white-space: nowrap;
}

.nav-logo {
  height: calc(var(--nav-height) - 22px);
  width: auto;
  object-fit: contain;
  transition: filter 0.25s, opacity 0.25s;
}

.nav-name {
  margin: 0;
  color: var(--c-brand);
  font-weight: 500;
  letter-spacing: 0.25px;
  line-height: 1;
  font-size: 24px; /* fixed size */
  transition: color 0.25s;
}

.nav-brand:hover .nav-name { color: var(--c-accent); }
.nav-brand:hover .nav-logo { filter: saturate(1.1); opacity: 0.95; }

/* ---------- Desktop Menu ---------- */
.nav-menu {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0; padding: 0;
  gap: clamp(14px, 2.5vw, 48px);
  white-space: nowrap;
}

.nav-link {
  position: relative;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.2rem;            /* fixed size */
  color: var(--c-brand);
  transition: color 0.2s, transform 0.2s;
  --underline-offset: 6px;
  line-height: 1;               /* avoid vertical growth */
}

.nav-link:hover { color: var(--c-accent); }

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: calc(var(--underline-offset) * -1);
  height: 2px;
  width: 0;
  background: var(--c-accent);
  transition: width 0.25s;
}
.nav-link:hover::after { width: 100%; }

/* ---------- Mobile Controls ---------- */
#nav-toggle { display: none; }  /* hidden checkbox for hamburger */

.nav-hamburger {
  display: none;
  inline-size: 42px;
  block-size: 42px;
  cursor: pointer;
  border: 1px solid #d0d7dd;
  border-radius: 8px;
  background: #fff;
  align-items: center;
  justify-content: center;
}

.nav-hamburger-icon,
.nav-hamburger-icon::before,
.nav-hamburger-icon::after {
  content: "";
  display: block;
  width: 20px;
  height: 2px;
  background: var(--c-brand);
  border-radius: 2px;
  position: relative;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-hamburger-icon::before { top: -6px; }
.nav-hamburger-icon::after  { top: 4px; }

/* ---------- Mobile Panel (fixed under bar) ---------- */
.nav-panel {
  position: fixed !important;
  z-index: var(--z-nav-menus) !important;
  left: 0; right: 0;
  top: var(--nav-height);
  display: none;
  background: #f8f9fa;
  border-left: 2px solid var(--c-brand);
  border-right: 2px solid var(--c-brand);
  border-bottom: 2px solid var(--c-brand);
  border-top: 1px solid #e0e7ec;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.18);
  max-height: calc(100vh - var(--nav-height));
  overflow: auto;
}

.nav-panel .container-fluid { padding: 10px var(--pad); }
.nav-panel ul { list-style: none; margin: 0; padding: 0; }
.nav-panel a {
  display: block;
  padding: clamp(6px, 1.5vw, 14px) 0 clamp(6px, 1.5vw, 14px) 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: clamp(1.5rem, 2vw, 2.5rem);
  color: var(--c-brand);
  border-radius: 10px;
  background: #f8f9fa;
  transition: background 0.2s, color 0.2s;
}
.nav-panel a:hover {
  background: var(--c-accent);
  color: #fff;
}

/* ---------- Mobile Behavior ---------- */
@media (max-width: 900px) {
  .nav-menu { display: none; }
  .nav-hamburger { display: inline-flex; }

  /* checkbox toggles the panel */
  #nav-toggle:checked ~ .nav-panel { display: block; }

  /* animate hamburger into an "X" */
  #nav-toggle:checked ~ .nav-inner .nav-hamburger-icon {
    transform: rotate(45deg);
  }
  #nav-toggle:checked ~ .nav-inner .nav-hamburger-icon::before {
    transform: rotate(-90deg) translateX(0);
    top: 0;
  }
  #nav-toggle:checked ~ .nav-inner .nav-hamburger-icon::after {
    opacity: 0;
  }
}

/* ---------- Accessibility ---------- */
.nav-hamburger:focus { outline: 2px solid var(--c-accent); }
a:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

/* ==========================================================
   Navbar Bottom Border Toggle (based on sidebar state)
   ========================================================== */
.nav { border-bottom: none; box-shadow: none; }
body.sidebar-open .nav,
body.has-sidebar-tab .nav {
  border-bottom: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}
body:not(.sidebar-open):not(.has-sidebar-tab) .nav {
  border-bottom: none;
  box-shadow: none;
}

/* ==========================================================
   Portal Extension — User Dropdown + Avatar
   ========================================================== */

/* Right-side user cluster (inside .nav-menu on desktop) */
.nav-menu .nav-user {
  position: relative;                 /* anchor for absolute dropdown */
  display: flex;
  align-items: center;
  z-index: auto;                      /* rely on dropdown's z-index */
}

/* Clickable user button */
.nav-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 6px 12px;
  border: 1px solid #d0d7dd;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: var(--c-brand);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.nav-user-btn:hover,
.nav-user-btn:focus-visible {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(10, 152, 185, 0.18);
  outline: none;
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background-color: #e5e7eb; /* neutral fallback */
  display: inline-block;
  margin-left: -5px;
}

/* Name next to avatar */
.nav-user-name {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

/* Caret icon */
.nav-caret {
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--c-brand);
  transform: translateY(1px);
}

/* Dropdown menu (desktop) */
.nav-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: var(--z-nav-menus) !important;
  font-size: 1.1rem;
  min-width: 200px;
  background: #f8f9fa;
  border-left: 2px solid var(--c-brand);
  border-right: 2px solid var(--c-brand);
  border-bottom: 2px solid var(--c-brand);
  border-top: 1px solid #e5e7eb;
  border-radius: 12px;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 8px;
  list-style: none;
  margin: 0;
  display: none;                      /* hidden by default */
}
.nav-user-menu.open { display: block; }

.nav-user-menu a {
  display: block;
  padding: 10px 12px 10px 22px;
  text-decoration: none;
  color: var(--c-brand);
  font-weight: 600;
  border-radius: 10px;
  background: #f8f9fa;
}
.nav-user-menu a:hover {
  background: var(--c-accent);
  color: #fff;
}

/* Mobile variant (shown inside the slide-down panel) */
.nav-user-mobile {
  display: none;
  padding: 8px 0;
  border-top: 1px solid #e0e7ec;
  margin-top: 8px;
}

.nav-user-mobile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}

@media (max-width: 900px) {
  .nav-user { display: none; }
  .nav-user-mobile { display: block; }
  .nav-user-menu {
    position: fixed !important;
    right: clamp(10px, 3vw, var(--pad)) !important;
    top: calc(var(--nav-height) + 8px) !important;
    z-index: var(--z-nav-menus) !important;
  }  
  .nav-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: var(--nav-height) !important;
    z-index: var(--z-nav-menus) !important;
  }  
}

/* ==========================================================
   Sidebar layering (kept below navbar menus on all screens)
   (If these classes live in sidebar.css, you can leave them
    there—duplicated here for certainty on layering.)
   ========================================================== */
.sidebar     { position: fixed; z-index: var(--z-sidebar); }
.sidebar-tab { position: fixed; z-index: var(--z-sidebar-tab); }
