/* Componenti condivisi: card, KPI, tabelle, badge, bottoni, form, modali,
   kanban, timeline, toast. Geometria e scala tipografica prese dal mockup. */

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-pad { padding: 16px 18px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { flex: 1; font-size: 13.5px; font-weight: 600; }

/* ---- KPI ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi .kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  text-transform: none;
  letter-spacing: 0;
}
.kpi .kpi-value {
  font: 600 26px/1 'IBM Plex Sans', system-ui, sans-serif;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .kpi-note { font-size: 11.5px; color: var(--text3); }
.kpi .up { color: var(--pos); font-weight: 600; }
.kpi .down { color: var(--neg); font-weight: 600; }

/* ---- Tabelle ---- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th:first-child, table.data td:first-child { padding-left: 16px; }
table.data th:last-child, table.data td:last-child { padding-right: 16px; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr { transition: background var(--t-fast) var(--ease); }
table.data tbody tr.clickable:hover { background: var(--row-hover); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
table.data th.num { text-align: right; }
/* nelle liste il .mono è sempre il codice della riga (TW-…, AST-…, RR-…):
   nel mockup è il riferimento cliccabile, quindi mono e in accento */
table.data .mono {
  font: 500 12px 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--accent);
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text3);
  border-top: 1px solid var(--border);
}
.pager .grow { flex: 1; }
.pager button {
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  font: 500 12px inherit;
  font-family: inherit;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.pager button:disabled { opacity: .4; cursor: default; }
.pager button:not(:disabled):hover { background: var(--surface2); color: var(--text); }

/* ---- Badge di stato ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  white-space: nowrap;
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge.ok      { background: var(--pos-soft); color: var(--pos); }
.badge.warn    { background: var(--warn-soft); color: var(--warn); }
.badge.danger  { background: var(--neg-soft); color: var(--neg); }
.badge.info    { background: var(--accent-soft); color: var(--accent); }
.badge.accent  { background: var(--accent-soft); color: var(--accent); }
.badge.neutral { background: var(--surface2); color: var(--text2); }

.tag {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 11.5px;
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
}
/* certificazioni mostrate tra le competenze: derivano dal box Certificazioni */
.tag.cert { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.tag.cert.expired { background: var(--neg-soft); border-color: transparent; color: var(--neg); }
.tag .lvl { color: var(--text3); font-size: 10px; margin-left: 5px; text-transform: uppercase; letter-spacing: .05em; }

/* ---- Bottoni ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 12px 'IBM Plex Sans', system-ui, sans-serif;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface2); color: var(--text); }
.btn.primary {
  font-weight: 600;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn.danger { color: var(--neg); border-color: var(--border); }
.btn.danger:hover { background: var(--neg-soft); border-color: var(--neg-soft); color: var(--neg); }
.btn.sm { padding: 4px 9px; font-size: 11.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:disabled:hover { background: none; color: var(--text2); }
.btn svg { width: 13px; height: 13px; flex: none; }

/* ---- Form ---- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 12.5px;
  padding: 7px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--border-strong); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* campo file (CV del candidato, allegati): il bottone nativo prende l'aspetto
   di un .btn secondario, il resto del controllo resta un input come gli altri */
.field input[type="file"] { padding: 6px 10px; cursor: pointer; }
.field input[type="file"]::file-selector-button {
  font-family: inherit;
  font: 500 12px 'IBM Plex Sans', system-ui, sans-serif;
  margin-right: 10px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.field input[type="file"]::file-selector-button:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border-strong);
}

.field .ferr { color: var(--neg); font-size: 11.5px; margin-top: 4px; background: none; border: none; padding: 0; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline label { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: span 1; } }

/* ---- Modale ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  z-index: 200;
  overflow-y: auto;
  animation: fadeIn var(--t-fast) var(--ease) both;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 560px;
  max-width: 100%;
  /* popIn: la stessa entrata del mockup, definita in css/motion.css */
  animation: popIn 240ms var(--ease-out) both;
}
.modal.wide { width: 760px; }
.modal-head {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { flex: 1; font-size: 13.5px; font-weight: 600; }
.modal-body { padding: 18px 16px; max-height: 65vh; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px;
  transition: color var(--t-fast) var(--ease);
}
.modal-close:hover { color: var(--text); }

/* ---- Toast ---- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  min-width: 240px;
  max-width: 380px;
  animation: toastIn 300ms var(--ease-out) both;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toast.ok { border-left-color: var(--pos); }
.toast.error { border-left-color: var(--neg); }
.toast-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0;
  line-height: 0;
  margin-left: auto;
  flex: 0 0 auto;
  transition: color var(--t-fast) var(--ease);
}
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 13px; height: 13px; }
/* ---- Kanban ---- */
.kanban { display: flex; gap: 14px; overflow-x: auto; align-items: flex-start; padding-bottom: 8px; }
.kanban-col {
  flex: 0 0 270px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.kanban-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  padding: 4px 6px 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.kanban-col-head .count {
  margin-left: auto;
  font: 600 10.5px 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--text3);
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 12.5px;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.kanban-card:hover { border-color: var(--border-strong); background: var(--row-hover); }

/* ---- Timeline workflow onboarding ---- */
.timeline { padding: 6px 16px 14px; }
.tl-item { display: flex; gap: 12px; position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 4px; }
.tl-item::before {
  content: '';
  position: absolute;
  left: 11px; top: 24px; bottom: 0;
  width: 1px;
  background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  flex: 0 0 23px;
  width: 23px; height: 23px;
  border-radius: 50%;
  display: grid; place-items: center;
  font: 600 10.5px 'IBM Plex Mono', ui-monospace, monospace;
  background: var(--surface2); color: var(--text3);
  border: 1px solid var(--border);
  z-index: 1;
}
.tl-item.done .tl-dot { background: var(--pos-soft); color: var(--pos); border-color: var(--pos); }
.tl-item.ko .tl-dot { background: var(--neg-soft); color: var(--neg); border-color: var(--neg); }
.tl-item.current .tl-dot { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tl-body { flex: 1; padding-top: 2px; min-width: 0; }
.tl-title { font-weight: 600; font-size: 12.5px; }
.tl-item.current .tl-title { color: var(--accent); }
.tl-meta { font-size: 11.5px; color: var(--text3); margin-top: 2px; }
.tl-note {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
  background: var(--surface2);
  border-radius: var(--radius-xs);
  padding: 6px 9px;
}

/* ---- Utility ---- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--text2); }
.small { font-size: 11.5px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1000px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.empty {
  text-align: center;
  color: var(--text3);
  padding: 42px 20px;
  font-size: 12.5px;
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 60px auto;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Form a pagina intera (nuovo/modifica dipendente e candidato) ---- */
.form-page { display: flex; flex-direction: column; gap: 16px; max-width: 1000px; }
.form-page .page-head { margin-bottom: 0; }
.form-page .card-pad .field:last-child { margin-bottom: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* messaggio di errore del form (in modale e a pagina intera) */
.ferr {
  color: var(--neg);
  font-size: 12.5px;
  background: var(--neg-soft);
  border: 1px solid var(--neg);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
/* avviso in testa a una vista (es. schema del database non ancora migrato) */
.banner-warn {
  border: 1px solid var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 16px;
}
