/* ==========================================================================
   BP-MENU — Header + navigazione con dropdown (brand Business-Plan.it)
   Prefisso: bpm-   |   Dipendenze: nessuna (token brand ereditati da :root)

   Tutte le classi sono namespacate perché la pagina carica Bootstrap 3 e
   main.css, che occupano nomi generici come .nav, .btn, .menu, .item, .right.
   Sostituisce l'header legacy #top-bar / .bp-header sulle pagine che lo adottano.
   La barra accenti (.bp-accentbar) resta quella già definita nel CSS di pagina.
   ========================================================================== */

/* L'header resta visibile durante lo scroll: gli ancoraggi e gli
   scrollIntoView della pagina devono fermarsi sotto di esso. */
html { scroll-padding-top: 90px; }

/* position:fixed e non sticky: main.css imposta overflow-x:hidden su html/body,
   che rende body un contenitore di scroll e annulla lo sticky rispetto al
   viewport. È lo stesso motivo per cui l'header legacy usava navbar-fixed-top.
   Di conseguenza l'header esce dal flusso e va compensato sul body. */
body { padding-top: 78px; }

.bpm-header {
  background: #fff;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1030;
}

.bpm-nav {
  align-items: stretch;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 0 32px;
  position: relative;
  z-index: 3;
}

.bpm-nav :focus-visible { border-radius: 2px; outline: 2px solid var(--navy); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Logo + payoff
   -------------------------------------------------------------------------- */
.bpm-brand {
  align-items: center;
  display: flex;
  flex: none;
  gap: 12px;
  padding: 14px 0;
  text-decoration: none;
}

.bpm-brand:hover, .bpm-brand:focus { text-decoration: none; }
.bpm-brand svg { display: block; flex: none; height: 33px; width: 26px; }

.bpm-brand .bpm-wm {
  color: var(--navy);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: .95;
  white-space: nowrap;
}

.bpm-brand .bpm-wm small {
  color: var(--ink);
  display: block;
  font-size: 8px;
  font-weight: 400;
  letter-spacing: .03em;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Contenitore voci: in linea da desktop, drawer sotto i 1080px
   -------------------------------------------------------------------------- */
.bpm-panel {
  align-items: stretch;
  display: flex;
  flex: 1;
  gap: 24px;
  justify-content: space-between;
  min-width: 0;
}

.bpm-menu {
  align-items: stretch;
  display: flex;
  flex: 1;
  gap: 4px;
  justify-content: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

.bpm-item { display: flex; margin: 0; position: relative; }

.bpm-item > button {
  align-items: flex-start;
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  font-family: inherit;
  gap: 9px;
  padding: 18px 14px 16px;
  transition: background .15s, border-color .15s;
}

.bpm-item > button:hover { background: var(--sky-soft); }
.bpm-item.is-open > button { background: var(--sky-soft); border-bottom-color: var(--navy); }

.bpm-lbl { display: flex; flex-direction: column; line-height: 1.06; text-align: left; }

.bpm-lbl .bpm-up {
  color: var(--navy);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.bpm-lbl .bpm-lo {
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-top: 5px;
  white-space: nowrap;
}

.bpm-chev {
  color: var(--mute, #6B7280);
  flex: none;
  height: 9px;
  margin-top: 4px;
  transition: transform .2s ease, color .15s;
  width: 9px;
}

.bpm-item > button:hover .bpm-chev { color: var(--navy); }
.bpm-item.is-open .bpm-chev { color: var(--navy); transform: rotate(180deg); }

/* --------------------------------------------------------------------------
   Blocco destro: dropdown Software + azioni
   -------------------------------------------------------------------------- */
.bpm-right { display: flex; flex: none; gap: 12px; list-style: none; margin: 0; padding: 0; }
/* il <li> è il flex item: va lui centrato, non il bottone che contiene */
.bpm-right > li { align-items: center; display: flex; }

.bpm-item-soft > button { align-items: center; padding: 16px 14px; }
.bpm-item-soft .bpm-lbl .bpm-up { font-size: 13px; letter-spacing: .12em; }
.bpm-item-soft .bpm-chev { margin-top: 0; }
.bpm-item-soft .bpm-dd { left: auto; min-width: 268px; padding: 10px 0; right: 0; }

/* --------------------------------------------------------------------------
   Bottoni della testata
   -------------------------------------------------------------------------- */
.bpm-btn {
  align-items: center;
  border: 1.5px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  gap: 8px;
  padding: 11px 18px;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}

.bpm-btn-primary { background: var(--navy); color: #fff; }
.bpm-btn-primary:hover, .bpm-btn-primary:focus { background: var(--navy-deep); color: #fff; text-decoration: none; }

.bpm-btn-secondary { background: transparent; border-color: var(--navy); color: var(--navy); }
.bpm-btn-secondary:hover, .bpm-btn-secondary:focus { background: var(--navy); color: #fff; text-decoration: none; }

/* Il link "Contatti" è iniettato da 123formbuilder: lo stiliamo dall'esterno */
.bpm-contatti a {
  align-items: center;
  border: 1.5px solid var(--navy);
  border-radius: 4px;
  color: var(--navy);
  display: inline-flex;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.bpm-contatti a:hover, .bpm-contatti a:focus { background: var(--navy); color: #fff; text-decoration: none; }

/* --------------------------------------------------------------------------
   Pannelli dropdown
   -------------------------------------------------------------------------- */
.bpm-dd {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 6px 6px;
  border-top: 3px solid var(--yellow);
  box-shadow: 0 20px 40px rgba(21, 42, 78, .14);
  left: 8px;
  max-width: 420px;
  min-width: 340px;
  opacity: 0;
  padding: 22px 26px 20px;
  position: absolute;
  top: calc(100% + 1px);
  transform: translateY(-6px);
  /* visibility senza durata: in apertura è subito visibile (quindi focusabile),
     in chiusura si nasconde solo a dissolvenza finita */
  transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
  visibility: hidden;
  z-index: 4;
}

.bpm-item.is-open > .bpm-dd {
  opacity: 1;
  transform: translateY(0);
  transition: opacity .18s ease, transform .18s ease, visibility 0s;
  visibility: visible;
}

.bpm-dd .bpm-dd-t {
  color: var(--navy-deep);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin: 0;
}

.bpm-links {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.bpm-dd.bpm-only-sub { padding: 10px 26px 12px; }
.bpm-dd.bpm-only-sub .bpm-links { border-top: 0; margin-top: 0; }

.bpm-links li { margin: 0; }

.bpm-links a {
  align-items: center;
  border-bottom: 1px solid var(--line);
  border-radius: 3px;
  color: var(--navy-deep);
  display: flex;
  font-size: 15px;
  font-weight: 600;
  gap: 10px;
  margin: 0 -10px 0 -4px;
  padding: 11px 10px 11px 4px;
  transition: background .14s, color .14s, padding .14s;
}

.bpm-links li:last-child a { border-bottom: 0; }

.bpm-links a::before {
  color: var(--pale-blue);
  content: "\203A";
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 15px;
  transition: transform .14s, color .14s;
}

.bpm-links a:hover, .bpm-links a:focus-visible {
  background: var(--sky-soft);
  color: var(--navy);
  padding-left: 10px;
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.bpm-links a:hover::before, .bpm-links a:focus-visible::before { color: var(--navy); transform: translateX(2px); }

.bpm-item-soft .bpm-links a { border-radius: 0; font-size: 14.5px; margin: 0; padding: 10px 20px; }
.bpm-item-soft .bpm-links a:hover, .bpm-item-soft .bpm-links a:focus-visible { padding-left: 26px; }

/* Le ultime voci aprono verso sinistra per non uscire dal viewport */
.bpm-menu .bpm-item:nth-child(4) > .bpm-dd,
.bpm-menu .bpm-item:nth-child(5) > .bpm-dd { left: auto; right: 8px; }

/* --------------------------------------------------------------------------
   Toggle mobile
   -------------------------------------------------------------------------- */
.bpm-toggle {
  align-items: center;
  align-self: center;
  appearance: none;
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  color: var(--navy);
  cursor: pointer;
  display: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  gap: 9px;
  padding: 9px 13px;
}

.bpm-toggle:hover { background: var(--sky-soft); border-color: var(--navy); }
.bpm-toggle .bpm-bars { display: block; height: 11px; position: relative; width: 17px; }

.bpm-toggle .bpm-bars i {
  background: var(--navy);
  height: 2px;
  left: 0;
  position: absolute;
  transition: transform .2s ease, opacity .2s ease;
  width: 100%;
}

.bpm-toggle .bpm-bars i:nth-child(1) { top: 0; }
.bpm-toggle .bpm-bars i:nth-child(2) { top: 4.5px; }
.bpm-toggle .bpm-bars i:nth-child(3) { top: 9px; }
.bpm-toggle[aria-expanded="true"] .bpm-bars i:nth-child(1) { transform: translateY(4.5px) rotate(45deg); }
.bpm-toggle[aria-expanded="true"] .bpm-bars i:nth-child(2) { opacity: 0; }
.bpm-toggle[aria-expanded="true"] .bpm-bars i:nth-child(3) { transform: translateY(-4.5px) rotate(-45deg); }

/* --------------------------------------------------------------------------
   Velo che stacca il pannello aperto dalla pagina
   -------------------------------------------------------------------------- */
.bpm-scrim {
  background: rgba(21, 42, 78, .34);
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity .18s ease, visibility .18s;
  visibility: hidden;
  z-index: 1020;
}

body.bpm-any-open .bpm-scrim { opacity: 1; visibility: visible; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Desktop stretto: comprime le voci prima di passare al drawer */
@media (max-width: 1279px) {
  .bpm-nav { gap: 12px; padding: 0 20px; }
  .bpm-item > button { padding: 16px 10px 14px; }
  .bpm-lbl .bpm-lo { font-size: 15px; }
  .bpm-lbl .bpm-up { font-size: 11px; letter-spacing: .1em; }
  .bpm-dd { min-width: 300px; }
}

/* Tablet / mobile: drawer a fisarmonica */
@media (max-width: 1079px) {
  html { scroll-padding-top: 72px; }
  body { padding-top: 60px; }
  .bpm-nav { align-items: center; flex-wrap: wrap; gap: 0; padding: 0 18px; }
  .bpm-brand { margin-right: auto; padding: 12px 0; }
  .bpm-toggle { display: inline-flex; }

  .bpm-panel {
    border-top: 1px solid var(--line);
    display: none;
    flex: none;
    flex-basis: 100%;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    padding-bottom: 18px;
    width: 100%;
  }

  .bpm-nav.is-open .bpm-panel { display: block; }

  .bpm-menu, .bpm-right, .bpm-right > li { display: block; flex: none; }
  .bpm-item { display: block; }

  .bpm-item > button,
  .bpm-item-soft > button {
    align-items: center;
    border-bottom: 1px solid var(--line);
    justify-content: space-between;
    padding: 15px 4px;
    width: 100%;
  }

  .bpm-item.is-open > button { border-bottom-color: var(--navy); }
  .bpm-lbl { align-items: baseline; flex-direction: row; gap: 8px; }
  .bpm-lbl .bpm-lo { margin-top: 0; }
  .bpm-chev { height: 11px; margin-top: 0; width: 11px; }

  /* Il pannello diventa contenuto in linea, non più sovrapposto */
  .bpm-dd,
  .bpm-item-soft .bpm-dd,
  .bpm-menu .bpm-item:nth-child(4) > .bpm-dd,
  .bpm-menu .bpm-item:nth-child(5) > .bpm-dd {
    background: var(--sky-soft);
    border: 0;
    border-left: 3px solid var(--yellow);
    border-radius: 0;
    box-shadow: none;
    display: none;
    left: auto;
    margin: 0 0 4px;
    max-width: none;
    min-width: 0;
    opacity: 1;
    padding: 14px 16px;
    position: static;
    right: auto;
    transform: none;
    transition: none;
    visibility: visible;
  }

  /* Specificita' allineata a quella della regola :nth-child(4)/(5) qui sopra,
     altrimenti i dropdown di Monitora e Risorse restano display:none su mobile */
  .bpm-menu .bpm-item.is-open > .bpm-dd,
  .bpm-right .bpm-item.is-open > .bpm-dd,
  .bpm-item.is-open > .bpm-dd { display: block; }
  .bpm-dd .bpm-dd-t { font-size: 18px; }
  .bpm-links { border-top-color: #CFE3EF; }
  .bpm-links a, .bpm-item-soft .bpm-links a { border-bottom-color: #CFE3EF; font-size: 15px; margin: 0; padding: 11px 4px; }

  .bpm-right > li { margin-top: 14px; }
  .bpm-right .bpm-btn,
  .bpm-contatti a { display: flex; justify-content: center; padding: 13px 18px; }

  .bpm-scrim { display: none; }
}

@media (max-width: 479px) {
  .bpm-brand .bpm-wm { font-size: 16px; }
  .bpm-brand svg { height: 28px; width: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .bpm-header *, .bpm-scrim { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
