/* Il gruppo di scelte (components/_choice_group), in due aspetti perché si capisca cosa si sceglie:
   - radio: un blocco a segmenti uniti (se ne sceglie uno), quello scelto pieno nel blu dei
     bottoni principali;
   - checkbox: spunte col quadratino, che si aggiungono a quello che c'è; spuntate prendono il
     colore della scelta (rosso gli insoluti, arancio i segnalati). Angoli come i bottoni dell'app. */

.choice-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.choice-group__caption {
  flex: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--app-muted);
}

.choice-group__options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.choice-group__option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--touch);
  padding: 0 0.875rem;
  border: 1px solid var(--app-border);
  border-radius: var(--radius);
  color: var(--app-ink);
  cursor: pointer;
  background: var(--app-surface);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.choice-group__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-group__text {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
}

.choice-group__label {
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
}

.choice-group__hint {
  font-size: 0.8125rem;
  white-space: nowrap;
  color: var(--app-muted);
}

.choice-group__count {
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--app-muted);
}

.choice-group__option:has(:focus-visible) {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

/* Radio: segmenti uniti in un blocco solo. */
.choice-group--radio .choice-group__options {
  flex-wrap: nowrap;
  gap: 0;
}

.choice-group--radio .choice-group__option {
  border-radius: 0;
}

.choice-group--radio .choice-group__option + .choice-group__option {
  margin-left: -1px;
}

.choice-group--radio .choice-group__option:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.choice-group--radio .choice-group__option:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Il passaggio del mouse come in tutta l'app (application.css): la voce grigia diventa blu su azzurro
   chiaro; solo dove c'è un mouse. */
.with-mouse .choice-group--radio .choice-group__option:hover {
  color: var(--app-accent);
  background: var(--app-accent-faint);
}

.choice-group--radio .choice-group__option:has(:checked) {
  z-index: 1;
  border-color: var(--app-accent);
  color: var(--app-on-color);
  background: var(--app-accent);
}

.choice-group--radio .choice-group__option:has(:checked) .choice-group__count,
.choice-group--radio .choice-group__option:has(:checked) .choice-group__hint {
  color: rgba(255, 255, 255, 0.8);
}

/* Checkbox: il quadratino da spuntare, nel colore della scelta quando è spuntato. */
.choice-group--checkbox .choice-group__option {
  --tone: var(--app-accent);
  --tone-faint: var(--app-accent-faint);
}

.choice-group--checkbox .choice-group__option--danger {
  --tone: var(--app-danger);
  --tone-faint: var(--app-danger-faint);
}

.choice-group--checkbox .choice-group__option--warning {
  --tone: var(--app-warning);
  --tone-faint: var(--app-warning-faint);
}

.with-mouse .choice-group--checkbox .choice-group__option:hover {
  border-color: var(--tone);
}

.choice-group__box {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 1.5px solid var(--app-border-strong);
  border-radius: var(--radius-sm);
  color: transparent;
  background: var(--app-surface);
}

.choice-group__box .icon {
  width: 0.875rem;
  height: 0.875rem;
}

.choice-group--checkbox .choice-group__option:has(:checked) {
  border-color: var(--tone);
  color: var(--tone);
  background: var(--tone-faint);
}

.choice-group--checkbox .choice-group__option:has(:checked) .choice-group__box {
  border-color: var(--tone);
  color: var(--app-on-color);
  background: var(--tone);
}

.choice-group--checkbox .choice-group__option:has(:checked) .choice-group__count {
  color: var(--tone);
}

/* Tablet in verticale (23/10/2026: lo «Stato» dei clienti usciva di 44 px dal bordo): i segmenti si
   dividono la riga e si stringono, restano alti da toccare. */
@media (max-width: 900px) {
  .choice-group--radio {
    flex: 1 1 100%;
  }

  .choice-group--radio .choice-group__options {
    flex: 1;
    min-width: 0;
  }

  .choice-group--radio .choice-group__option {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0 0.5rem;
  }

  .choice-group--radio .choice-group__label {
    font-size: 0.875rem;
  }

  .choice-group--radio .choice-group__text {
    gap: 0.25rem;
  }
}

/* La taglia piccola: alta come un bottone Small, per il Segmented nel titolo di una sezione («Ieri |
   Questo mese» in Home, «Da proporre | Già da noi» nel menu). Prima erano schede a mano con dei radio. */
.choice-group--small .choice-group__option {
  min-height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.75rem;
}

.choice-group--small .choice-group__count {
  font-size: 0.75rem;
}
