/* ======================================================================
   FHP HR Suite — Organigramma / Anagrafica / Import CSS
   Estende app.css esistente con componenti specifici dei nuovi moduli
   ====================================================================== */

/* Sidebar sections */
.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  padding: 12px 16px 6px 16px;
  margin-top: 8px;
}
.nav-section-label:first-child { margin-top: 0; }

/* ======================================================================
   PAGINA ORGANIGRAMMA
   ====================================================================== */

.org-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}
.org-toolbar select,
.org-toolbar input {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
}
.org-toolbar .toolbar-label {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}

.org-canvas {
  background: #fafbfc;
  width: 100%;
  height: calc(100vh - 180px);
  overflow: auto;
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.org-canvas svg {
  min-width: 100%;
  min-height: 100%;
}

/* D3.js tree nodes */
.node {
  cursor: pointer;  /* v1.0.6.4: click per collassa/espandi sottoramo */
}
.node rect {
  fill: #fff;
  stroke: #003da8;
  stroke-width: 1.5;
  rx: 6;
}
.node.highlighted rect { stroke: #f59e0b; stroke-width: 2.5; }
.node.vacant rect { stroke: #dc2626; stroke-dasharray: 4 4; }
.node.manager rect { fill: #f0f7ff; }
/* v1.0.6.4: nodo con figli nascosti (collassato) */
.node.node-collapsed rect {
  fill: #fef3c7;          /* giallo chiaro — "c'è roba sotto" */
  stroke: #d97706;
  stroke-width: 2;
}
.node-name {
  font-weight: 600;
  text-anchor: middle;
  font-size: 11px;
  fill: #0f172a;
}
.node-role {
  text-anchor: middle;
  font-size: 10px;
  fill: #64748b;
}
.node-badge {
  text-anchor: middle;
  font-size: 9px;
  font-weight: 700;
  fill: #d97706;
}
.node text {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  fill: #0f172a;
}
.node text.role {
  font-size: 10.5px;
  fill: #64748b;
}
.node text.entity {
  font-size: 9.5px;
  fill: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}
.link {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 1.5;
}
.link.functional {
  stroke-dasharray: 4 3;
  stroke: #94a3b8;
}

/* ======================================================================
   PAGINA ANAGRAFICA
   ====================================================================== */

.anag-toolbar {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
  align-items: center;
}
.anag-toolbar input[type="text"] {
  min-width: 280px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
}
.anag-toolbar select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}

.anag-stats {
  display: flex;
  gap: 16px;
  padding: 16px 24px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.stat-chip {
  background: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  min-width: 140px;
}
.stat-chip .stat-value {
  font-size: 22px;
  font-weight: 600;
  color: #003da8;
  font-family: 'JetBrains Mono', monospace;
}
.stat-chip .stat-label {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.anag-table-wrap {
  padding: 16px 24px;
  overflow-x: auto;
}
.anag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}
.anag-table thead {
  background: #f1f5f9;
}
.anag-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: #0f172a;
  border-bottom: 1px solid #e5e7eb;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.anag-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}
.anag-table tbody tr:hover {
  background: #f8fafc;
  cursor: pointer;
}
.anag-table .codifica {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: #64748b;
}
.anag-table .badge-inactive {
  display: inline-block;
  background: #fee2e2;
  color: #b91c1c;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.anag-table .badge-cessazione {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

/* ======================================================================
   PAGINA IMPORT ZUCCHETTI
   ====================================================================== */

.import-wizard {
  max-width: 920px;
  margin: 24px auto;
  padding: 0 24px;
}
.import-step {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 16px;
}
.import-step h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #0f172a;
}
.import-step .step-desc {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 16px;
}

.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 40px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: #003da8;
  background: #eff6ff;
}
.drop-zone .dz-icon {
  font-size: 40px;
  color: #94a3b8;
  margin-bottom: 10px;
}
.drop-zone .dz-title {
  font-size: 16px;
  font-weight: 500;
  color: #0f172a;
}
.drop-zone .dz-sub {
  color: #64748b;
  font-size: 13px;
  margin-top: 4px;
}

.preview-panel {
  background: #f8fafc;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}
.preview-panel h4 {
  margin: 0 0 10px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
}
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.preview-grid .pv-item {
  background: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
}
.preview-grid .pv-item .pv-label {
  color: #64748b;
  font-size: 10.5px;
  text-transform: uppercase;
}
.preview-grid .pv-item .pv-value {
  font-weight: 600;
  color: #0f172a;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
}

.anomalie-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
}
.anomalia-row {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12.5px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.anomalia-row:last-child { border-bottom: none; }
.anomalia-row .gravita-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}
.gravita-error { background: #fee2e2; color: #b91c1c; }
.gravita-warning { background: #fef3c7; color: #92400e; }

.import-history-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  font-size: 13px;
}
.import-history-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #0f172a;
}
.import-history-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
}

/* Page titles shared across new pages */
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px 24px;
}
.page-title h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #0f172a;
}
.page-title .subtitle {
  color: #64748b;
  font-size: 13px;
  margin-top: 2px;
}

/* ======================================================================
   EXPORT MENU (v1.0.2) — Dropdown Esporta nell'Organigramma
   ====================================================================== */

.export-menu-wrapper {
  position: relative;
  display: inline-block;
}

.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 280px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 6px 0;
  z-index: 1000;
  max-height: 540px;
  overflow-y: auto;
  white-space: nowrap;
}

.export-menu a {
  display: block;
  padding: 8px 16px;
  color: #0f172a;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.1s;
}

.export-menu a:hover {
  background: #f1f5f9;
  color: #003da8;
}

.export-menu-section {
  padding: 10px 16px 4px 16px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
}

.export-menu-section:first-child {
  border-top: none;
  padding-top: 4px;
}

/* ======================================================================
   v1.0.6.5 — Level stepper (toolbar) + toggle button (box)
   ====================================================================== */

/* Stepper +/- per livelli gerarchici */
.level-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #f8fafc;
  border: 1px solid #d1d5db;
  border-radius: 6px;
}
.level-stepper .btn-step {
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #003da8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.level-stepper .btn-step:hover {
  background: #003da8;
  color: #fff;
  border-color: #003da8;
}
.level-stepper .btn-step:active {
  transform: translateY(1px);
}
.level-stepper .level-label {
  font-size: 12px;
  color: #475569;
  font-family: 'JetBrains Mono', monospace;
  min-width: 75px;
  text-align: center;
}

/* Toggle button sul box del nodo (cerchio cliccabile sotto il rect) */
.node-toggle {
  cursor: pointer;
}
.node-toggle circle {
  fill: #fff;
  stroke: #003da8;
  stroke-width: 1.5;
  transition: fill 0.15s, stroke 0.15s;
}
.node-toggle:hover circle {
  fill: #003da8;
  stroke: #003da8;
}
.node-toggle .node-toggle-icon {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 700;
  fill: #003da8;
  pointer-events: none;  /* click passa al g padre */
  user-select: none;
}
.node-toggle:hover .node-toggle-icon {
  fill: #fff;
}
/* Nodi collassati: cerchio arancione per matching con badge */
.node.node-collapsed .node-toggle circle {
  stroke: #d97706;
  fill: #fef3c7;
}
.node.node-collapsed .node-toggle .node-toggle-icon {
  fill: #d97706;
}
.node.node-collapsed .node-toggle:hover circle {
  fill: #d97706;
}
.node.node-collapsed .node-toggle:hover .node-toggle-icon {
  fill: #fff;
}
