/* ============================================================================
   AMAC Suite — Universal Header v1  (shared chrome bar)
   ----------------------------------------------------------------------------
   One consistent top bar across every app: ← Suite Home · app identity ·
   Help · Notifications · Theme · Account menu. Only the app name + version
   (and, later, one app action) differ per app.

   Pairs with amac-suite-header-v1.js. Additive + reversible: remove the
   <link>/<script> and the app's own hero nav is untouched.

   The bar is intentionally AMAC navy in BOTH themes (brand chrome); only the
   account dropdown follows light/dark. Desktop only — on <=1024px the bar is
   hidden and the existing v1.2 off-canvas drawer owns mobile navigation, so
   the two never collide.
   ========================================================================= */

.amac-suite-header{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  height:48px; padding:0 14px; box-sizing:border-box;
  background:#022544; color:#fff;
  position:sticky; top:0; z-index:9000;
  font-family:inherit; -webkit-font-smoothing:antialiased;
}
.amac-suite-header *{ box-sizing:border-box; }
.amac-suite-header .ash-left,
.amac-suite-header .ash-right{ display:flex; align-items:center; gap:8px; min-width:0; }
.amac-suite-header .ash-left{ flex:1 1 auto; min-width:0; }
.amac-suite-header .ash-right{ flex:0 0 auto; }

/* Suite Home pill */
.amac-suite-header .ash-home{
  display:inline-flex; align-items:center; gap:6px; text-decoration:none;
  padding:6px 12px; border-radius:8px; background:rgba(255,255,255,.12);
  color:#fff; font-size:13px; font-weight:500; white-space:nowrap; flex:none;
}
.amac-suite-header .ash-home:hover{ background:rgba(255,255,255,.22); color:#fff; }
.amac-suite-header .ash-home:focus-visible{ outline:2px solid #fff; outline-offset:2px; }

.amac-suite-header .ash-divider{ width:1px; height:20px; background:rgba(255,255,255,.2); margin:0 2px; flex:none; }

/* App identity */
.amac-suite-header .ash-logo{
  display:inline-flex; align-items:center; justify-content:center;
  width:26px; height:26px; border-radius:6px; background:#840D0D; color:#fff;
  font-size:12px; font-weight:600; flex:none;
}
.amac-suite-header .ash-name{
  color:#fff; font-size:15px; font-weight:500; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; min-width:0;
}
.amac-suite-header .ash-ver{
  color:#fff; font-size:11px; padding:2px 7px; border-radius:20px;
  background:rgba(255,255,255,.16); white-space:nowrap; flex:none;
}

/* Icon buttons (help / bell / theme) */
.amac-suite-header .ash-iconbtn{
  display:inline-flex; align-items:center; justify-content:center;
  width:34px; height:34px; border:0; background:transparent; color:#fff;
  border-radius:8px; cursor:pointer; line-height:1; position:relative; flex:none;
}
.amac-suite-header .ash-iconbtn:hover{ background:rgba(255,255,255,.14); }
.amac-suite-header .ash-iconbtn:focus-visible{ outline:2px solid #fff; outline-offset:2px; }
/* 2026-07-22: lock the control-icon SVG size + flex so it can't be squeezed to
 * ~2px "dots" in a cramped header row. The 18px lived only in the SVG's HTML
 * width/height attrs (an unconstrained flex item); this centralizes the fix
 * AMAC Management applied locally (amac-management.css .ash-iconbtn svg) so all
 * suite apps that load this shared header are immune. Suite-wide header-icon
 * audit 2026-07-22: 31/32 apps were at risk; this one change covers them all. */
.amac-suite-header .ash-iconbtn svg{ display:block; width:18px; height:18px; flex:0 0 auto; }
.amac-suite-header .ash-dot{
  position:absolute; top:6px; right:6px; width:8px; height:8px; border-radius:50%;
  background:#E24B4A; border:2px solid #022544;
}
.amac-suite-header .ash-dot[hidden]{ display:none; }
/* The ⚕ diagnostics icon is feature-detected (revealed only when the app exposes
   a diagnostics launcher), so it must actually hide while the `hidden` attr is
   set — `.ash-iconbtn`'s display:inline-flex would otherwise override it. */
.amac-suite-header .ash-diag[hidden]{ display:none !important; }

/* Labeled action pills (icon + short label) — Feedback, Ask AI. These relocate
   the bottom-right floating launchers into the bar (operator request 2026-06-28),
   so they read like the actions they replace rather than as bare icons. */
.amac-suite-header .ash-pill{
  display:inline-flex; align-items:center; gap:6px; flex:none;
  padding:6px 12px; border:0; border-radius:20px;
  background:rgba(255,255,255,.12); color:#fff;
  font-family:inherit; font-size:13px; font-weight:500; line-height:1;
  white-space:nowrap; cursor:pointer;
}
.amac-suite-header .ash-pill:hover{ background:rgba(255,255,255,.22); }
.amac-suite-header .ash-pill:focus-visible{ outline:2px solid #fff; outline-offset:2px; }
.amac-suite-header .ash-pill svg{ display:block; width:18px; height:18px; flex:0 0 auto; }
.amac-suite-header .ash-pill[hidden]{ display:none !important; }

/* Account control + dropdown */
.amac-suite-header .ash-acct-wrap{ position:relative; flex:none; }
.amac-suite-header .ash-acct{
  display:inline-flex; align-items:center; gap:7px; padding:4px 8px 4px 4px;
  border:0; background:rgba(255,255,255,.1); color:#fff; border-radius:20px; cursor:pointer;
}
.amac-suite-header .ash-acct:hover{ background:rgba(255,255,255,.2); }
.amac-suite-header .ash-acct:focus-visible{ outline:2px solid #fff; outline-offset:2px; }
.amac-suite-header .ash-avatar{
  width:24px; height:24px; border-radius:50%; background:#2A6BB0; color:#fff;
  display:inline-flex; align-items:center; justify-content:center; font-size:11px; font-weight:600; flex:none;
}
.amac-suite-header .ash-acct-name{ font-size:12px; max-width:130px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.amac-suite-header .ash-acct svg{ display:block; opacity:.85; }

.amac-suite-header .ash-menu{
  position:absolute; top:calc(100% + 6px); right:0; min-width:224px;
  background:#fff; color:#17222e; border:1px solid rgba(0,0,0,.12);
  border-radius:10px; box-shadow:0 8px 24px rgba(0,0,0,.18); padding:6px; z-index:9001;
}
.amac-suite-header .ash-menu[hidden]{ display:none; }
.amac-suite-header .ash-menu-head{ padding:8px 10px 10px; border-bottom:1px solid rgba(0,0,0,.08); margin-bottom:4px; }
.amac-suite-header .ash-menu-name{ font-size:13px; font-weight:600; color:#17222e; }
.amac-suite-header .ash-menu-role{ font-size:11px; color:#5b6b7b; margin-top:1px; }
.amac-suite-header .ash-menu a,
.amac-suite-header .ash-menu button{
  display:flex; align-items:center; gap:10px; width:100%; text-align:left;
  padding:8px 10px; border:0; background:transparent; color:#17222e; font-size:13px;
  border-radius:7px; cursor:pointer; text-decoration:none; font-family:inherit;
}
.amac-suite-header .ash-menu a:hover,
.amac-suite-header .ash-menu button:hover{ background:rgba(2,37,68,.06); }
.amac-suite-header .ash-menu a svg,
.amac-suite-header .ash-menu button svg{ display:block; opacity:.7; flex:none; }
.amac-suite-header .ash-menu .ash-logout{ color:#a3261f; }
.amac-suite-header .ash-menu .ash-logout:hover{ background:rgba(163,38,31,.08); }
.amac-suite-header .ash-menu-sep{ height:1px; background:rgba(0,0,0,.08); margin:4px 6px; }

/* account dropdown — dark mode */
[data-theme="dark"] .amac-suite-header .ash-menu{ background:#0e2236; color:#e8eef5; border-color:rgba(255,255,255,.14); box-shadow:0 8px 24px rgba(0,0,0,.5); }
[data-theme="dark"] .amac-suite-header .ash-menu-name{ color:#e8eef5; }
[data-theme="dark"] .amac-suite-header .ash-menu-role{ color:#9fb2c4; }
[data-theme="dark"] .amac-suite-header .ash-menu-head,
[data-theme="dark"] .amac-suite-header .ash-menu-sep{ border-color:rgba(255,255,255,.1); background:transparent; }
[data-theme="dark"] .amac-suite-header .ash-menu-sep{ background:rgba(255,255,255,.1); }
[data-theme="dark"] .amac-suite-header .ash-menu a,
[data-theme="dark"] .amac-suite-header .ash-menu button{ color:#e8eef5; }
[data-theme="dark"] .amac-suite-header .ash-menu a:hover,
[data-theme="dark"] .amac-suite-header .ash-menu button:hover{ background:rgba(255,255,255,.08); }
[data-theme="dark"] .amac-suite-header .ash-menu .ash-logout{ color:#ff8b80; }
[data-theme="dark"] .amac-suite-header .ash-menu .ash-logout:hover{ background:rgba(255,139,128,.12); }

/* ----------------------------------------------------------------------------
   Hide legacy / duplicate chrome once the bar is mounted (desktop only). These
   are the suite-standard classes; the bar supersedes them.
   ------------------------------------------------------------------------- */
@media (min-width:1025px){
  body.amac-suite-header-on .suite-back-link,
  body.amac-suite-header-on .amac-shell-home-btn,
  body.amac-suite-header-on .amac-shell-bar,
  body.amac-suite-header-on .quick-actions-drop,
  body.amac-suite-header-on .user-chip,
  body.amac-suite-header-on #suite-nav,
  body.amac-suite-header-on #suite-nav-slot,
  body.amac-suite-header-on #amacThemeToggle,
  body.amac-suite-header-on .amac-notif-bell,
  body.amac-suite-header-on .amac-manual-fab,
  body.amac-suite-header-on .amac-aichat-btn,
  body.amac-suite-header-on .cam-notif-chip,
  /* v1.5.0 (FR-000034 P2): Suite Home's own identity line. It exists only on
     Home, and the bar's Account menu now supersedes it -- without this you get
     two user chips on the same screen. */
  body.amac-suite-header-home #user-info{ display:none !important; }
  /* BUG-000039: retire the floating Feedback FAB ONLY once its header pill is
     confirmed live (amac-feedback-relocated, set by wireFeedback on reveal) --
     otherwise the FAB stays visible as a fallback so feedback is never
     unreachable. Mirrors the amac-diag-relocated handoff below. */
  body.amac-suite-header-on.amac-feedback-relocated .amac-bugreport-btn{ display:none !important; }
}

/* ----------------------------------------------------------------------------
   Header-anchored dropdowns (desktop). Once the bar is mounted, the suite's
   floating widget panels DROP DOWN from the bar's right cluster instead of
   docking in the bottom-right corner where they covered app data (operator
   request 2026-06-28). Pure re-anchor: each widget's open/close + internals are
   untouched; we only move where the (already-open) panel sits. Right-aligned to
   the bar's right padding so it reads as a dropdown from the header buttons.
   `--ash-dropdown-top` = bar height (48) + a 6px gap.
   ------------------------------------------------------------------------- */
@media (min-width:1025px){
  body.amac-suite-header-on .amac-notif-panel{
    top:54px; right:14px; bottom:auto; left:auto;
    max-height:min(78vh, 620px);
  }
  /* Feedback chooser menu (Report a bug / Request a feature) drops under the
     bar's Feedback pill. The bug/feature MODALS stay centered (untouched). */
  body.amac-suite-header-on .amac-feedback-menu{
    top:54px; right:14px; bottom:auto; left:auto;
  }
  /* Ask AI chat panel drops under the bar's Ask AI pill. Height clamps to the
     viewport below the bar so it never runs off a short screen. */
  body.amac-suite-header-on .amac-aichat-panel{
    top:54px; right:14px; bottom:auto; left:auto;
    height:min(640px, calc(100vh - 68px));
  }
  /* Retire the per-app floating self-diagnostic launcher on desktop — but ONLY
     once the bar's ⚕ is live (`amac-diag-relocated`, set by wireDiag when it
     finds a launcher). Atomic: the corner button never disappears before its
     header replacement exists, so diagnostics is always reachable. */
  body.amac-suite-header-on.amac-diag-relocated #amacDiagFloatBtn,
  body.amac-suite-header-on.amac-diag-relocated .amgmt-diag-pill{ display:none !important; }
}

/* ----------------------------------------------------------------------------
   SUITE HOME + WORKSPACE TABS (v1.5.0, FR-000034 P2)
   ----------------------------------------------------------------------------
   Suite Home is the only page that also hosts the Workspace Tabs shell, so the
   bar has to coexist with chrome no app page has:

   1. `.amac-ws-bar` is `position:fixed; top:0; height:40px` and appears ONLY once
      at least one tab is open (`body.amac-ws-has-tabs`). The header is sticky at
      top:0, so with tabs open the two occupy the same 40px band. Push the whole
      document below the strip and re-anchor the sticky offset to match, so the
      order reads: tab strip, then header, then content -- the same stack a framed
      app shows. The workspace's own `main.page-shell` padding-top compensation is
      then redundant and would double the gap, so it is neutralised here.

   2. While an app tab is ACTIVE the framed app renders its OWN header inside the
      iframe. Home's bar would sit above it -- two stacked header bars, the exact
      class of bug Workspace Tabs v1.1.1 fixed for the tab strip. Hide Home's bar
      in that state; the framed app's bar is the live one. (`amac-ws-app-active`
      is set only on the TOP window's body -- the workspace refuses to boot inside
      a frame, WS-8 -- so this can never hide the framed app's own header.)
   ------------------------------------------------------------------------- */
@media (min-width:1025px){
  body.amac-suite-header-home.amac-ws-has-tabs{ padding-top:40px; }
  body.amac-suite-header-home.amac-ws-has-tabs .amac-suite-header{ top:40px; }
  body.amac-suite-header-home.amac-ws-has-tabs main.page-shell{ padding-top:0 !important; }
  body.amac-suite-header-home.amac-ws-app-active .amac-suite-header{ display:none !important; }
}

/* Mobile: defer entirely to the existing v1.2 off-canvas drawer. */
@media (max-width:1024px){
  .amac-suite-header{ display:none !important; }
}
