/* ============================================= */
/* FLUXOGRAMA DE PRODUÇÃO                         */
/* ============================================= */

.fx-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.fx-toolbar h2 { margin: 0 0 .25rem; font-size: 1.3rem; }
.fx-subtitle { margin: 0; color: var(--text2, #94a3b8); font-size: .85rem; max-width: 560px; }
.fx-toolbar-actions { display: flex; gap: .5rem; }

.fx-tabs {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border, #334155);
  padding-bottom: .75rem;
}
.fx-tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border, #334155);
  background: var(--bg2, #1e293b);
  color: var(--text2, #94a3b8);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.fx-tab:hover { border-color: var(--orange, #f97316); }
.fx-tab-active {
  background: var(--orange, #f97316);
  border-color: var(--orange, #f97316);
  color: #fff;
}

.fx-loading, .fx-error {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text2, #94a3b8);
  font-size: .95rem;
}
.fx-error { color: var(--red, #ef4444); }

.fx-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.fx-summary-item {
  background: var(--bg2, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.fx-summary-label { font-size: .78rem; color: var(--text2, #94a3b8); text-transform: uppercase; letter-spacing: .03em; }
.fx-summary-value { font-size: 1.4rem; font-weight: 800; color: var(--orange, #f97316); }

/* ---------- Fluxo em coluna, tipo fluxograma real ---------- */
.fx-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 520px;
  margin: 0 auto;
}
.fx-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.fx-node {
  min-width: 240px;
  text-align: center;
  padding: .9rem 1.25rem;
  font-weight: 700;
  font-size: .92rem;
}

/* Início / Fim: oval */
.fx-node-terminal {
  background: var(--bg2, #1e293b);
  border: 2px solid var(--orange, #f97316);
  border-radius: 999px;
  color: var(--orange, #f97316);
  padding: .8rem 1.5rem;
}

/* Setores: retângulo */
.fx-node-sector {
  background: var(--bg2, #1e293b);
  border: 2px solid var(--border, #334155);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.fx-node-empty { opacity: .5; border-style: dashed; cursor: default; }
.fx-node-liberacao {
  border-color: var(--border, #334155);
  cursor: default;
}
.fx-node-liberacao .fx-node-count { font-style: italic; }
.fx-node-clickable {
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.fx-node-clickable:hover,
.fx-node-clickable:focus-visible {
  border-color: var(--orange, #f97316);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(249, 115, 22, .25);
  outline: none;
}
.fx-node-clickable:active { transform: translateY(0); }

/* Bifurcação (fork): dois ou mais caminhos lado a lado */
.fx-fork {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}
.fx-fork-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 220px;
  max-width: 260px;
  padding: .75rem;
  border: 1px dashed var(--border, #334155);
  border-radius: 12px;
}

.fx-node-branch { border-style: dashed; }
.fx-branch-label {
  font-size: .72rem;
  color: var(--orange, #f97316);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: .35rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.fx-step-note {
  font-size: .72rem;
  color: var(--text2, #94a3b8);
  font-style: italic;
  text-align: center;
  max-width: 260px;
  margin-top: .35rem;
}

.fx-node-label { font-weight: 700; font-size: .92rem; }
.fx-node-time { font-size: 1.2rem; font-weight: 800; color: var(--orange, #f97316); }
.fx-node-count { font-size: .72rem; color: var(--text2, #94a3b8); font-weight: 500; }

/* Conector vertical entre os nós */
.fx-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text2, #94a3b8);
  height: 34px;
  justify-content: flex-end;
}
.fx-connector-line {
  width: 2px;
  flex: 1;
  background: var(--border, #334155);
}
.fx-connector i { font-size: .85rem; margin-top: -2px; }

.fx-note {
  margin-top: 1.25rem;
  font-size: .8rem;
  color: var(--text2, #94a3b8);
  text-align: center;
}
.fx-print-footer { display: none; }

/* ---------- Drill-down (modal de detalhamento do setor) ---------- */
.fx-drill-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.fx-drill-stat {
  background: var(--bg2, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  padding: .75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.fx-drill-stat-label { font-size: .72rem; color: var(--text2, #94a3b8); text-transform: uppercase; letter-spacing: .02em; }
.fx-drill-stat-value { font-size: 1.15rem; font-weight: 800; }

.fx-drill-table-wrap { overflow-x: auto; overflow-y: auto; max-height: 50vh; border: 1px solid var(--border, #334155); border-radius: 10px; }
.fx-drill-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.fx-drill-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg2, #1e293b);
  z-index: 1;
}
.fx-drill-table th {
  text-align: left;
  padding: .5rem .6rem;
  color: var(--text2, #94a3b8);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  border-bottom: 1px solid var(--border, #334155);
}
.fx-drill-table td {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border, #334155);
  white-space: nowrap;
}
.fx-td-right { text-align: right; }
.fx-drill-more { margin-top: .6rem; font-size: .78rem; color: var(--text2, #94a3b8); }

/* ============================================= */
/* IMPRESSÃO — só o fluxograma, formatado pra A4  */
/* ============================================= */
@media print {
  body * { visibility: hidden; }
  #pageFluxograma, #pageFluxograma * { visibility: visible; }
  #pageFluxograma {
    position: absolute;
    inset: 0;
    background: #fff !important;
    color: #111 !important;
    padding: 1.5cm;
  }
  .fx-toolbar-actions { display: none !important; }
  .fx-subtitle { color: #444 !important; }
  .fx-tabs { border-color: #ccc !important; }
  .fx-tab { display: none !important; }
  .fx-tab-active {
    display: inline-flex !important;
    background: #fff !important;
    color: #c2410c !important;
    border-color: #c2410c !important;
  }
  .fx-branch-label { color: #c2410c !important; }
  .fx-step-note { color: #555 !important; }
  .fx-summary-item {
    background: #f3f4f6 !important;
    border-color: #ccc !important;
  }
  .fx-summary-label { color: #555 !important; }
  .fx-summary-value { color: #c2410c !important; }
  .fx-node-terminal { color: #c2410c !important; border-color: #c2410c !important; background: #fff !important; }
  .fx-node-sector {
    background: #fff !important;
    border-color: #333 !important;
    break-inside: avoid;
  }
  .fx-node-time { color: #c2410c !important; }
  .fx-node-count, .fx-note { color: #555 !important; }
  .fx-connector-line { background: #333 !important; }
  .fx-connector { color: #333 !important; }
  .fx-fork-branch { border-color: #999 !important; break-inside: avoid; }
  .fx-print-footer {
    display: block;
    margin-top: 2rem;
    font-size: .75rem;
    color: #666 !important;
    text-align: right;
  }
}

@media (max-width: 768px) {
  .fx-node { min-width: 0; width: 100%; }
  .fx-flow { max-width: 100%; }
  .fx-fork { flex-direction: column; align-items: center; }
  .fx-fork-branch { max-width: 100%; width: 100%; }
}
