/* ============================================================
   TradeForge OS — Global Header System
   Two-layer OS-level header: command strip + primary bar.
   Replaces all legacy nav patterns across the site.
   ============================================================ */

/* ── Command Strip (top KPI bar) ─────────────────────────── */
.tfos-cmd-strip {
  background: rgba(15,17,20,.96);
  border-bottom: 1px solid rgba(140,106,62,.12);
  font-size: 11px;
  letter-spacing: .02em;
  z-index: 52;
  position: sticky;
  top: 0;
}
.tfos-cmd-strip-inner {
  max-width: var(--max, 1140px);
  margin: 0 auto;
  padding: 6px 22px;
  display: flex;
  align-items: center;
  gap: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tfos-cmd-strip-inner::-webkit-scrollbar { display: none; }
.tfos-kpi {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tfos-kpi-val {
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  min-width: 18px;
  text-align: center;
}
.tfos-kpi-val--urgent { color: #e8625a; }
.tfos-kpi-val--risk { color: #e8a34e; }
.tfos-kpi-label {
  color: var(--muted, rgba(181,183,185,.72));
  font-weight: 500;
}

/* ── Primary Header ──────────────────────────────────────── */
.tfos-header {
  position: sticky;
  top: 30px; /* below command strip */
  z-index: 51;
  background: rgba(28,30,33,.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(140,106,62,.18);
}
.tfos-header-inner {
  max-width: var(--max, 1140px);
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 16px;
}

/* Brand */
.tfos-brand {
  display: flex;
  flex-direction: column;
  line-height: 1;
  flex-shrink: 0;
  text-decoration: none !important;
  color: inherit;
}
.tfos-brand:hover { text-decoration: none !important; }
.tfos-brand b {
  letter-spacing: .06em;
  font-size: 15px;
  color: #fff;
}
.tfos-brand span {
  color: var(--muted, rgba(181,183,185,.72));
  font-size: 10px;
  margin-top: 2px;
  letter-spacing: .04em;
}

/* ── Lifecycle Nav (center) ──────────────────────────────── */
.tfos-lifecycle {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 auto;
  flex-shrink: 1;
  min-width: 0;
}
.tfos-lifecycle a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, rgba(181,183,185,.72));
  text-decoration: none !important;
  border-radius: 6px;
  white-space: nowrap;
  transition: color .18s, background .18s;
  letter-spacing: .01em;
}
.tfos-lifecycle a:hover {
  color: #fff;
  background: rgba(140,106,62,.10);
  text-decoration: none !important;
}
.tfos-lifecycle a.active {
  color: #fff;
  background: rgba(140,106,62,.18);
}
.tfos-lifecycle a.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--bronze, #8C6A3E);
  border-radius: 2px;
}
/* Step separator */
.tfos-lifecycle-sep {
  color: rgba(140,106,62,.3);
  font-size: 10px;
  margin: 0 -1px;
  user-select: none;
  flex-shrink: 0;
}

/* ── Control Center (right) ──────────────────────────────── */
.tfos-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
/* Icon buttons */
.tfos-ctrl-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted, rgba(181,183,185,.72));
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  padding: 0;
}
.tfos-ctrl-btn:hover {
  color: #fff;
  background: rgba(140,106,62,.10);
  border-color: rgba(140,106,62,.25);
}
.tfos-ctrl-btn svg {
  width: 18px;
  height: 18px;
}
/* Notification badge */
.tfos-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 8px;
  height: 8px;
  border-radius: 8px;
  background: #e8625a;
  border: 2px solid rgba(28,30,33,.95);
  pointer-events: none;
}
.tfos-badge[data-count="0"],
.tfos-badge:empty { display: none; }
.tfos-badge[data-count] {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  top: 0;
  right: 0;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  padding: 0 3px;
}

/* ── Quick Actions Dropdown ──────────────────────────────── */
.tfos-dropdown {
  position: relative;
}
.tfos-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: rgba(38,40,44,.98);
  border: 1px solid rgba(140,106,62,.22);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  z-index: 100;
}
.tfos-dropdown.open .tfos-dropdown-panel { display: block; }
.tfos-dropdown-panel a,
.tfos-dropdown-panel button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ash, #B5B7B9);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none !important;
  transition: background .12s, color .12s;
  text-align: left;
}
.tfos-dropdown-panel a:hover,
.tfos-dropdown-panel button:hover {
  background: rgba(140,106,62,.12);
  color: #fff;
  text-decoration: none !important;
}
.tfos-dropdown-panel svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .7;
}
.tfos-dropdown-divider {
  height: 1px;
  background: rgba(140,106,62,.12);
  margin: 4px 6px;
}

/* Open Workspace button */
.tfos-workspace-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink, #0f1114);
  background: var(--bronze, #8C6A3E);
  border: 1px solid rgba(140,106,62,.65);
  border-radius: 999px;
  text-decoration: none !important;
  white-space: nowrap;
  transition: transform .12s, background .12s;
  box-shadow: 0 0 0 1px rgba(140,106,62,.18) inset;
}
.tfos-workspace-btn:hover {
  background: #9d7646;
  transform: translateY(-1px);
  text-decoration: none !important;
  color: var(--ink, #0f1114);
}

/* Profile avatar */
.tfos-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(140,106,62,.2);
  border: 1px solid rgba(140,106,62,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--bronze, #8C6A3E);
  flex-shrink: 0;
  cursor: pointer;
}

/* ── Mobile Menu Toggle ──────────────────────────────────── */
.tfos-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid rgba(140,106,62,.2);
  border-radius: 8px;
  color: var(--ash, #B5B7B9);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.tfos-mobile-toggle svg {
  width: 20px;
  height: 20px;
}

/* ── Mobile Menu Panel ───────────────────────────────────── */
.tfos-mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: rgba(15,17,20,.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tfos-mobile-menu.open { display: flex; }
.tfos-mobile-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(140,106,62,.15);
}
.tfos-mobile-menu-close {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(140,106,62,.2);
  border-radius: 8px;
  color: var(--ash, #B5B7B9);
  cursor: pointer;
  padding: 0;
}
.tfos-mobile-menu-close svg { width: 20px; height: 20px; }
.tfos-mobile-menu-body {
  flex: 1;
  padding: 16px 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tfos-mobile-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--bronze, #8C6A3E);
  padding: 16px 0 6px;
}
.tfos-mobile-section-title:first-child { padding-top: 4px; }
.tfos-mobile-menu-body a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ash, #B5B7B9);
  text-decoration: none !important;
  border-radius: 8px;
  transition: background .12s, color .12s;
}
.tfos-mobile-menu-body a:hover {
  background: rgba(140,106,62,.10);
  color: #fff;
  text-decoration: none !important;
}
.tfos-mobile-menu-body a.active {
  color: #fff;
  background: rgba(140,106,62,.15);
}
.tfos-mobile-menu-body svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .6;
}
.tfos-mobile-cta {
  margin-top: auto;
  padding-top: 20px;
}
.tfos-mobile-cta a {
  display: flex !important;
  justify-content: center;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 960px) {
  .tfos-lifecycle { display: none; }
  .tfos-controls .tfos-dropdown:not(.tfos-notif-wrap),
  .tfos-controls .tfos-profile-wrap { display: none; }
  .tfos-mobile-toggle { display: flex; }
  .tfos-header-inner { height: 50px; }
  .tfos-cmd-strip-inner { padding: 5px 16px; gap: 16px; }
  .tfos-kpi-label { display: none; }
  .tfos-kpi-val { font-size: 12px; }
  .tfos-kpi::before {
    font-size: 9px;
    font-weight: 600;
    color: var(--muted, rgba(181,183,185,.72));
    letter-spacing: .02em;
  }
  .tfos-kpi[data-short="ACT"]::before { content: "ACT"; }
  .tfos-kpi[data-short="DUE"]::before { content: "DUE"; }
  .tfos-kpi[data-short="REV"]::before { content: "REV"; }
  .tfos-kpi[data-short="PRJ"]::before { content: "PRJ"; }
  .tfos-header { top: 25px; }
}
@media (min-width: 961px) {
  .tfos-mobile-menu { display: none !important; }
}

/* ── Override old nav when OS header is active ────────────── */
body.tfos-header-active > .nav,
body.tfos-header-active > header.cc-top-strip,
body.tfos-header-active > nav.ucmd-nav {
  display: none !important;
}
/* Also hide old portal-module-nav subnav bar since lifecycle nav replaces it */
body.tfos-header-active .portal-module-nav { display: none !important; }
body.tfos-header-active .tf-primary-os-nav { display: none !important; }
body.tfos-header-active .tf-system-flow { display: none !important; }

/* Fix sticky positioning for command strip + header combo */
body.tfos-header-active {
  scroll-padding-top: 90px;
}

/* Adjust the dos-command-strip on dashboard since we now have the global one */
body.tfos-header-active .dos-command-strip { display: none; }
