/* =========================================================
   HEADER REDESIGN (mobile-first)
   Add at the END of your theme CSS (e.g. style.css / custom css).
   No template changes required.
   ========================================================= */

:root {
  --hdr-height: 56px;
  --hdr-icon: 40px;          /* tap target (min 40px for mobile) */
  --hdr-gap: 6px;
  --hdr-pad-x: 12px;
  --hdr-logo-h: 30px;        /* logo height on mobile  */
  --hdr-bg: #ffffff;
  --hdr-border: rgba(0, 0, 0, .08);
  --hdr-icon-bg: #f0f2f5;
  --hdr-icon-bg-hover: #e4e6eb;
}
[data-bs-theme="dark"], .night-mode {
  --hdr-bg: #242526;
  --hdr-border: rgba(255, 255, 255, .08);
  --hdr-icon-bg: #3a3b3c;
  --hdr-icon-bg-hover: #4e4f50;
}

/* ---------- Bar ---------- */
.main-header {
  height: var(--hdr-height);
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--hdr-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  display: flex;
  align-items: center;
  padding: 0 !important;
}
.main-header > .container,
.main-header > .container-fluid {
  height: 100%;
  padding-left: var(--hdr-pad-x);
  padding-right: var(--hdr-pad-x);
}

/* Outer row -> single flex line: [logo side] ........ [actions side] */
.main-header > .container > .row,
.main-header > .container-fluid > .row {
  height: 100%;
  margin: 0;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
}
.main-header > .container > .row > [class*="col-"],
.main-header > .container-fluid > .row > [class*="col-"] {
  padding: 0;
  height: 100%;
  display: flex;
  align-items: center;
}
/* left block hugs content, right block takes the rest */
.main-header > .container > .row > [class*="col-"]:first-child,
.main-header > .container-fluid > .row > [class*="col-"]:first-child {
  flex: 0 0 auto;
  width: auto;
  max-width: none;
}
.main-header > .container > .row > [class*="col-"]:last-child,
.main-header > .container-fluid > .row > [class*="col-"]:last-child {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
}

/* Inner row (search + navbar) */
.main-header [class*="col-"] > .row {
  width: 100%;
  margin: 0;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.main-header [class*="col-"] > .row > [class*="col-"] {
  padding: 0;
  height: 100%;
  display: flex;
  align-items: center;
}

/* ---------- Logo + menu button ---------- */
.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 !important;
  margin: 0;
}
.logo-wrapper .menu-icon {
  width: var(--hdr-icon);
  height: var(--hdr-icon);
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent;
}
.logo-wrapper .menu-icon:active { background: var(--hdr-icon-bg); }

.logo-wrapper .logo {
  display: flex;
  align-items: center;
  height: 100%;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1;
  font-weight: 700;
  font-size: 20px;
  white-space: nowrap;
}
.logo-wrapper .logo img {
  height: var(--hdr-logo-h);
  width: auto;
  max-width: 140px;
  object-fit: contain;      /* keeps logo proportions, no stretch */
  display: block;
  margin: 0;
}
.header-home-btn { display: none; }   /* too crowded on mobile */

/* ---------- Search (hidden on small phones, icon-sized otherwise) ---------- */
.main-header .search-wrapper {
  margin: 0 !important;
  width: 100%;
}
@media (max-width: 767.98px) {
  .main-header .search-wrapper { display: none; }
}

/* ---------- Action icons ---------- */
.navbar-wrapper { width: 100%; height: 100%; }
.navbar-wrapper > ul {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--hdr-gap);
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}
.navbar-wrapper > ul > li {
  float: none !important;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  padding: 0 !important;
  height: auto;
}
.navbar-wrapper > ul > li > a:not(.user-menu),
.navbar-wrapper > ul > li > .dropdown-toggle:not(.user-menu) {
  width: var(--hdr-icon);
  height: var(--hdr-icon);
  border-radius: 50%;
  background: var(--hdr-icon-bg);
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  padding: 0 !important;
  transition: background .15s ease;
  position: relative;
}
.navbar-wrapper > ul > li > a:not(.user-menu):hover,
.navbar-wrapper > ul > li > a:not(.user-menu).active,
.navbar-wrapper > ul > li.show > a {
  background: var(--hdr-icon-bg-hover);
}
.navbar-wrapper .header-icon {
  width: 22px !important;
  height: 22px !important;
  display: block;
}

/* Notification counters: pinned to top-right of the circle */
.navbar-wrapper .counter,
.navbar-wrapper .badge.counter {
  position: absolute !important;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--hdr-bg);
  box-sizing: content-box;
}

/* Guest "Join" button */
.navbar-wrapper a.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--hdr-icon);
  padding: 0 12px 0 4px;
  border-radius: 20px;
  background: var(--hdr-icon-bg);
  float: none !important;
}
.navbar-wrapper a.user-menu img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

/* Dropdown panels never overflow the screen on phones */
@media (max-width: 575.98px) {
  .navbar-wrapper .dropdown-menu,
  .navbar-wrapper .js_dropdown-menu {
    position: fixed !important;
    top: var(--hdr-height) !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none;
    transform: none !important;
  }
}

/* ---------- Very small phones ---------- */
@media (max-width: 359.98px) {
  :root { --hdr-icon: 36px; --hdr-gap: 4px; --hdr-logo-h: 26px; }
  .logo-wrapper .logo img { max-width: 110px; }
}

/* ---------- Tablet / desktop ---------- */
@media (min-width: 768px) {
  :root { --hdr-logo-h: 34px; --hdr-pad-x: 16px; }
  .header-home-btn { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; }
  .main-header [class*="col-"] > .row { justify-content: space-between; gap: 12px; }
  .main-header [class*="col-"] > .row > [class*="col-"]:first-child { flex: 1 1 auto; }
  .main-header [class*="col-"] > .row > [class*="col-"]:last-child { flex: 0 0 auto; width: auto; }
  .navbar-wrapper { width: auto; }
}