/* =========================================================
   Personale: info-disclosure, section card, kpi, table search,
   sticky filter, calendar a11y, landing nav cards.
   Pure CSS, consumes the Registro semantic tokens directly
   (--accent-fill/-ink/-soft, --on-accent, --st-*). Per-area accent colour
   is retired (docs/ui/DESIGN_CONTRACT.md §2) — wayfinding comes from the
   active nav fill and the page title, not per-module hue.
   ========================================================= */

/* --- Info-section: collassabile, zero-JS, accessibile (§2 del contratto).
   Stesso pattern <details>/<summary> di .info / .export-menu: il marker
   nativo è nascosto e sostituito da un chevron coerente. --------------- */
.info-disclosure {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: var(--sp-5);
  font-size: var(--text-sm);
}
.info-disclosure__summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 600;
  color: var(--accent-ink);
  border-radius: var(--radius);
}
.info-disclosure__summary::-webkit-details-marker { display: none; }
/* Chevron a destra, ruota all'apertura (coerente con le altre disclosure). */
.info-disclosure__summary::after {
  content: "";
  margin-left: auto;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--motion) var(--ease);
  flex-shrink: 0;
}
.info-disclosure[open] > .info-disclosure__summary::after {
  transform: rotate(-135deg);
}
.info-disclosure__summary:focus-visible {
  outline: 2px solid var(--accent-fill);
  outline-offset: 2px;
}
.info-disclosure__icon {
  font-size: 1.05em;
  line-height: 1;
  color: var(--accent-ink);
}
.info-disclosure__body {
  padding: var(--sp-1) var(--sp-4) var(--sp-4);
  color: var(--color-text);
}
.info-disclosure__body p { margin: 0 0 var(--sp-3); }
.info-disclosure__body p:last-child { margin-bottom: 0; }
.info-disclosure__h {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent-ink);
  margin: var(--sp-3) 0 var(--sp-1);
}
.info-disclosure__body > .info-disclosure__h:first-child { margin-top: 0; }

/* --- Section card: contenitore con header (titolo + azioni a destra).
   Riusa .info-card come superficie di base. ----------------------------- */
.personale-section { margin-bottom: var(--sp-5); }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.section-head__title {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  color: var(--color-text);
}
.section-head__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* The generic stat strip is intentionally an inline ledger row. Five HR
   queues, however, become a visual word-salad when flex-wrap splits a label
   from its number on a phone. The cockpit owns a small two-column grid below
   640px, keeping every label and count in one stable tap target. */
@media (max-width: 639px) {
  .personale-cockpit__metrics .stat-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
  }
  .personale-cockpit__metrics .stat-strip__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
    min-width: 0;
    min-height: 5.25rem;
    padding: var(--sp-3);
    border: 0;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
  }
  .personale-cockpit__metrics .stat-strip__item:last-child {
    grid-column: 1 / -1;
  }
  .personale-cockpit__metrics .stat-strip__label {
    overflow-wrap: anywhere;
  }
}

/* Personale forms share the same compact ledger labels as the rest of the
   product. Most of these forms use wrapping labels for no-JS accessibility,
   so scope the treatment to this area rather than duplicating form markup. */
.personale-section .form-grid > label {
  gap: var(--sp-1);
  font-size: 0.66rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

/* --- Generator pairs (monthly / yearly, import / export, etc.).
   One outer section owns the context; its two actions become clearly distinct
   panels with a shared responsive grid. This avoids a stack of anonymous
   full-width form cards whose buttons look attached to the next form. --- */
.reminder-generator-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
}
.reminder-generator {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
  padding: var(--sp-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.reminder-generator__head h3 {
  margin: var(--sp-1) 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--text-lg);
  line-height: 1.25;
}
.reminder-generator__head p:not(.reminder-generator__eyebrow) {
  margin: var(--sp-2) 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.reminder-generator__eyebrow {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.reminder-generator .form-actions {
  margin-top: auto;
}
.reminder-generator__hint {
  margin: var(--sp-4) 0 0;
}
@media (min-width: 900px) {
  .reminder-generator-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- Ricerca tabella client-side (§3, feature JS #1). Stile coerente con
   .filter-search; resta un campo usabile anche senza JS. ----------------- */
.table-search {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.table-search__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}
.table-search__input {
  min-width: min(100%, 18rem);
  flex: 1 1 14rem;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
}
.table-search__input:focus {
  outline: none;
  border-color: var(--accent-fill);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Messaggio "0 risultati" del filtro client (#1): nodo testuale, non solo stile. */
.table-filter__empty {
  padding: var(--sp-4);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* --- Barra filtri sticky (§4, feature JS #6). Lo sticky di base è CSS;
   .is-stuck (aggiunta via IntersectionObserver) aggiunge solo l'ombra. --- */
.filter-bar--sticky {
  position: sticky;
  top: 0;
  z-index: 20;
}
.is-stuck {
  box-shadow: var(--shadow-md);
}

/* UI v3 L5: Personale's filter forms moved from the old fat .form-card
   filter-bar to the shared compact .toolbar (web/components.py
   filter_toolbar / app/personale/_components.py filter_bar). Combobox
   sizing inside .toolbar rows is now handled app-wide in forms.css. */

/* --- Utility: nascondi righe filtrate dal filtro client (#1). ----------- */
.is-hidden { display: none !important; }

/* --- Calendario: focus visibile per la navigazione da tastiera (§3 #5).
   Sia :focus-visible (tastiera) che la classe --focus (roving tabindex)
   mostrano l'anello accent, senza rimuovere l'outline di default. -------- */
.cal-day:focus-visible,
.cal-day--focus {
  outline: 2px solid var(--accent-fill);
  outline-offset: -2px;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* --- Landing personale: griglia di card di navigazione. ----------------- */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.nav-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--motion) var(--ease), box-shadow var(--motion) var(--ease), transform var(--motion) var(--ease);
}
.nav-card:hover,
.nav-card:focus-visible {
  border-color: var(--accent-fill);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
.nav-card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--accent-ink);
  margin-bottom: 0;
  width: 100%;
}
.nav-card__icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}
.nav-card > .status-chip,
.nav-card > .btn {
  align-self: flex-start;
}
.nav-card > .btn {
  margin-top: auto;
}
.nav-card > .hint {
  margin: 0;
}

/* --- Rimborsi: riepilogo e azioni mobile-friendly. --------------------- */
.rimborsi-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.rimborsi-summary .kpi-card {
  min-height: 6.25rem;
}

.rimborsi-km-box {
  grid-column: 1 / -1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  background: var(--color-surface-2);
}

.rimborsi-km-box legend {
  padding: 0 var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--accent-ink);
}

@media (max-width: 639px) {
  .personale-section .inline-form {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-2);
    align-items: stretch;
  }

  .personale-section .inline-form input,
  .personale-section .inline-form button {
    width: 100%;
  }

  .data-table--cards td.actions {
    justify-content: stretch;
    text-align: left;
  }

  .data-table--cards td.actions::before {
    display: none;
  }
}

/* Hint generico per le descrizioni sotto i controlli, fuori
   dal contesto .form-row che ha già la sua regola. Minore specificità: non
   sovrascrive .form-row .hint esistente. */
.hint {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text-muted);
}

.text-warning {
  color: var(--st-warn);
  font-weight: 600;
}

/* ── Pannello dipendente · assunzione wizard · self-service ────────────────
   Pure CSS, reuses existing design tokens. Semantic colors:
     --ok / --approvata   → st-ok (green)
     --warn / --richiesta → st-warn (amber)
     --bad  / --respinta  → st-bad  (red)
   Mirror conventions of .status-chip, .kpi-card, .info-card.
   ─────────────────────────────────────────────────────────────────────── */

/* ── Cockpit (HR pannello dipendente) ──────────────────────── */

/* Page outer shell */
.cockpit {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

/* Hero header surface */
.cockpit-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* Initials avatar + name/meta flex row */
.cockpit-hero__id {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

/* Circular avatar with worker initials */
.cockpit-hero__initials {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--accent-fill);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

.cockpit-hero__name {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  margin: 0;
}

.cockpit-hero__meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Row of status chips (mirrors .status-chip layout) */
.cockpit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

/* Individual status chip — same pill shape as .status-chip */
.cockpit-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.2em 0.65em;
  border-radius: 9999px;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid var(--st-missing-border);
  background: var(--st-missing-bg);
  color: var(--st-missing);
}

.cockpit-chip--ok {
  background: var(--st-ok-bg);
  color: var(--st-ok);
  border-color: var(--st-ok-border);
}

.cockpit-chip--warn {
  background: var(--st-warn-bg);
  color: var(--st-warn);
  border-color: var(--st-warn-border);
}

.cockpit-chip--bad {
  background: var(--st-bad-bg);
  color: var(--st-bad);
  border-color: var(--st-bad-border);
}

/* KPI card grid — mirrors .kpi-cards responsive grid */
.cockpit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: var(--sp-3);
}

/* KPI card surface — neutral panel; state (ok/warn) is a full-tint background
   (never an accent bar), reinforced by the value's status ink below. */
.cockpit-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  position: relative;
}

.cockpit-card--ok   { background: var(--st-ok-bg); border-color: var(--st-ok-border); }
.cockpit-card--warn { background: var(--st-warn-bg); border-color: var(--st-warn-border); }

/* Card label (key) */
.cockpit-card__k {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

/* Card big value — proportional sans, weight 650 (contract §3: big standalone
   numbers are NOT mono, NOT serif). */
.cockpit-card__v {
  font-size: var(--text-2xl);
  font-weight: 650;
  line-height: 1;
  color: var(--color-text);
}

.cockpit-card--ok   .cockpit-card__v { color: var(--st-ok); }
.cockpit-card--warn .cockpit-card__v { color: var(--st-warn); }

/* Optional sub-text below the value */
.cockpit-card__sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Quick-actions button/link bar */
.cockpit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

/* Individual action link/button — soft accent pill */
.cockpit-action {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent-fill);
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}

.cockpit-action:hover {
  background: color-mix(in srgb, var(--accent-soft) 65%, var(--color-surface));
  border-color: var(--accent-fill);
  text-decoration: none;
}

/* ── Onboarding checklist ────────────────────────────────────── */

.onboarding {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}

/* Heading + progress counter row */
.onboarding__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.onboarding__head h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0;
}

/* Progress bar track — §6 meter spec: 8px track, radius 2px, light step of
   the accent ramp (this is a completion meter, not a severity one, so it
   rides the "ok" pairing throughout). */
.onboarding__bar {
  height: 0.5rem;
  background: var(--accent-soft);
  border: 1px solid var(--color-border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: var(--sp-4);
}

/* Progress fill — width is set inline via style="width:N%" */
.onboarding__fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-fill);
  transition: width var(--motion-slow) var(--ease);
}

/* Checklist <ul> */
.onboarding__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Individual checklist item */
.onboarding__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  font-size: var(--text-sm);
}

/* Completed item — green tint with leading check symbol. No trailing CTA, so
   keep the check + label together on the left instead of letting
   space-between push the lone label to the far right. */
.onboarding__item--done {
  background: var(--st-ok-bg);
  border-color: var(--st-ok-border);
  color: var(--st-ok);
  justify-content: flex-start;
}

.onboarding__item--done::before {
  content: "✓";
  font-weight: 700;
  flex-shrink: 0;
}

/* CTA action button on pending item — minimal override; btn btn-sm btn-primary
   already provides full button styling */
.onboarding__cta {
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Wizard (assunzione guidata) ─────────────────────────────── */
/* The numbered-circle stepper (.wizard-steps/.wizard-step*) and the
   read-only review grid (.wizard-summary/.wizard-summary__row) are now the
   APP-WIDE wizard component defined once in static/css/forms.css (docs/ui/
   DESIGN_CONTRACT.md §4) — the hiring flow (app/anagrafica/assunzione_wizard.py)
   reuses those exact class names so the app has one stepper language. Only
   this page's own full-page card chrome stays here. */

/* Outer wizard card */
.wizard {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Step content area */
.wizard-body {
  padding: var(--sp-5) var(--sp-6);
}

/* Prev / next navigation row */
.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* ── Self-service (area-personale) ───────────────────────────── */

/* Profile field list container */
.self-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

/* Individual label / value row */
.self-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.self-row:last-child { border-bottom: none; }

.self-row strong {
  flex: 0 0 10rem;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

/* Request / modification item. State is a full-tint background + border
   (kept paired with the .status-chip rendered inside) — no accent bar. */
.self-req {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-2);
}

/* Pending / neutral — warning amber */
.self-req--richiesta {
  border-color: var(--st-warn-border);
  background: var(--st-warn-bg);
}

/* Approved — success green */
.self-req--approvata {
  border-color: var(--st-ok-border);
  background: var(--st-ok-bg);
}

/* Rejected — danger red */
.self-req--respinta {
  border-color: var(--st-bad-border);
  background: var(--st-bad-bg);
}

/* ── Responsive adjustments ──────────────────────────────────── */

@media (max-width: 639px) {
  .cockpit-hero {
    padding: var(--sp-4);
  }

  .cockpit-hero__initials {
    width: 2.5rem;
    height: 2.5rem;
    font-size: var(--text-base);
  }

  .cockpit-hero__name {
    font-size: var(--text-xl);
  }

  .cockpit-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  }

  .wizard-body {
    padding: var(--sp-4);
  }

  .wizard-nav {
    padding: var(--sp-3) var(--sp-4);
    justify-content: flex-end;
  }

  .wizard-nav .btn {
    flex: 1 1 10rem;
    justify-content: center;
  }

  .self-row {
    flex-direction: column;
    gap: var(--sp-1);
  }

  .self-row strong {
    flex: none;
  }
}

@media (min-width: 640px) {
  .cockpit-hero__initials {
    width: 3.5rem;
    height: 3.5rem;
    font-size: var(--text-xl);
  }

  .cockpit-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}
