/* =====================================================
   HEADER (logged-in B2B panel)
   Markup: app/Views/template/home-header.php
   Top bar (agency, wallet, user) + main bar (logo, menu)
   + mobile drawer. Colours come from theme.css tokens.
   Previous version: header_bkp_22102026.css
===================================================== */
.header {
  position: relative;
  z-index: 1030;
}

/* one container for every header row, so edges line up */
.hdr-container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

/* -----------------------------------------------------
   TOP BAR
----------------------------------------------------- */
.hdr-top {
  color: rgba(255, 255, 255, 0.88);
  background: linear-gradient(100deg, var(--primary-deep) 0%, var(--primary-dark) 55%, var(--primary) 130%);
}

.hdr-top .hdr-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
}

.hdr-top__greet {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
}

.hdr-top__greet > i {
  font-size: 13px;
  opacity: 0.75;
}

.hdr-top__greet strong {
  font-weight: 700;
  color: #fff;
}

.hdr-top__id {
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.hdr-top__links {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hdr-wallet,
.hdr-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.hdr-wallet {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.hdr-wallet__label {
  font-weight: 500;
  opacity: 0.8;
}

.hdr-wallet:hover,
.hdr-user:hover,
.hdr-wallet[aria-expanded="true"],
.hdr-user[aria-expanded="true"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

.hdr-user {
  padding-left: 4px;
}

.hdr-avatar {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--on-secondary);
  background: var(--secondary);
  border-radius: 50%;
}

.hdr-caret {
  font-size: 9px;
  opacity: 0.75;
  transition: transform 0.2s ease;
}

[aria-expanded="true"] > .hdr-caret {
  transform: rotate(180deg);
}

/* top-bar dropdowns (Bootstrap click dropdowns) */
.hdr-dropdown.dropdown-menu {
  min-width: 240px;
  margin-top: 8px !important;
  padding: 8px;
  font-size: 13.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 48px -20px rgba(15, 27, 51, 0.4);
}

.hdr-dropdown .dropdown-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 800;
  color: var(--heading);
  background: var(--primary-soft);
  border-radius: 10px;
}

.hdr-dropdown .dropdown-header span {
  font-weight: 600;
  color: var(--text);
}

.hdr-dropdown .dropdown-divider {
  margin: 6px 0;
  border-color: var(--border);
}

.hdr-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  font-weight: 500;
  color: var(--heading);
  border-radius: 8px;
}

.hdr-dropdown .dropdown-item i {
  width: 18px;
  color: var(--text-muted);
}

.hdr-dropdown .dropdown-item:hover,
.hdr-dropdown .dropdown-item:focus {
  color: var(--primary);
  background: var(--primary-soft);
}

.hdr-dropdown .dropdown-item:hover i {
  color: var(--primary);
}

.hdr-dropdown .dropdown-item.text-danger,
.hdr-dropdown .dropdown-item.text-danger i {
  color: var(--danger) !important;
}

.hdr-dropdown .dropdown-item.text-danger:hover {
  background: color-mix(in srgb, var(--danger), #fff 92%);
}

/* -----------------------------------------------------
   MAIN BAR
----------------------------------------------------- */
.hdr-main {
  position: relative;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px -20px rgba(15, 27, 51, 0.45);
}

.hdr-main__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 72px;
}

.hdr-logo {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.hdr-logo img {
  display: block;
  width: auto;
  max-width: 180px;
  max-height: 44px;
}

.hdr-main__end {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.hdr-agent-logo {
  display: inline-flex;
  align-items: center;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.hdr-agent-logo img {
  display: block;
  width: auto;
  max-width: 150px;
  max-height: 38px;
}

/* --- desktop menu --- */
.main-menu {
  flex: 1 1 auto;
  min-width: 0;
}

.main-menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.main-menu > ul {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.main-menu > ul > li {
  position: relative;
}

.main-menu > ul > li > a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 72px;
  padding: 0 12px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  color: var(--heading);
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.2s ease;
}

/* chevron drawn with borders: no icon-font dependency */
.main-menu > ul > li.menu-item-has-children > a::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  opacity: 0.55;
  transform: rotate(45deg);
  transition: transform 0.2s ease, margin 0.2s ease;
}

.main-menu > ul > li:hover > a::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}

/* active / hover underline */
.main-menu > ul > li > a::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  height: 3px;
  background: var(--secondary);
  border-radius: 3px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.main-menu > ul > li:hover > a,
.main-menu > ul > li > a.active {
  color: var(--primary);
}

.main-menu > ul > li:hover > a::before,
.main-menu > ul > li > a.active::before {
  transform: scaleX(1);
}

/* dropdown */
.main-menu .sub-menu {
  position: absolute;
  top: calc(100% - 10px);
  left: 0;
  z-index: 1000;
  min-width: 230px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 48px -20px rgba(15, 27, 51, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.main-menu li:hover > .sub-menu,
.main-menu li:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.main-menu > ul > li:nth-last-child(-n + 2) > .sub-menu {
  left: auto;
  right: 0;
}

.main-menu .sub-menu li a {
  display: block;
  padding: 9px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--heading);
  white-space: nowrap;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.main-menu .sub-menu li a:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

/* call-to-action in the public header (login / register pages) */
.hdr-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--on-secondary);
  text-decoration: none;
  background: var(--secondary);
  border-radius: 12px;
  box-shadow: 0 10px 20px -12px var(--secondary);
  transition: background 0.2s ease, transform 0.2s ease;
}

.hdr-cta:hover {
  color: var(--on-secondary);
  background: var(--secondary-dark);
  transform: translateY(-1px);
}

.hdr-top a {
  color: inherit;
  text-decoration: none;
}

/* burger */
.hdr-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 18px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 0;
  border-radius: 12px;
  transition: background 0.2s ease, color 0.2s ease;
}

.hdr-burger:hover {
  color: var(--on-primary);
  background: var(--primary);
}

/* -----------------------------------------------------
   MOBILE DRAWER (.open toggled by the script in home-header.php)
----------------------------------------------------- */
.th-menu-wrapper {
  position: fixed;
  inset: 0;
  z-index: 1060;
  background: rgba(6, 14, 30, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.th-menu-wrapper.open {
  opacity: 1;
  visibility: visible;
}

.th-menu-area {
  position: relative;
  width: 320px;
  max-width: 86vw;
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: 20px 0 40px -20px rgba(6, 14, 30, 0.5);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overscroll-behavior: contain;
}

.th-menu-wrapper.open .th-menu-area {
  transform: translateX(0);
}

.hdr-drawer__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hdr-drawer__head .hdr-logo img {
  max-width: 150px;
  max-height: 36px;
}

.hdr-drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 18px;
  color: var(--heading);
  background: var(--bg);
  border: 0;
  border-radius: 10px;
}

.hdr-drawer__close:hover {
  color: var(--on-primary);
  background: var(--primary);
}

.hdr-drawer__user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 16px 8px;
  padding: 12px 14px;
  background: var(--primary-soft);
  border-radius: 14px;
}

.hdr-drawer__user .hdr-avatar {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

.hdr-drawer__user strong {
  display: block;
  font-size: 14px;
  color: var(--heading);
}

.hdr-drawer__user small {
  font-size: 12.5px;
  color: var(--text-muted);
}

.th-mobile-menu {
  padding: 4px 0 24px;
}

.th-mobile-menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.th-mobile-menu > ul > li {
  border-bottom: 1px solid var(--border);
}

.th-mobile-menu > ul > li > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--heading);
  text-decoration: none;
}

.th-mobile-menu > ul > li > a.active,
.th-mobile-menu .th-active > a {
  color: var(--primary);
}

/* expand chevron */
.th-mobile-menu .th-mean-expand {
  position: relative;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-left: auto;
  border-radius: 6px;
}

.th-mobile-menu .th-mean-expand::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 8px;
  width: 6px;
  height: 6px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  opacity: 0.6;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.th-mobile-menu .th-active > a .th-mean-expand::before {
  top: 10px;
  transform: rotate(-135deg);
}

.th-mobile-menu .sub-menu {
  padding: 4px 0 10px;
  background: var(--bg);
}

.th-mobile-menu .sub-menu li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px 9px 34px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.th-mobile-menu .sub-menu li a::before {
  content: "";
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  background: var(--primary-soft-2);
  border-radius: 50%;
}

.th-mobile-menu .sub-menu li a:hover {
  color: var(--primary);
}

.th-mobile-menu .sub-menu li a:hover::before {
  background: var(--primary);
}

/* -----------------------------------------------------
   RESPONSIVE
----------------------------------------------------- */
@media (max-width: 1399.98px) {
  .main-menu > ul > li > a {
    padding: 0 9px;
    font-size: 14px;
  }

  .main-menu > ul > li > a::before {
    left: 9px;
    right: 9px;
  }
}

/* below 1200px the 10-item menu no longer fits: switch to the drawer */
@media (max-width: 1199.98px) {
  .main-menu {
    display: none;
  }

  .hdr-burger {
    display: inline-flex;
  }

  .hdr-main__inner {
    min-height: 64px;
  }
}

@media (max-width: 767.98px) {
  .hdr-container {
    padding: 0 16px;
  }

  .hdr-top__greet span:not(.hdr-top__id),
  .hdr-top__greet > i,
  .hdr-wallet__label,
  .hdr-user__name {
    display: none;
  }

  .hdr-agent-logo {
    display: none;
  }

  .hdr-logo img {
    max-width: 150px;
    max-height: 38px;
  }
}
