/* ============================================================
   Perfect HOA — Global Shell Styles
   Top bar (navy) + Primary subnav (white) + Page body background.
   Scoped under .topbar-wrap to win over legacy theme CSS
   without !important sprawl.
   ============================================================ */

/* ============================================================
   BODY / PAGE BACKGROUND
   ============================================================ */

body {
  font-family: var(--phoa-font);
  -webkit-font-smoothing: antialiased;
  background-color: var(--phoa-bg);
}

/* ============================================================
   TOP BAR — dark navy strip
   ============================================================ */

.topbar-wrap .topbar,
.topbar-wrap .topbar.is-sticky {
  background: var(--phoa-topbar-bg);
  border-bottom: none;
  box-shadow: none;
  padding: 0;
  /* position + z-index kept from legacy; height controlled via container */
}

.topbar-wrap .topbar .container,
.topbar-wrap .topbar.is-sticky .container {
  height: var(--phoa-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  width: 100%;
  padding-left: clamp(16px, 3vw, 26px);
  padding-right: clamp(16px, 3vw, 26px);
}

/* Override Bootstrap container max-width inside topbar */
@media (min-width: 1400px) {
  .topbar-wrap .topbar .container {
    max-width: 1440px;
  }
}

/* --- Logo --- */
.topbar-wrap .topbar-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.topbar-wrap .topbar-logo img {
  height: 30px;
  width: auto;
  display: block;
  filter: brightness(0) invert(1);
}

/* --- Right-side nav list --- */
.topbar-wrap .topbar .topbar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.topbar-wrap .topbar .topbar-nav-item {
  position: relative;
  display: flex;
  align-items: center;
}

/* --- Hamburger toggle (mobile only) --- */
.topbar-wrap .toggle-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--phoa-r-icon-btn);
  background: rgba(255, 255, 255, 0.10);
  cursor: pointer;
  transition: background 0.12s ease;
  border: none;
}

.topbar-wrap .toggle-nav:hover {
  background: rgba(255, 255, 255, 0.18);
}

.topbar-wrap .toggle-nav svg {
  color: rgba(255, 255, 255, 0.88);
}

/* --- Community switcher — custom pill trigger + panel --- */
.topbar-wrap .community-switcher-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  color: #fff;
  font-family: var(--phoa-font);
  font-size: 14px;
  font-weight: var(--phoa-fw-semibold);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.topbar-wrap .community-switcher-trigger:hover,
.topbar-wrap .community-switcher-trigger:focus {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.26);
  color: #fff;
  text-decoration: none;
}

.topbar-wrap .community-switcher-caret {
  display: inline-flex;
  opacity: 0.85;
  flex-shrink: 0;
}

.topbar-wrap .community-switcher-menu {
  min-width: 308px;
  padding: 0;
  overflow: hidden;
}

.topbar-wrap .community-switcher-eyebrow {
  padding: 13px 16px 9px;
  font-size: 11px;
  font-weight: var(--phoa-fw-extrabold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--phoa-muted-4);
}

.topbar-wrap .community-switcher-list {
  padding: 0 8px 8px;
  max-height: 320px;
  overflow-y: auto;
}

.topbar-wrap .community-switcher-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s ease;
}

.topbar-wrap .community-switcher-row:hover {
  background: var(--phoa-subtle-4);
  text-decoration: none;
  color: inherit;
}

.topbar-wrap .community-switcher-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--phoa-primary-tint-3);
  color: var(--phoa-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: var(--phoa-fw-extrabold);
  flex-shrink: 0;
}

.topbar-wrap .community-switcher-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: var(--phoa-fw-bold);
  color: var(--phoa-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-wrap .community-switcher-check {
  display: inline-flex;
  color: var(--phoa-primary);
  flex-shrink: 0;
}

.topbar-wrap .community-switcher-add {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-top: 1px solid var(--phoa-subtle-5);
  color: var(--phoa-primary);
  font-size: 14px;
  font-weight: var(--phoa-fw-bold);
  text-decoration: none;
  transition: background 0.1s ease;
}

.topbar-wrap .community-switcher-add:hover {
  background: var(--phoa-subtle-4);
  color: var(--phoa-primary);
  text-decoration: none;
}

.topbar-wrap .community-switcher-add-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1.5px dashed var(--phoa-border-input-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* --- Notification bell button --- */
.topbar-wrap .notification-bell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--phoa-r-icon-btn);
  background: rgba(255, 255, 255, 0.10);
  box-shadow: none;
  transform: none;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  transition: background 0.12s ease;
  position: relative;
}

.topbar-wrap .notification-bell:hover,
.topbar-wrap .notification-bell:focus {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
  transform: none;
  color: #fff;
}

.topbar-wrap .notification-bell em,
.topbar-wrap .notification-bell i {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1;
}

/* Notification unread dot */
.topbar-wrap .notification-badge {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FF5C7A;
  border: 1.5px solid var(--phoa-topbar-bg);
  pointer-events: none;
}

/* --- User avatar button --- */
.topbar-wrap .user-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--phoa-r-icon-btn);
  background: rgba(255, 255, 255, 0.10);
  box-shadow: none;
  transform: none;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  transition: background 0.12s ease;
}

.topbar-wrap .user-thumb:hover,
.topbar-wrap .user-thumb:focus {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
  transform: none;
  color: #fff;
}

.topbar-wrap .user-thumb em,
.topbar-wrap .user-thumb i {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1;
}

/* ============================================================
   DROPDOWN PANELS — notifications + user menu
   Positioned by legacy dropdown controller, restyled here.
   ============================================================ */

.topbar-wrap .dropdown-content {
  font-family: var(--phoa-font);
  border: 1px solid var(--phoa-border);
  border-radius: 14px;
  box-shadow: var(--phoa-shadow-panel);
  background: var(--phoa-card);
  overflow: hidden;
}

/* Notification dropdown panel sizing is kept inline per Stimulus controller logic */

/* --- User dropdown --- */
.topbar-wrap .user-dropdown {
  overflow: hidden;
}

.topbar-wrap .user-status {
  background: var(--phoa-topbar-bg);
  padding: 16px 18px;
}

.topbar-wrap .user-status-title {
  font-size: 11px;
  font-weight: var(--phoa-fw-extrabold);
  letter-spacing: 0.06em;
  color: #8FA0D6;
  text-transform: uppercase;
  margin: 0 0 6px;
  line-height: 1.2;
}

/* Balance line inherits from legacy .user-status-balance; override here */
.topbar-wrap .user-status .user-status-balance {
  font-size: 14.5px;
  font-weight: var(--phoa-fw-bold);
  color: #fff;
  margin: 0;
}

/* --- User menu links --- */
.topbar-wrap .user-links {
  list-style: none;
  margin: 0;
  padding: 8px;
  background: transparent;
}

.topbar-wrap .user-links.bg-light {
  background: var(--phoa-subtle-1);
  border-top: 1px solid var(--phoa-border-divider);
}

.topbar-wrap .user-links li {
  margin: 0;
  padding: 0;
}

.topbar-wrap .user-links li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: var(--phoa-fw-semibold);
  color: var(--phoa-heading);
  text-decoration: none;
  transition: background 0.1s ease;
}

.topbar-wrap .user-links li a:hover {
  background: var(--phoa-subtle-4);
  color: var(--phoa-heading);
  text-decoration: none;
}

.topbar-wrap .user-links li a i,
.topbar-wrap .user-links li a em,
.topbar-wrap .user-links li a svg {
  color: var(--phoa-primary);
  font-size: 15px;
  width: 17px;
  flex-shrink: 0;
  line-height: 1;
}

.topbar-wrap .user-links.bg-light li a {
  color: var(--phoa-muted-1);
}

.topbar-wrap .user-links.bg-light li a i,
.topbar-wrap .user-links.bg-light li a em,
.topbar-wrap .user-links.bg-light li a svg {
  color: var(--phoa-muted-1);
}

.topbar-wrap .user-links.bg-light li a:hover {
  background: var(--phoa-subtle-4);
  color: var(--phoa-secondary);
}

/* ============================================================
   PRIMARY NAV — white subnav bar
   ============================================================ */

.topbar-wrap .navbar.navbar-mobile {
  background: var(--phoa-card);
  border-bottom: 1px solid var(--phoa-border);
  box-shadow: none;
  margin: 0;
  padding: 0;
  /* z-index kept via inline style on element (data-mobile-nav-target) */
}

.topbar-wrap .navbar.navbar-mobile .container {
  max-width: 1440px;
  width: 100%;
  padding-left: clamp(16px, 3vw, 26px);
  padding-right: clamp(16px, 3vw, 26px);
}

/* Desktop: stick subnav just below the topbar */
@media (min-width: 992px) {
  .topbar-wrap .navbar.navbar-mobile {
    position: sticky;
    top: var(--phoa-topbar-h);
    z-index: 35;
  }

  .topbar-wrap .navbar-mobile .navbar-innr {
    height: var(--phoa-subnav-h);
    display: flex;
    align-items: stretch;
  }

  .topbar-wrap .navbar-menu {
    display: flex;
    align-items: stretch;
    flex-direction: row;
    list-style: none;
    margin: 0 0 0 -8px; /* optical left-edge alignment, matches design file */
    padding: 0;
    gap: 2px;
  }

  .topbar-wrap .navbar-menu > li {
    position: relative;
    display: flex;
    align-items: stretch;
  }

  /* Invisible bridge over the gap between the trigger and its dropdown
     panel (which sits 8px below via margin-top) — without this, moving
     the mouse straight down from the trigger to the panel crosses a
     dead zone that isn't part of either element's hover box, so the
     :hover chain breaks and the panel closes before the pointer arrives. */
  .topbar-wrap .navbar-menu > li.has-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 8px;
  }

  .topbar-wrap .navbar-menu > li > a,
  .topbar-wrap .navbar-menu > li > a.drop-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    font-size: 13.5px;
    font-weight: var(--phoa-fw-semibold);
    color: var(--phoa-secondary);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    /* Bottom border indicator for active state */
    border-bottom: 2px solid transparent;
    margin-bottom: -1px; /* sit flush on the subnav's bottom border */
    transition: color 0.1s ease;
    background: none;
  }

  .topbar-wrap .navbar-menu > li > a:hover,
  .topbar-wrap .navbar-menu > li > a.drop-toggle:hover {
    color: var(--phoa-heading);
    text-decoration: none;
  }

  /* Active: primary color + bottom border indicator */
  .topbar-wrap .navbar-menu > li.active > a,
  .topbar-wrap .navbar-menu > li.active > a.drop-toggle {
    color: var(--phoa-primary);
    border-bottom-color: var(--phoa-primary);
    font-weight: var(--phoa-fw-bold);
  }

  /* Caret rotation on hover */
  .topbar-wrap .navbar-menu > li.has-dropdown:hover > a .nav-caret,
  .topbar-wrap .navbar-menu > li.active > a .nav-caret {
    transform: rotate(180deg);
    color: var(--phoa-primary);
    opacity: 0.9;
  }

  /* Desktop dropdown panel: CSS hover, no JS needed */
  .topbar-wrap .navbar-menu > li.has-dropdown > .navbar-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px; /* gap between trigger and panel */
    list-style: none;
    padding: 8px;
    min-width: 210px;
    background: var(--phoa-card);
    border: 1px solid var(--phoa-border);
    border-radius: 12px;
    box-shadow: var(--phoa-shadow-dropdown-heavy);
    z-index: 60;
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
    pointer-events: none;
    /* Override any legacy display:none */
    display: block;
    max-height: none;
  }

  .topbar-wrap .navbar-menu > li.has-dropdown:hover > .navbar-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }

  /* Dropdown list items */
  .topbar-wrap .navbar-menu > li.has-dropdown > .navbar-dropdown > li {
    display: block;
    margin: 0;
    padding: 0;
  }

  .topbar-wrap .navbar-dropdown > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: var(--phoa-fw-semibold);
    color: var(--phoa-secondary);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.1s ease, color 0.1s ease;
  }

  .topbar-wrap .navbar-dropdown > li > a:hover {
    background: var(--phoa-subtle-4);
    color: var(--phoa-heading);
    text-decoration: none;
  }
}

/* ============================================================
   ICON + CARET — shared between desktop and mobile
   ============================================================ */

.topbar-wrap .navbar-menu .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.topbar-wrap .navbar-menu > li.active > a .nav-icon,
.topbar-wrap .navbar-menu > li > a:hover .nav-icon {
  opacity: 1;
}

.topbar-wrap .navbar-menu .nav-caret {
  display: inline-flex;
  align-items: center;
  opacity: 0.6;
  margin-left: 1px;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease, color 0.15s ease;
}

/* Suppress the legacy theme's font-icon caret (.has-dropdown > a:after) in the
   primary nav only — we render our own SVG caret above. Left untouched
   elsewhere in the app (e.g. other dropdown lists still using .has-dropdown). */
.topbar-wrap .navbar-menu > li.has-dropdown > a:after {
  display: none;
}

/* ============================================================
   NAV BADGES — inline in dropdown items
   ============================================================ */

.topbar-wrap .navbar-dropdown .badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--phoa-r-badge);
  font-size: 11px;
  font-weight: var(--phoa-fw-extrabold);
  line-height: 1;
  flex-shrink: 0;
  border: none;
}

.topbar-wrap .navbar-dropdown .badge-warning {
  background: var(--phoa-badge-amber-bg);
  color: var(--phoa-badge-amber-text);
}

.topbar-wrap .navbar-dropdown .badge-secondary {
  background: var(--phoa-badge-navy-bg);
  color: var(--phoa-badge-navy-text);
}

.topbar-wrap .navbar-dropdown .badge-info {
  background: var(--phoa-badge-blue-bg);
  color: var(--phoa-badge-blue-text);
}

.topbar-wrap .navbar-dropdown .badge-danger {
  background: var(--phoa-badge-danger-bg);
  color: var(--phoa-badge-danger-text);
}

/* ============================================================
   MOBILE NAV — accordion drawer
   Overrides and complements the inline <style> in header.html.twig
   which handles the .open toggle class from mobile-nav controller.
   ============================================================ */

@media (max-width: 991px) {
  .topbar-wrap .navbar.navbar-mobile {
    /* Not sticky on mobile — it's a collapsible drawer, hidden until
       mobile-nav-controller#toggle adds .active to this element
       (the legacy theme's .navbar-mobile{display:block} rule was
       cascading over .navbar{display:none} and always showing it). */
    position: static;
    display: none;
  }

  .topbar-wrap .navbar.navbar-mobile.active {
    display: block;
  }

  .topbar-wrap .navbar-mobile .navbar-innr {
    height: auto;
  }

  .topbar-wrap .navbar-menu {
    flex-direction: column;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 8px 0;
    gap: 0;
  }

  .topbar-wrap .navbar-menu > li {
    display: block;
    position: static;
  }

  .topbar-wrap .navbar-menu > li > a,
  .topbar-wrap .navbar-menu > li > a.drop-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: var(--phoa-fw-semibold);
    color: var(--phoa-secondary);
    text-decoration: none;
    border-left: 3px solid transparent;
    border-bottom: none;
    transition: background 0.1s ease, color 0.1s ease;
    margin-bottom: 0;
    background: none;
    cursor: pointer;
  }

  .topbar-wrap .navbar-menu > li > a:hover {
    background: var(--phoa-subtle-4);
    color: var(--phoa-heading);
  }

  .topbar-wrap .navbar-menu > li.active > a,
  .topbar-wrap .navbar-menu > li.active > a.drop-toggle {
    background: var(--phoa-primary-tint);
    border-left-color: var(--phoa-primary);
    border-bottom-color: transparent;
    color: var(--phoa-primary);
    font-weight: var(--phoa-fw-bold);
  }

  /* Mobile caret: open state flips via .has-dropdown.open > a:after
     (handled by inline <style> in header.html.twig) */
  .topbar-wrap .navbar-menu > li.has-dropdown.open > a .nav-caret {
    transform: rotate(180deg);
    opacity: 0.8;
  }

  /* Mobile dropdown items — indented sub-list */
  .topbar-wrap .navbar-menu > li.has-dropdown > .navbar-dropdown {
    position: static;
    background: var(--phoa-subtle-1);
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 4px 0;
    min-width: unset;
    /* The open/close is controlled via max-height toggle in inline <style> */
  }

  .topbar-wrap .navbar-dropdown > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px 10px 28px;
    font-size: 13.5px;
    font-weight: var(--phoa-fw-semibold);
    color: var(--phoa-secondary);
    text-decoration: none;
    transition: background 0.1s ease;
  }

  .topbar-wrap .navbar-dropdown > li > a:hover {
    background: var(--phoa-subtle-4);
    text-decoration: none;
  }

  /* Mobile notification/user dropdown positioning fixes kept from inline style */
  .topbar-wrap .topbar-nav-item .dropdown-content-right[data-notifications-target="dropdown"] {
    right: -20px;
  }

  .topbar-wrap .topbar-nav-item .user-dropdown {
    left: auto;
    right: 0;
    transform: none;
  }
}

/* ============================================================
   STICKY TOPBAR: ensures topbar is fixed to viewport top
   Legacy .is-sticky class may already do this; we reinforce.
   ============================================================ */

.topbar-wrap .topbar.is-sticky {
  position: sticky;
  top: 0;
  z-index: 40;
}

/* ============================================================
   PAGE BODY / CARD TREATMENT
   Body bg is on <body> above. Cards use the token border-radius.
   ============================================================ */

/* Ensure the impersonation banner and flash messages read
   correctly against the new page background */
.topbar-wrap + .alert {
  border-radius: 0;
}

/* ============================================================
   PAGE CONTAINER WIDTH
   Match Bootstrap's .container to the same fluid max-width +
   padding used by the topbar/subnav containers above, so page
   content lines up with the header instead of Bootstrap's
   narrower stepped breakpoints (540/720/960/1140/1320px).
   ============================================================ */

.container {
  max-width: 1440px;
  padding-left: clamp(16px, 3vw, 26px);
  padding-right: clamp(16px, 3vw, 26px);
}
