
/* FX Primer Portal Header v0.4
   Shared visual contract for Docs, Trend Pulse Screener and AI Analysis. */

:root{
  --fxp-header-bg:rgba(8,13,25,.90);
  --fxp-header-border:rgba(53,80,114,.46);
  --fxp-header-nav-bg:#09111f;
  --fxp-header-nav-active:rgba(25,38,65,.96);
  --fxp-header-muted:#96a5b9;
  --fxp-header-text:#f3f7fb;
  --fxp-header-action-border:rgba(89,116,159,.35);
  --fxp-header-action-border-hover:rgba(89,116,159,.60);
}

/* Same logo dimensions in all three product pages. */
.fxp-portal-logo{
  display:block !important;
  width:auto !important;
  height:27px !important;
  max-width:170px !important;
  object-fit:contain !important;
}

/* Same toolbar dimensions in all three product pages. */
.fxp-portal-nav{
  box-sizing:border-box !important;
  min-height:42px !important;
  display:grid !important;
  grid-template-columns:78px 176px 98px !important;
  align-items:center !important;
  justify-content:center !important;
  gap:4px !important;
  padding:4px !important;
  margin:0 !important;
  border:1px solid rgba(53,80,114,.50) !important;
  border-radius:12px !important;
  background:var(--fxp-header-nav-bg) !important;
  box-shadow:none !important;
}
.fxp-portal-nav a,
.fxp-portal-nav .nav-btn{
  box-sizing:border-box !important;
  width:100% !important;
  min-width:0 !important;
  min-height:32px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  margin:0 !important;
  padding:0 8px !important;
  border:0 !important;
  border-radius:8px !important;
  background:transparent !important;
  color:var(--fxp-header-muted) !important;
  font-family:Inter,Segoe UI,Arial,sans-serif !important;
  font-size:10px !important;
  font-weight:800 !important;
  line-height:1 !important;
  text-align:center !important;
  text-decoration:none !important;
  white-space:nowrap !important;
}
.fxp-portal-nav a.active,
.fxp-portal-nav .nav-btn.active{
  background:var(--fxp-header-nav-active) !important;
  color:var(--fxp-header-text) !important;
}
.fxp-portal-nav a:hover,
.fxp-portal-nav .nav-btn:hover{
  color:var(--fxp-header-text) !important;
}

/* Docs' button style becomes the common Account / Logout style. */
.fxp-portal-actions{
  display:flex !important;
  align-items:center !important;
  justify-content:flex-end !important;
  gap:7px !important;
}
.fxp-portal-action{
  box-sizing:border-box !important;
  min-width:72px !important;
  height:34px !important;
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  margin:0 !important;
  padding:0 12px !important;
  border:1px solid var(--fxp-header-action-border) !important;
  border-radius:10px !important;
  background:transparent !important;
  color:var(--fxp-header-muted) !important;
  font-family:Inter,Segoe UI,Arial,sans-serif !important;
  font-size:10px !important;
  font-weight:800 !important;
  line-height:1 !important;
  text-decoration:none !important;
  text-align:center !important;
  white-space:nowrap !important;
  cursor:pointer !important;
}
.fxp-portal-action:hover{
  color:#fff !important;
  border-color:var(--fxp-header-action-border-hover) !important;
  background:rgba(255,255,255,.018) !important;
}

/* Keep the Docs mobile menu icon visually left of the logo. */
.doc-top-left .mobile-menu{
  flex:0 0 auto;
}
.doc-top-left .doc-top-logo{
  flex:0 0 auto;
}

/* ------------------------------- MOBILE ------------------------------- */
@media(max-width:820px){
  /* Docs and the two apps now share the same two-row header geometry. */
  .topbar-inner,
  .top{
    box-sizing:border-box !important;
    min-height:0 !important;
    height:auto !important;
    display:grid !important;
    grid-template-columns:minmax(0,1fr) auto !important;
    grid-template-areas:
      "brand actions"
      "nav nav" !important;
    align-items:center !important;
    column-gap:10px !important;
    row-gap:13px !important; /* deliberately more breathing room */
    padding-top:8px !important;
    padding-bottom:10px !important;
  }

  .topbar .topbar-inner{
    width:calc(100% - 20px) !important;
    margin-left:auto !important;
    margin-right:auto !important;
  }
  .top{
    width:100% !important;
    padding-left:10px !important;
    padding-right:10px !important;
    background:var(--fxp-header-bg) !important;
    border-bottom:1px solid var(--fxp-header-border) !important;
  }

  /* Brand / Docs left group */
  .topbar-inner > .brand,
  .topbar-inner > .portal-brand-link,
  .doc-top-left{
    grid-area:brand !important;
    min-width:0 !important;
    margin:0 !important;
    align-self:center !important;
  }
  .doc-top-left{
    display:flex !important;
    align-items:center !important;
    gap:7px !important;
  }

  /* The old inner wrapper in Docs becomes layout-transparent so the
     hamburger can sit before the logo via order. */
  .doc-top-left > div[style*="display:flex"]{
    display:contents !important;
  }
  .doc-top-left .mobile-menu{
    display:block !important;
    order:0 !important;
  }
  .doc-top-left .doc-top-logo{
    order:1 !important;
  }
  .doc-top-left .crumb{
    display:none !important;
  }
  .mobile-menu summary{
    box-sizing:border-box !important;
    width:30px !important;
    height:30px !important;
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    margin:0 !important;
    padding:0 !important;
    border:1px solid rgba(89,116,159,.30) !important;
    border-radius:8px !important;
    font-size:15px !important;
    line-height:1 !important;
  }

  .fxp-portal-logo{
    height:23px !important;
    max-width:140px !important;
  }

  /* Actions */
  .top-right,
  .top-user,
  .doc-actions{
    grid-area:actions !important;
    justify-self:end !important;
    margin:0 !important;
  }
  .top-right .live,
  .top-user #usernameTop,
  .top-user .quota-pill{
    display:none !important;
  }
  .top-user .account-actions{
    display:flex !important;
    align-items:center !important;
    gap:6px !important;
    margin:0 !important;
  }
  .fxp-portal-actions{
    gap:6px !important;
  }
  .fxp-portal-action{
    min-width:62px !important;
    height:30px !important;
    padding:0 9px !important;
    border-radius:8px !important;
    font-size:9px !important;
    line-height:1 !important;
  }

  /* Navigation: exact same width, height and spacing on every page. */
  .portal-nav,
  .nav.fxp-portal-nav,
  .portal-switch{
    grid-area:nav !important;
    grid-column:auto !important;
    grid-row:auto !important;
    order:initial !important;
    width:100% !important;
    max-width:none !important;
    min-height:38px !important;
    grid-template-columns:68px minmax(154px,1fr) 86px !important;
    gap:4px !important;
    padding:4px !important;
    margin:0 !important;
    justify-self:stretch !important;
  }
  .fxp-portal-nav a,
  .fxp-portal-nav .nav-btn{
    min-height:28px !important;
    padding:0 4px !important;
    font-size:9px !important;
    line-height:1 !important;
    white-space:nowrap !important;
  }

  /* Docs content must clear the now standardized two-row header. */
  .page{
    scroll-margin-top:126px !important;
  }
}

@media(max-width:380px){
  .fxp-portal-logo{
    height:22px !important;
    max-width:128px !important;
  }
  .topbar-inner,
  .top{
    row-gap:12px !important;
  }
  .portal-nav,
  .nav.fxp-portal-nav,
  .portal-switch{
    grid-template-columns:62px minmax(145px,1fr) 80px !important;
  }
  .fxp-portal-nav a,
  .fxp-portal-nav .nav-btn{
    font-size:8.5px !important;
    padding-left:2px !important;
    padding-right:2px !important;
  }
  .fxp-portal-action{
    min-width:58px !important;
    padding:0 7px !important;
    font-size:8.5px !important;
  }
}


/* ======================================================================
   v0.4.1 MOBILE TOOLBAR FIX
   Robust mobile geometry for Docs / Screener / AI.
   ====================================================================== */
@media(max-width:820px){

  /* Use flex wrapping instead of the previous mobile grid.
     This prevents the Docs nav from inheriting a partial grid width. */
  .topbar-inner,
  .top{
    display:flex !important;
    flex-wrap:wrap !important;
    align-items:center !important;
    justify-content:space-between !important;
    gap:0 !important;
    row-gap:0 !important;
    column-gap:0 !important;
    min-height:0 !important;
    height:auto !important;
    box-sizing:border-box !important;
    padding-top:8px !important;
    padding-bottom:9px !important;
  }

  .topbar .topbar-inner{
    width:calc(100% - 20px) !important;
    margin-left:auto !important;
    margin-right:auto !important;
  }

  .top{
    width:100% !important;
    padding-left:10px !important;
    padding-right:10px !important;
  }

  /* Row 1 */
  .topbar-inner > .brand,
  .topbar-inner > .portal-brand-link,
  .doc-top-left{
    order:1 !important;
    flex:1 1 auto !important;
    min-width:0 !important;
    width:auto !important;
    margin:0 !important;
    align-self:center !important;
  }

  .top-right,
  .top-user,
  .doc-actions{
    order:2 !important;
    flex:0 0 auto !important;
    width:auto !important;
    margin:0 !important;
    align-self:center !important;
  }

  /* Row 2: always one full-width toolbar.
     margin-top is intentional: more separation from logo/actions. */
  .portal-nav,
  .nav.fxp-portal-nav,
  .portal-switch{
    order:3 !important;
    flex:0 0 100% !important;
    width:100% !important;
    max-width:none !important;
    min-width:0 !important;
    min-height:38px !important;
    margin:13px 0 0 0 !important;
    padding:4px !important;
    align-self:stretch !important;
    justify-self:auto !important;
    box-sizing:border-box !important;

    display:grid !important;
    grid-template-columns:minmax(0,.78fr) minmax(0,1.62fr) minmax(0,.95fr) !important;
    gap:4px !important;
  }

  .fxp-portal-nav a,
  .fxp-portal-nav .nav-btn{
    width:100% !important;
    min-width:0 !important;
    min-height:28px !important;
    height:28px !important;
    padding:0 4px !important;
    margin:0 !important;
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    text-align:center !important;
    white-space:nowrap !important;
    overflow:hidden !important;
    text-overflow:clip !important;
    font-size:9px !important;
    line-height:1 !important;
  }

  /* Docs left row: hamburger BEFORE logo. */
  .doc-top-left{
    display:flex !important;
    align-items:center !important;
    justify-content:flex-start !important;
    gap:8px !important;
  }
  .doc-top-left > div[style*="display:flex"]{
    display:contents !important;
  }
  .doc-top-left .mobile-menu{
    display:block !important;
    order:0 !important;
    flex:0 0 30px !important;
    margin:0 !important;
  }
  .doc-top-left .doc-top-logo{
    order:1 !important;
    flex:0 0 auto !important;
    margin:0 !important;
  }
  .doc-top-left .crumb{
    display:none !important;
  }

  /* Draw a true geometric hamburger instead of relying on the ☰ glyph,
     whose font metrics made it look off-centre on iOS. */
  .mobile-menu summary{
    position:relative !important;
    box-sizing:border-box !important;
    width:30px !important;
    height:30px !important;
    min-width:30px !important;
    min-height:30px !important;
    margin:0 !important;
    padding:0 !important;
    display:block !important;
    list-style:none !important;
    color:#dce7f5 !important;
    font-size:0 !important;
    line-height:0 !important;
    border:1px solid rgba(89,116,159,.30) !important;
    border-radius:8px !important;
  }
  .mobile-menu summary::-webkit-details-marker{
    display:none !important;
  }
  .mobile-menu summary::marker{
    content:"" !important;
  }
  .mobile-menu summary::before{
    content:"" !important;
    position:absolute !important;
    left:50% !important;
    top:50% !important;
    width:14px !important;
    height:10px !important;
    transform:translate(-50%,-50%) !important;
    background:
      linear-gradient(to bottom,
        currentColor 0 2px,
        transparent 2px 4px,
        currentColor 4px 6px,
        transparent 6px 8px,
        currentColor 8px 10px) !important;
    border-radius:1px !important;
  }

  /* Preserve identical logo size across the three product pages. */
  .fxp-portal-logo{
    height:23px !important;
    max-width:140px !important;
  }

  /* Same compact action buttons, perfectly centred. */
  .fxp-portal-actions{
    display:flex !important;
    align-items:center !important;
    justify-content:flex-end !important;
    gap:6px !important;
  }
  .fxp-portal-action{
    min-width:62px !important;
    width:auto !important;
    height:30px !important;
    min-height:30px !important;
    padding:0 9px !important;
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    text-align:center !important;
    vertical-align:middle !important;
    font-size:9px !important;
    line-height:1 !important;
  }

  .page{
    scroll-margin-top:124px !important;
  }
}

@media(max-width:380px){
  .portal-nav,
  .nav.fxp-portal-nav,
  .portal-switch{
    grid-template-columns:minmax(0,.75fr) minmax(0,1.70fr) minmax(0,.95fr) !important;
    margin-top:12px !important;
  }
  .fxp-portal-nav a,
  .fxp-portal-nav .nav-btn{
    font-size:8.4px !important;
    padding-left:2px !important;
    padding-right:2px !important;
  }
  .fxp-portal-logo{
    height:22px !important;
    max-width:128px !important;
  }
}


/* ======================================================================
   v0.4.2 HUB HEADER CLEANUP
   Hub only: brand left, Logout right, no Account button.
   ====================================================================== */
.hub-page .topbar-inner{
  position:relative !important;
}

.hub-page .top-actions{
  margin-left:auto !important;
}

.hub-page .top-actions .fxp-portal-action{
  min-width:72px !important;
  height:34px !important;
  min-height:34px !important;
  padding:0 12px !important;
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  text-align:center !important;
  line-height:1 !important;
}

@media(max-width:820px){
  .hub-page .topbar-inner{
    display:flex !important;
    flex-wrap:wrap !important;
    align-items:center !important;
    justify-content:space-between !important;
    padding-top:8px !important;
    padding-bottom:9px !important;
  }

  .hub-page .brand{
    order:1 !important;
    flex:0 0 auto !important;
    margin:0 !important;
    justify-self:auto !important;
  }

  .hub-page .top-actions{
    order:2 !important;
    flex:0 0 auto !important;
    width:auto !important;
    margin:0 0 0 auto !important;
    justify-content:flex-end !important;
  }

  .hub-page .portal-nav{
    order:3 !important;
    flex:0 0 100% !important;
    width:100% !important;
    margin-top:13px !important;
  }

  .hub-page .top-actions .fxp-portal-action{
    min-width:62px !important;
    width:auto !important;
    height:30px !important;
    min-height:30px !important;
    padding:0 9px !important;
    font-size:9px !important;
    line-height:1 !important;
  }
}


/* ======================================================================
   v0.4.4 HUB DESKTOP CENTERING
   Hub only: keep the portal selector geometrically centered in the header,
   independent of logo / Logout widths.
   ====================================================================== */
@media(min-width:821px){
  .hub-page .topbar-inner{
    position:relative !important;
  }

  .hub-page .brand{
    position:relative !important;
    z-index:2 !important;
    margin-right:auto !important;
  }

  .hub-page .portal-nav{
    position:absolute !important;
    left:50% !important;
    top:50% !important;
    transform:translate(-50%,-50%) !important;
    margin:0 !important;
    z-index:1 !important;
  }

  .hub-page .top-actions{
    position:relative !important;
    z-index:2 !important;
    margin-left:auto !important;
  }
}
