/* =============================================================================
   NowInfinity Aurelia Header — component styles
   Mirrors the scoped styles from the Vue originals, de-scoped for global use.
   Import once from your app shell (app.html or equivalent).
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Layout wrapper
   --------------------------------------------------------------------------- */
.nav-header-wrapper {  
  top: 0;
  left: 0;
  right: 0;
  z-index: 5000;
}

/* Push page content below the fixed header — only when the header is present */
.wrapper.has-header {
  padding-top: 0px;
}

@media (max-width: 989px) {
  .wrapper.has-header {
    padding-top: 56px;
  }
}

.nav-header {
  display: block;
}

/* ---------------------------------------------------------------------------
   Logo
   --------------------------------------------------------------------------- */
.ni-logo {
  height: 30px;
  padding: 0 4px;
  display: block;
}

.ni-logo--lg { display: none; }

@media (min-width: 989px) {
  .ni-logo--sm { display: none; }
  .ni-logo--lg { display: block; }
}

/* ---------------------------------------------------------------------------
   App Switcher
   --------------------------------------------------------------------------- */
.app-switcher {
  display: flex;
  align-items: center;
}

.account-list-menu-item {
  width: 280px !important;
}

.app-switcher sl-app-switcher::part(base) {
  min-height: 425px;
}

.app-switcher sl-app-switcher::part(drawer) {
  border-radius: var(--hds-border-radius-none, 0);
  border: 1px solid var(--hds-color-border-subtler, #edeef0);
  background: var(--hds-color-bg, #fff);
  box-shadow:
    var(--hds-shadow-level2-offset-x, 0)
    var(--hds-shadow-level2-offset-y, 4px)
    var(--hds-shadow-level2-blur, 16px)
    var(--hds-shadow-level2-spread, 0)
    var(--hds-shadow-level2-opacity, rgba(41, 46, 55, 0.20));
  backdrop-filter: blur(2px);
}

/* ---------------------------------------------------------------------------
   App Switcher Trigger
   --------------------------------------------------------------------------- */
.trigger-icon {
  width: 25px;
  height: 25px;
  filter: brightness(0) invert(1);
  transform: translateY(-1px);
}

/* ---------------------------------------------------------------------------
   Account switcher dropdown (header-right slot)
   --------------------------------------------------------------------------- */
.header-menu {
  max-width: 282px;
  padding: var(--hds-space-1x);
}

.account-switcher {
  max-width: max(20vw, 200px);
}

@media (min-width: 600px) {
  .nav-header [slot='avatar'] {
    margin-left: -9px; /* Fine tuning for avatar alignment */
  }
}

/* ---------------------------------------------------------------------------
   Header search container
   --------------------------------------------------------------------------- */
.header-search-container {
  display: flex;
  justify-content: flex-end;
  z-index: 5000;
}

/* Search backdrop — sits above page content, below the hoisted dropdown panel */
.header-search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4000;
}

/* Mobile overlay */
.mobile-search-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 var(--hds-space-3x);
  background-color: var(--hds-app-header-color-bg-primary);
  z-index: 301;
}

/* Stretch the header-search custom element to fill the overlay */
.mobile-search-overlay header-search {
  flex: 1;
  width: 100%;
  display: block;
}

/* Mobile backdrop sits below nav-header-wrapper (z-index 1000) so clicks on the
   overlay itself are not swallowed, while clicks on page content below still close it */
.header-search-backdrop--mobile {
  z-index: 500;
}

/* ---------------------------------------------------------------------------
   Search bar — sizing by breakpoint
   --------------------------------------------------------------------------- */
.header-search-bar--mobile {
  flex: 1;
  width: 100%;
}

.header-search {
  padding-top: var(--hds-space-2x, 8px);
  padding-bottom: var(--hds-space-2x, 8px);
  transition: width 0.25s ease-out;
}

.header-search::part(base) {
  transition: width 0.25s ease-out;
}

/* M: 990–1439 px */
@media (min-width: 990px) and (max-width: 1439px) {
  .header-search { width: 240px; }
  .header-search--expanded { width: 540px; }
}

/* L: 1440–1989 px */
@media (min-width: 1440px) and (max-width: 1989px) {
  .header-search { width: 540px; }
  .header-search--expanded { width: min(860px, 60vw); }
}

/* GT_L: >= 1990 px */
@media (min-width: 1990px) {
  .header-search { width: 540px; }
  .header-search--expanded { width: clamp(860px, 45vw, 1400px); }
}

/* XS + S: full width */
@media (max-width: 989px) {
  .header-search,
  .header-search--expanded { width: 100%; }
}

/* Search panel — replaces sl-dropdown/sl-menu */
.header-search-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1001;
  background: var(--hds-color-bg, #fff);
  border: 1px solid var(--hds-color-border-subtler, #edeef0);
  border-radius: var(--hds-border-radius-medium, 4px);
  box-shadow:
    0 4px 16px 0 rgba(41, 46, 55, 0.20);
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: 70vh;
}

.header-search-bar {
  position: relative;
}

/* Filter buttons row */
.header-search__start {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--hds-space-2x);
  padding-left: var(--hds-space-2x);
  padding-right: var(--hds-space-2x);
}

/* Group label (replaces sl-menu-label) */
.header-search__group-label {
  padding: var(--hds-space-2x) var(--hds-space-3x) var(--hds-space-2x);
  font-size: var(--hds-font-size-large, 14px);
  font-weight: 500;
  color: var(--hds-color-text, #292e37);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

/* Result item (replaces sl-menu-item) */
.header-search__result-item {
  display: block;
  padding: var(--hds-space-3x) var(--hds-space-3x);
  border-bottom: 1px solid var(--hds-color-border-subtler, #edeef0);
  text-decoration: none;
  color: var(--hds-color-text, #111827);
  cursor: pointer;
}
.header-search__result-item:hover {
  background: var(--hds-color-bg-hover, #f3f4f6);
  text-decoration: none;
}

/* Results panel */
.header-search__results {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.header-search__loading {
  display: flex;
  justify-content: center;
  padding: var(--hds-space-4x);
  gap: var(--hds-space-2x);
}

.header-search__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--hds-space-2x);
  padding: var(--hds-space-6x) var(--hds-space-3x);
  color: var(--hds-color-alpha-neutral-50);
}

.header-search__see-type {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--hds-space-2x) var(--hds-space-3x);
  color: var(--hds-color-primary-600);
  font-size: var(--hds-font-size-14);
  cursor: pointer;
  outline: none;
}
.header-search__see-type:hover,
.header-search__see-type:focus-visible {
  background: var(--hds-color-bg-neutral-subtle, #f6f7f8);
  border-radius: var(--hds-border-radius-base, 4px);
}

.header-search__see-all {
  display: flex;
  align-items: center;
  gap: var(--hds-space-2x);
  padding: var(--hds-space-3x);
  color: var(--hds-color-primary-600);
  cursor: pointer;
  outline: none;
}
.header-search__see-all:hover,
.header-search__see-all:focus-visible {
  border: 1px solid var(--hds-color-border-focus, #007cbc);
  border-radius: var(--hds-border-radius-base, 4px);
}

.header-search__actions {
  padding: var(--hds-space-3x);
  border-top: 1px solid var(--hds-color-alpha-neutral-90);
  margin-top: var(--hds-space-2x);
}
.header-search__actions-label {
  margin: 0 0 var(--hds-space-2x);
  font-size: var(--hds-font-size-14);
}
.header-search__actions-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--hds-space-2x);
}

/* Default panel */
.header-search__default {
  display: flex;
  flex-direction: column;
  padding: var(--hds-space-3x);
  width: 100%;
}
.header-search__default-section {
  margin-bottom: var(--hds-space-2x);
}
.result-name {
  font-size: var(--hds-font-size-14);
}
.result-meta {
  font-size: var(--hds-font-size-12, 12px);
  color: var(--hds-color-fg-subtle);
  margin-top: var(--hds-space-1x);
}
.result-meta-row {
  display: flex;
  align-items: center;
  gap: var(--hds-space-2x, 8px);
}
.result-meta-row sl-divider {
  height: 14px;
  --spacing: 0;
  --width: 1px;
  --color: var(--hds-color-border-subtler, #dddfe3);
}

/* ---------------------------------------------------------------------------
   Desktop navigation (sub-header bar)
   --------------------------------------------------------------------------- */
.subnav-desktop {
  display: inline-flex;
  align-items: center;
  gap: var(--hds-space-2x, 8px);
}

[slot='subheader-left'] sl-toggle-button::part(base) {
  color: var(--hds-color-fg-inverse, #ffffff);
}
[slot='subheader-left'] sl-toggle-button:hover::part(base),
[slot='subheader-left'] sl-toggle-button[checked]::part(base) {
  color: var(--hds-color-fg-inverse, #ffffff);
  border-radius: var(--hds-border-radius-base, 4px);
  background: var(--hds-color-bg-opacity-press-onDark, rgba(255, 255, 255, 0.30));
}
[slot='subheader-left'] .subnav-btn {
  all: unset;
  cursor: pointer;
  color: var(--hds-color-fg-inverse, #ffffff);
  font: inherit;
  padding: var(--hds-space-1x, 4px) var(--hds-space-2x, 8px);
  border-radius: var(--hds-border-radius-base, 4px);
}
[slot='subheader-left'] .subnav-btn:hover,
[slot='subheader-left'] .subnav-btn--active {
  color: var(--hds-color-fg-inverse, #ffffff);
  background: var(--hds-color-bg-opacity-press-onDark, rgba(255, 255, 255, 0.30));
}

/* ---------------------------------------------------------------------------
   Dropdown menu panel
   --------------------------------------------------------------------------- */
.nav-menu {
  display: flex;
  padding: var(--hds-space-1x, 4px);
  align-items: flex-start;
  gap: var(--hds-space-5x, 20px);
  border-radius: var(--hds-button-border-radius, 4px);
  border: 1px solid var(--hds-color-border-subtlest, #f6f7f8);
  background: var(--hds-color-bg, #fff);
  box-shadow:
    var(--hds-shadow-level2-offset-x, 0)
    var(--hds-shadow-level2-offset-y, 4px)
    var(--hds-shadow-level2-blur, 16px)
    var(--hds-shadow-level2-spread, 0)
    var(--hds-shadow-level2-opacity, rgba(41, 46, 55, 0.20));
  backdrop-filter: blur(2px);
}
.nav-menu__col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--hds-space-1x, 4px);
  flex: 1 0 0;
  align-self: stretch;
}
.nav-menu__col > * {
  width: 100%;
}

/* ---------------------------------------------------------------------------
   Nav menu link
   --------------------------------------------------------------------------- */
.nav-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  color: var(--hds-color-fg);
  padding: var(--hds-space-2x);
  cursor: pointer;
  text-decoration: none;
}
.nav-link:hover {
  border-radius: var(--hds-border-radius-base);
  background-color: var(--hds-color-bg-selected);
  text-decoration: none;
}
.nav-link--active {
  border-radius: var(--hds-border-radius-base);
  background-color: var(--hds-color-bg-selected);
  font-weight: 600;
}
.nav-link--creation {
  justify-content: flex-start;
  color: #146ea3;
}
.nav-link--has-badge {
  position: relative;
  padding-right: 72px;
}
.creation-badge {
  font-weight: 700;
  flex-shrink: 0;
  margin-right: var(--hds-space-1x);
}
.nav-link-badge {
  position: absolute;
  top: 50%;
  right: 8px;
  display: inline-flex;
  align-items: center;
  transform: translateY(-50%);
  gap: 4px;
  flex-shrink: 0;
  padding: 2px 8px;
  border: 1px solid #d71920;
  border-radius: 999px;
  background: #fff1f1;
  color: #30343b;
  font-size: 12px;
  font-weight: 600;
  line-height: 12px;
  white-space: nowrap;
}
.nav-link-badge__icon::before {
  content: "\e937";
  font-family: "nowinfinity";
  color: #d71920;
  font-size: 12px;
}

/* ---------------------------------------------------------------------------
   Current account chip
   --------------------------------------------------------------------------- */
.current-account-container {
  display: flex;
  align-items: center;
  gap: var(--hds-space-2x, 8px);
}

.current-account-container .account-logo-img {
    max-width: 30px;
}
.current-account-container .account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-switcher-icon {
  justify-self: flex-end;
  margin-left: -3px;
  width: 12px;
  height: 12px;
}

/* ---------------------------------------------------------------------------
   Account list
   --------------------------------------------------------------------------- */
.account-list-menu {
  width: 100%;
  max-width: 288px;
}
.account-list-menu::part(base) {
  border: none;
}

.filter-input {
  width: 100%;
}
.accounts-label {
  color: var(--hds-color-fg);
  font-weight: var(--hds-font-application-weight-strong, 500);
  padding: var(--hds-space-1x);
}
.current-account {
  background-color: var(--hds-color-bg-selected);
}
.account-logo-container {
  width: 30px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: var(--hds-space-1x, 8px);
  flex-shrink: 0;
}
.account-logo {
  display: block;
  max-width: 30px;
  max-height: 24px;
}

/* ---------------------------------------------------------------------------
   Avatar button
   --------------------------------------------------------------------------- */
.avatar-button::part(trigger) {
  border: 5px solid transparent;
}
.nav-header .avatar-button::part(trigger) {
  cursor: pointer;
}
.account-drawer .avatar-button::part(trigger) {
  cursor: default;
}
.avatar-button.onDark::part(trigger):hover,
.avatar-button.onDark::part(trigger):focus {
  border: 5px solid #ffffff33;
}
.avatar-button.onLight::part(trigger):hover,
.avatar-button.onLight::part(trigger):focus {
  border: 5px solid #00000022;
}

/* ---------------------------------------------------------------------------
   Account drawer
   --------------------------------------------------------------------------- */
sl-drawer {
  --header-spacing: var(--hds-space-4x);
  --body-spacing: var(--hds-space-3x);
}

sl-drawer::part(body) {
  padding: 0;
}
.account-switcher-drawer::part(close-button) {
  display: none;
}
.back-button::part(base) {
  border: none !important;
}
.account-drawer {
  position: relative;
  width: 100%;
  overflow: hidden;
  color: var(--hds-color-fg, #292e37);
}
.account-block {
  display: flex;
  align-items: center;
  gap: var(--hds-space-2x, 8px);
  width: 100%;
  padding: var(--hds-space-1x, 4px);
  border-radius: var(--hds-border-radius-base, 4px);
  background: var(--hds-color-neutral-50, #f6f7f8);
}
.account-block .details {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  height: 35px;
  width: 100%;
  overflow: hidden;
}
.account-block .email {
  width: 100%;
  font-size: var(--hds-font-size-body-sm, 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-drawer-menu {
  width: 100%;
  max-width: 100%;
  margin-top: var(--hds-space-1x, 4px);
}
.account-drawer-menu::part(base),
.mobile-header-menu::part(base) {
  width: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* ---------------------------------------------------------------------------
   Mobile navigation drawer
   --------------------------------------------------------------------------- */
.mobile-menu-icon {
  width: 20px;
  height: 20px;
}
.drawer-logo {
  height: 32px;
}
.mobile-header-menu {
  display: flex;
  flex-direction: column;
  gap: var(--hds-space-1x);
}
.parent-button {
  width: 100%;
}
.parent-button::part(base) {
  display: flex;
  width: 100%;
  justify-content: space-between;
  font-size: 13px;
  font-family: var(--hds-font-application-fontFamily);
}
.parent-button::part(base):hover {
  background-color: var(--hds-color-bg-selected);
}
.parent-button--active::part(base) {
  background-color: var(--hds-color-bg-selected);
  font-weight: 600;
}
.parent-button::part(prefix) {
  display: none;
}
.submenu-label {
  color: #000;
  padding: var(--hds-space-2x);
  font-weight: var(--hds-font-body-base-strong-font-weight, 500);
}
.submenu-drawer::part(close-button) {
  display: none;
}
.bt-app-switcher {
  width: 100%;
}
.bt-app-switcher::part(base) {
  justify-content: flex-start;
}
.bt-app-switcher::part(base):hover {
  background-color: var(--hds-color-bg-neutral-subtle-hover, #edeef0);
}
.account-switcher-icon {
  width: 18px;
  height: 18px;
  margin-right: var(--hds-space-2x, 8px);
}

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
