/*
 * C3 · Anatomia del campo, C4 Textbox, S1 Select nativa (docs/ui/COMPONENTI.md). Solo token --hy-*.
 */
/* Caselle e scelte native (es. colonna "Scegli" delle griglie) nel colore d'accento invece del blu del browser (2026-10-23).
   :where() = specificità zero: le regole dei componenti (hy-check, hy-switch…) restano più forti */
:where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--hy-accent); }
.hy-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hy-field__label { font: var(--hy-weight-strong) var(--hy-text-sm) var(--hy-font-sans); color: var(--hy-text); margin: 0; }
.hy-field__req { color: var(--hy-accent-text); margin-left: 2px; }
.hy-field__control { position: relative; display: flex; align-items: center; }
.hy-field__help { font-size: var(--hy-text-xs); color: var(--hy-text-muted); }
.hy-field__error { font-size: var(--hy-text-xs); color: var(--hy-danger); }
.hy-field__error:empty { display: none; }
.hy-field__prefix { position: absolute; left: 12px; color: var(--hy-text-muted); pointer-events: none; font-size: 14px; }

.hy-input, .hy-select {
    width: 100%; height: 42px; padding: 0 12px; margin: 0;
    border-radius: var(--hy-radius-md); border: 1px solid var(--hy-border-control);
    background-color: var(--hy-control-bg); color: var(--hy-text);
    font: var(--hy-weight-regular) var(--hy-text-md) var(--hy-font-sans);
    transition: border-color var(--hy-dur-fast), box-shadow var(--hy-dur-fast);
}
.hy-input::placeholder { color: var(--hy-text-placeholder); opacity: 1; }
/* Icone native (orario, data) e completamento automatico nel colore del tema */
.hy-input { color-scheme: dark; }
html[data-theme="light"] .hy-input { color-scheme: light; }
.hy-input:hover, .hy-select:hover { border-color: var(--hy-text-muted); }
.hy-input:focus, .hy-select:focus { outline: none; border-color: var(--hy-focus-ring); box-shadow: 0 0 0 1px var(--hy-focus-ring), 0 0 0 4px var(--hy-accent-soft); }
.hy-input[aria-invalid="true"], .hy-select[aria-invalid="true"] { border-color: var(--hy-danger); }
.hy-input:disabled, .hy-select:disabled { opacity: .5; background-color: var(--hy-surface-alt); cursor: not-allowed; }
.hy-field__prefix + .hy-input { padding-left: 36px; }

/* Select nativa: freccia disegnata con il colore del testo del tema */
.hy-select {
    appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--hy-text-muted) 50%), linear-gradient(135deg, var(--hy-text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.hy-select option { background: var(--hy-surface-raised); color: var(--hy-text); }

/* Taglia sm (filtri e celle, solo desktop) */
.hy-input--sm, .hy-select--sm { height: 32px; font-size: var(--hy-text-sm); }

@media (max-width: 767.98px) {
    .hy-input, .hy-select { height: 44px; font-size: 16px; } /* D18: niente zoom automatico su iPhone */
    .hy-input--sm, .hy-select--sm { height: 44px; }
}

/* Sola lettura come testo (dettagli e contesto nelle modali) */
.hy-field--static .hy-field__value { min-height: 22px; color: var(--hy-text); overflow-wrap: anywhere; }

/* C5 · Textarea: parte da 3 righe e cresce fino a 10 (hy-fields.js), ridimensionabile in verticale */
.hy-textarea {
    display: block; width: 100%; min-height: calc(3 * 1.45em + 24px); max-height: calc(10 * 1.45em + 24px); padding: 12px; margin: 0;
    border-radius: var(--hy-radius-md); border: 1px solid var(--hy-border-control); background-color: var(--hy-control-bg); color: var(--hy-text);
    font: var(--hy-weight-regular) var(--hy-text-md)/1.45 var(--hy-font-sans); resize: vertical;
    transition: border-color var(--hy-dur-fast), box-shadow var(--hy-dur-fast);
}
.hy-textarea::placeholder { color: var(--hy-text-placeholder); opacity: 1; }
.hy-textarea:hover { border-color: var(--hy-text-muted); }
.hy-textarea:focus { outline: none; border-color: var(--hy-focus-ring); box-shadow: 0 0 0 1px var(--hy-focus-ring), 0 0 0 4px var(--hy-accent-soft); }
.hy-field__counter { align-self: flex-end; font-size: var(--hy-text-xs); color: var(--hy-text-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 767.98px) { .hy-textarea { font-size: 16px; } }

/* C8 · Gruppo di radio in colonna */
.hy-radios { display: flex; flex-direction: column; gap: 6px; }
.hy-radios label { display: flex; align-items: center; gap: 8px; min-height: 32px; margin: 0; cursor: pointer; font-weight: var(--hy-weight-regular); }
.hy-radios input { width: 18px; height: 18px; margin: 0; accent-color: var(--hy-accent); }
@media (max-width: 767.98px) { .hy-radios label { min-height: 44px; } }

/* C7 · Checkbox (docs/ui/COMPONENTI.md): quadratino 20px, selezionata piena in magenta con spunta bianca */
.hy-check { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.hy-check__input {
    -webkit-appearance: none; appearance: none; flex: none; width: 20px; height: 20px; margin: 0; cursor: pointer;
    border: 1px solid var(--hy-border-control); border-radius: var(--hy-radius-sm); background: var(--hy-control-bg) center / 14px no-repeat;
}
.hy-check__input:hover { border-color: var(--hy-accent-text); }
.hy-check__input:focus-visible { outline: 2px solid var(--hy-focus-ring); outline-offset: 2px; }
.hy-check__input:checked, .hy-check__input:indeterminate { background-color: var(--hy-accent-fill); border-color: var(--hy-accent-fill); }
.hy-check__input:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E"); }
.hy-check__input:indeterminate { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-width='2.2' stroke-linecap='round' d='M4 8h8'/%3E%3C/svg%3E"); }
.hy-check__input:disabled, .hy-check__input:disabled + .hy-check__label { opacity: .5; cursor: not-allowed; }
.hy-check__input[aria-invalid="true"] { border-color: var(--hy-danger); }
.hy-check__label { margin: 0; color: var(--hy-text); font: var(--hy-weight-regular) 14px var(--hy-font-sans); cursor: pointer; }
.hy-choice-group { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px; }
.hy-choice-group > legend { float: none; width: auto; margin: 0 0 4px; padding: 0; font: var(--hy-weight-strong) var(--hy-text-sm) var(--hy-font-sans); color: var(--hy-text); }
@media (max-width: 767.98px) { .hy-check { min-height: 44px; } }

/* C7b · Interruttore (docs/ui/COMPONENTI.md): checkbox nativa con role="switch", 40×22, acceso in magenta. Per le scelte che hanno effetto subito (es. Smart Working nel Marcatempo) */
.hy-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 32px; margin: 0; cursor: pointer; }
.hy-switch__input {
    -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 40px; height: 22px; margin: 0; cursor: pointer;
    border: 1px solid var(--hy-border-control); border-radius: 999px; background: var(--hy-control-bg); transition: background-color .15s ease, border-color .15s ease;
}
.hy-switch__input::before {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: var(--hy-text-muted); transition: transform .15s ease, background-color .15s ease;
}
.hy-switch__input:hover { border-color: var(--hy-accent-text); }
.hy-switch__input:focus-visible { outline: 2px solid var(--hy-focus-ring); outline-offset: 2px; }
.hy-switch__input:checked { background-color: var(--hy-accent-fill); border-color: var(--hy-accent-fill); }
.hy-switch__input:checked::before { transform: translateX(18px); background: var(--hy-on-accent); }
.hy-switch__input:disabled, .hy-switch__input:disabled + .hy-switch__label { opacity: .5; cursor: not-allowed; }
.hy-switch__label { color: var(--hy-text); font: var(--hy-weight-regular) 14px var(--hy-font-sans); }
@media (prefers-reduced-motion: reduce) { .hy-switch__input, .hy-switch__input::before { transition: none; } }
@media (max-width: 767.98px) { .hy-switch { min-height: 44px; } }

/* Data + ora nello stesso campo (hyper-crud type "datetime"): data a sinistra, ora hh:mm a destra */
.hy-datetime { display: flex; gap: 8px; align-items: flex-start; }
.hy-datetime > .hy-field__control { flex: 1; min-width: 0; }
.hy-datetime__time { width: 88px; flex: 0 0 88px; text-align: center; }

/* Titolo di sezione in un modulo lungo (al posto delle schede): separa i gruppi di campi */
.hy-form-section { padding-top: 8px; }
.hy-form-section:first-child { padding-top: 0; }
.hy-form-stack { display: flex; flex-direction: column; gap: 14px; } /* campi uno sotto l'altro senza griglia Bootstrap */
.hy-form-section__title { margin: 0; padding-bottom: 6px; border-bottom: 1px solid var(--hy-border); font: var(--hy-weight-strong) 15px/1.3 var(--hy-font-heading); color: var(--hy-text); }
.hy-form-section__help { margin: 6px 0 0; font-size: 13px; color: var(--hy-text-muted); }

/* D5 · Selettore Anno/Mese ("‹ Ottobre 2026 ›"): wwwroot/js/components/hy-month.js */
.hy-month { display: inline-flex; align-items: center; gap: 2px; height: 40px; padding: 0 2px; border: 1px solid var(--hy-border-control); border-radius: var(--hy-radius-pill); background: var(--hy-control-bg); }
.hy-month__label { min-width: 150px; height: 34px; padding: 0 10px; border: 0; border-radius: var(--hy-radius-pill); background: transparent; color: var(--hy-text); font: 600 14px/1 var(--hy-font-sans) !important; cursor: pointer; } /* !important: site.css forza il peso dei bottoni */
.hy-month__label:hover { background: var(--hy-accent-soft); }
.hy-month__years { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hy-month__year { font: var(--hy-weight-strong) 16px/1 var(--hy-font-heading); }
.hy-month__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hy-month__cell { height: 44px; border: 1px solid var(--hy-border); border-radius: var(--hy-radius-md); background: transparent; color: var(--hy-text); font-size: 14px; text-transform: capitalize; cursor: pointer; }
.hy-month__cell:hover { background: var(--hy-accent-soft); }
.hy-month__cell.is-active { background: var(--hy-accent-fill); border-color: var(--hy-accent-fill); color: var(--hy-on-accent); }
@media (max-width: 767.98px) { .hy-month { height: 44px; } .hy-month .hy-btn--icon { width: 44px; height: 44px; } }
