/*
 * Shared site header for the web portal: Dashboard, MCP Console, Setup Guide and Developer Notes.
 *
 * The header markup is the same on every page, so its style lives here, once. It is deliberately self-contained (own colours,
 * own font stack) because the pages name their CSS variables differently (--text-muted vs --muted, --cyfirma-red vs --bad) and
 * the Console uses a different body font. Page-local copies of these rules are what made the four headers drift apart: different
 * widths, different wrapping, different gaps and logo sizes. Change the header here and nowhere else.
 *
 * --shell-max is the one page width for all four pages, so the logo and the content start at the same x on every page.
 */
:root {
  --shell-max: 1280px;
}

header.site-header {
  --sh-red: #E11F26;
  --sh-red-glow: rgba(225, 31, 38, 0.35);
  --sh-muted: #8c9baed0;

  /*
   * Brand lockup at the top left, menu at the top right, tagline across the row beneath:
   *
   *   [logo] | [logo] | DeCYFIR MCP                    [ Dashboard | ... | Health ]  [ admin ]
   *   PREEMPTIVE EXTERNAL THREAT LANDSCAPE MANAGEMENT (ETLM)
   */
  width: 100%;
  margin: 0 0 2rem;
  padding: 1.25rem 0 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand   nav"
    "tagline tagline";
  align-items: center;
  column-gap: 1.25rem;
  row-gap: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

header.site-header *,
header.site-header *::before,
header.site-header *::after {
  box-sizing: border-box;
}

/* ---- brand ---- */

/* the link around the lockup: logo | logo | title on one row; only the lockup itself is clickable */
header.site-header .brand-wrap {
  grid-area: brand;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
  max-width: 100%;
  color: inherit;
  text-decoration: none;
}

header.site-header .brand-cyfirma-logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

header.site-header .brand-logo-img {
  height: 38px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

header.site-header .brand-divider {
  height: 28px;
  width: 1px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
}

header.site-header .brand-title-box {
  min-width: 0;
  margin: 0;
}

header.site-header .brand-title-box h1 {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: #fff;
}

header.site-header .brand-title-box h1 span.tm {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--sh-red);
  vertical-align: super;
}

header.site-header .brand-tagline {
  grid-area: tagline; /* its own row, starting under the first logo and running across */
  margin: 0;
  padding: 0;
  font-size: 0.72rem;
  line-height: 1.5; /* a page-wide `p { line-height: 1.6 }` (Setup Guide) must not leak into the header */
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sh-muted);
}

/* ---- navigation, health and session ---- */

header.site-header .nav-actions {
  grid-area: nav;
  justify-self: end;              /* menu and session chip sit together at the top right */
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;                /* the chip drops under the nav bar when the screen is too narrow for both */
  gap: 0.75rem;
  max-width: 100%;
  min-height: 39px;               /* the menu bar's height, so a page with only a badge here (login) has the same header height */
  margin: 0;
}

header.site-header .nav-links-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

header.site-header .nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--sh-muted);
  text-decoration: none;
  transition: all 0.15s ease;
}

header.site-header .nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

header.site-header .nav-item.active {
  color: #fff;
  font-weight: 600;
  background: var(--sh-red);
  box-shadow: 0 0 12px var(--sh-red-glow);
}

header.site-header .user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  white-space: nowrap;
  color: #cfd8e3;
}

header.site-header .user-badge strong,
header.site-header .user-badge #sessionUsername {
  font-weight: 600;
  color: #fff;
}

header.site-header .signout-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--sh-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

header.site-header .signout-btn:hover {
  color: #ff8a80;
  background: rgba(225, 31, 38, 0.15);
  border-color: rgba(225, 31, 38, 0.35);
}

/* ---- narrower screens ----
 * When the lockup and the menu no longer fit side by side (they need about 1080px), the menu moves under the tagline,
 * still at the right. The width is the same on every page because this is the only place it is set. */

@media (max-width: 1140px) {
  header.site-header {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "tagline"
      "nav";
  }

  header.site-header .nav-actions {
    margin-top: 0.4rem;
  }
}

@media (max-width: 640px) {
  header.site-header .nav-links-bar {
    flex-wrap: wrap;
  }
}
