/* TD Forms - stile frontend. Tutto guidato dalle variabili CSS iniettate per-form. */

.tdf-wrap { margin: 0 0 1.5em; }

.tdf-form {
    --tdf-accent: #2563eb;
    --tdf-field-bg: #fff;
    --tdf-field-color: #1f2933;
    --tdf-field-size: 15px;
    --tdf-border-style: solid;
    --tdf-border-width: 1px;
    --tdf-border-color: #d6dde5;
    --tdf-radius: 8px;
    --tdf-focus: #2563eb;
    --tdf-spacing: 18px;
    --tdf-label-color: #1f2933;
    --tdf-label-size: 15px;
    --tdf-label-weight: 600;
    --tdf-btn-bg: #2563eb;
    --tdf-btn-color: #fff;
    --tdf-btn-radius: 8px;
    --tdf-btn-size: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--tdf-spacing);
    box-sizing: border-box;
}
.tdf-form * { box-sizing: border-box; }

/* Pagine multi-step */
.tdf-page { display: none; width: 100%; flex-wrap: wrap; gap: var(--tdf-spacing); }
.tdf-page.is-active { display: flex; }

.tdf-steps-indicator {
    width: 100%;
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 4px;
}
.tdf-step-dot {
    width: 28px; height: 5px; border-radius: 3px;
    background: var(--tdf-border-color);
    transition: background .2s;
}
.tdf-step-dot.is-active { background: var(--tdf-accent); }
.tdf-step-count { display: none; }

/* Campo */
.tdf-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tdf-field.tdf-size-half    { width: calc((100% - var(--tdf-spacing)) / 2); }
.tdf-field.tdf-size-third   { width: calc((100% - 2 * var(--tdf-spacing)) / 3); }
.tdf-field.tdf-size-quarter { width: calc((100% - 3 * var(--tdf-spacing)) / 4); }
@media (max-width: 782px) {
    .tdf-field.tdf-size-third,
    .tdf-field.tdf-size-quarter { width: calc((100% - var(--tdf-spacing)) / 2); }
}
@media (max-width: 600px) {
    .tdf-field.tdf-size-half,
    .tdf-field.tdf-size-third,
    .tdf-field.tdf-size-quarter { width: 100%; }
}

.tdf-hidden { display: none !important; }

.tdf-label {
    color: var(--tdf-label-color);
    font-size: var(--tdf-label-size);
    font-weight: var(--tdf-label-weight);
    line-height: 1.3;
}
/* Etichetta nascosta visivamente ma disponibile per screen reader (aria-labelledby resta valido) */
.tdf-label-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.tdf-required { color: #dc2626; }
.tdf-required-note { margin: 0 0 var(--tdf-spacing, 18px); font-size: 13px; color: #6b7280; }
.tdf-required-note::first-letter { color: #dc2626; font-weight: 600; }
.tdf-desc { color: #6b7280; font-size: 13px; }

/* Input generici */
.tdf-field input[type=text],
.tdf-field input[type=email],
.tdf-field input[type=tel],
.tdf-field input[type=url],
.tdf-field input[type=number],
.tdf-field input[type=date],
.tdf-field input[type=time],
.tdf-field input[type=file],
.tdf-field textarea,
.tdf-field select {
    width: 100%;
    background: var(--tdf-field-bg);
    color: var(--tdf-field-color);
    font-size: var(--tdf-field-size);
    padding: 11px 13px;
    border-style: var(--tdf-border-style);
    border-width: var(--tdf-border-width);
    border-color: var(--tdf-border-color);
    border-radius: var(--tdf-radius);
    line-height: 1.4;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.tdf-field textarea { resize: vertical; min-height: 110px; }

.tdf-field input:focus,
.tdf-field textarea:focus,
.tdf-field select:focus {
    outline: none;
    border-color: var(--tdf-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tdf-focus) 22%, transparent);
}

/* Select: stesso look degli altri campi (bg/colore/bordo/raggio dalle variabili del form)
   + freccia custom. La tendina aperta con le opzioni resta gestita dal browser/OS. */
.tdf-field select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
}
.tdf-field select::-ms-expand { display: none; }
.tdf-field select.tdf-ph { color: var(--tdf-placeholder, #6b7280); }
.tdf-field select[multiple] {
    background-image: none;
    padding-right: 13px;
    cursor: auto;
    min-height: 110px;
}
/* Dove il browser lo consente (Firefox, Android) le opzioni seguono i colori del campo. */
.tdf-field select option { color: var(--tdf-field-color); background: var(--tdf-field-bg); }

/* Nome composito */
.tdf-name-row { display: flex; gap: 10px; }
.tdf-name-row input { flex: 1; }
@media (max-width: 480px) { .tdf-name-row { flex-direction: column; } }

/* Scelte radio/checkbox */
.tdf-choices { display: flex; flex-direction: column; gap: 8px; }
.tdf-choice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    color: var(--tdf-field-color);
    font-size: var(--tdf-field-size);
    cursor: pointer;
    line-height: 1.4;
}
.tdf-choice input { margin-top: 2px; accent-color: var(--tdf-accent); width: 17px; height: 17px; }
.tdf-acceptance { font-size: 14px; }

/* Range */
.tdf-range { display: flex; align-items: center; gap: 12px; }
.tdf-range input[type=range] { flex: 1; accent-color: var(--tdf-accent); padding: 0; border: 0; }
.tdf-range-out {
    min-width: 42px; text-align: center;
    font-weight: 600; color: var(--tdf-accent);
    background: color-mix(in srgb, var(--tdf-accent) 12%, transparent);
    border-radius: 6px; padding: 3px 6px;
}

/* Rating */
.tdf-rating { display: inline-flex; gap: 4px; font-size: 28px; cursor: pointer; }
.tdf-star { color: #d1d5db; transition: color .12s, transform .12s; }
.tdf-star.is-on { color: #f59e0b; }
.tdf-star:hover { transform: scale(1.12); }

/* Layout helper */
.tdf-heading { margin: 4px 0 0; color: var(--tdf-label-color); }
.tdf-heading-desc { color: #6b7280; font-size: 14px; }
.tdf-divider { width: 100%; border: 0; border-top: 1px solid var(--tdf-border-color); margin: 4px 0; }
.tdf-html { color: var(--tdf-field-color); font-size: 15px; }

/* Errori */
.tdf-error { color: #dc2626; font-size: 13px; min-height: 0; }
.tdf-field.tdf-has-error input,
.tdf-field.tdf-has-error textarea,
.tdf-field.tdf-has-error select {
    border-color: #dc2626;
}

/* Footer + bottoni */
.tdf-footer { width: 100%; }
.tdf-step-nav { width: 100%; display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; }
.tdf-btn {
    cursor: pointer;
    font-family: inherit;
    border: none;
    font-weight: 600;
}
.tdf-submit, .tdf-next, .tdf-prev {
    background: var(--tdf-btn-bg);
    color: var(--tdf-btn-color);
    font-size: var(--tdf-btn-size);
    padding: 12px 26px;
    border-radius: var(--tdf-btn-radius);
    transition: filter .15s, transform .05s;
}
.tdf-prev { background: #e5e7eb; color: #374151; }
.tdf-btn:hover { filter: brightness(0.95); }
.tdf-btn:active { transform: translateY(1px); }
.tdf-btn:disabled { opacity: .6; cursor: not-allowed; }

/* Messaggi */
.tdf-message { width: 100%; padding: 16px 18px; border-radius: var(--tdf-radius); font-size: 15px; }
.tdf-message-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.tdf-message-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Honeypot */
.tdf-hp { position: absolute !important; left: -9999px !important; height: 0; overflow: hidden; }

/* Avviso admin */
.tdf-notice { padding: 10px 14px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 6px; color: #9a3412; }

/* ======================================================================
   Modern select (stile WPForms "Modern"): box compatto + ricerca + tag.
   Progressive enhancement: il <select> nativo resta nel DOM, nascosto.
   Eredita le stesse variabili --tdf-* degli altri campi del form.
   ====================================================================== */
.tdf-field select.tdf-ms-native {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
    opacity: 0; pointer-events: none;
}
.tdf-ms { position: relative; width: 100%; }

.tdf-ms-control {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    background: var(--tdf-field-bg);
    color: var(--tdf-field-color);
    font-size: var(--tdf-field-size);
    padding: 11px 38px 11px 13px;
    border-style: var(--tdf-border-style);
    border-width: var(--tdf-border-width);
    border-color: var(--tdf-border-color);
    border-radius: var(--tdf-radius);
    line-height: 1.4;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.tdf-ms.is-open .tdf-ms-control,
.tdf-ms-control:focus {
    outline: none;
    border-color: var(--tdf-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tdf-focus) 22%, transparent);
}
.tdf-ms-values { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.tdf-ms-ph { color: var(--tdf-placeholder, #6b7280); }

.tdf-ms-arrow {
    position: absolute; right: 14px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
    pointer-events: none; transition: transform .15s;
    background: no-repeat center / 12px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}
.tdf-ms.is-open .tdf-ms-arrow { transform: rotate(180deg); }

/* Tag (multi-select) */
.tdf-ms-tag {
    display: inline-flex; align-items: center; gap: 6px;
    background: color-mix(in srgb, var(--tdf-accent) 14%, transparent);
    color: var(--tdf-accent);
    border-radius: calc(var(--tdf-radius) - 2px);
    padding: 2px 7px 2px 9px; font-size: .9em; line-height: 1.7;
}
.tdf-ms-tag-x {
    border: 0; background: transparent; color: inherit; cursor: pointer;
    font-size: 1.15em; line-height: 1; padding: 0; opacity: .65;
}
.tdf-ms-tag-x:hover { opacity: 1; }

/* Dropdown */
.tdf-ms-dropdown {
    display: none; position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 5px);
    background: var(--tdf-field-bg);
    border: 1px solid var(--tdf-border-color);
    border-radius: var(--tdf-radius);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
    overflow: hidden;
}
.tdf-ms.is-open .tdf-ms-dropdown { display: block; }

.tdf-ms-search { padding: 8px; border-bottom: 1px solid var(--tdf-border-color); }
.tdf-ms-search input {
    width: 100%; box-sizing: border-box; font-size: .95em;
    padding: 8px 10px; font-family: inherit;
    color: var(--tdf-field-color);
    background: color-mix(in srgb, var(--tdf-field-color) 4%, transparent);
    border: 1px solid var(--tdf-border-color);
    border-radius: calc(var(--tdf-radius) - 2px);
}
.tdf-ms-search input:focus { outline: none; border-color: var(--tdf-focus); }

.tdf-ms-list { list-style: none; margin: 0; padding: 4px; overflow: visible; }
.tdf-ms-option {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px; border-radius: calc(var(--tdf-radius) - 2px);
    cursor: pointer; font-size: var(--tdf-field-size); color: var(--tdf-field-color);
}
.tdf-ms-option:hover,
.tdf-ms-option.is-active { background: color-mix(in srgb, var(--tdf-accent) 12%, transparent); }
.tdf-ms-option.is-selected {
    background: color-mix(in srgb, var(--tdf-accent) 16%, transparent);
    color: var(--tdf-accent); font-weight: 600;
}
.tdf-ms-option.is-selected::after { content: '\2713'; margin-left: 10px; }
.tdf-ms-empty { padding: 14px; text-align: center; font-size: .9em; color: color-mix(in srgb, var(--tdf-field-color) 55%, transparent); }

/* Stato errore coerente con gli altri campi */
.tdf-field.tdf-has-error .tdf-ms-control { border-color: #dc2626; }

/* ======================================================================
   Campo Indirizzo (autocompletamento Nominatim/Photon).
   Eredita le variabili --tdf-* del form come tutti gli altri campi.
   ====================================================================== */
.tdf-address { width: 100%; }
.tdf-address-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Larghezza UNICA dei campi corti (civico, CAP, provincia).
       Cambia solo questo valore per regolare tutti e tre insieme. */
    --tdf-addr-fixed: 110px;
}
.tdf-addr-row { display: flex; gap: 10px; }
.tdf-addr-cell { display: flex; flex-direction: column; min-width: 0; }
.tdf-addr-cell input { width: 100%; }

/* I tre campi corti condividono la stessa larghezza: cosi' il civico (riga 1)
   e la provincia (riga 2) restano perfettamente allineati a destra, e il CAP
   (riga 2) si allinea a sinistra con la via (riga 1). */
.tdf-addr-cell-street   { flex: 1 1 auto; }
.tdf-addr-cell-number   { flex: 0 0 var(--tdf-addr-fixed); }
.tdf-addr-cell-postcode { flex: 0 0 var(--tdf-addr-fixed); }
.tdf-addr-cell-city     { flex: 1 1 auto; }
.tdf-addr-cell-province { flex: 0 0 var(--tdf-addr-fixed); }
.tdf-addr-cell-country  { flex: 1 1 auto; }

@media (max-width: 480px) {
    .tdf-addr-row { flex-wrap: wrap; }
    .tdf-addr-cell-number,
    .tdf-addr-cell-postcode,
    .tdf-addr-cell-province { flex: 1 1 28%; }
    .tdf-addr-cell-street,
    .tdf-addr-cell-city { flex: 1 1 100%; }
}

/* Contenitore con dropdown dei suggerimenti */
.tdf-addr-search { position: relative; width: 100%; }

.tdf-addr-suggest {
    display: none;
    position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 5px);
    background: var(--tdf-field-bg);
    border: 1px solid var(--tdf-border-color);
    border-radius: var(--tdf-radius);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
    max-height: 280px; overflow-y: auto;
}
.tdf-addr-suggest.is-open { display: block; }
.tdf-addr-suggest-item {
    padding: 9px 12px; cursor: pointer;
    font-size: var(--tdf-field-size); color: var(--tdf-field-color); line-height: 1.35;
    border-bottom: 1px solid color-mix(in srgb, var(--tdf-border-color) 60%, transparent);
}
.tdf-addr-suggest-item:last-child { border-bottom: 0; }
.tdf-addr-suggest-item:hover,
.tdf-addr-suggest-item.is-active { background: color-mix(in srgb, var(--tdf-accent) 12%, transparent); }

/* Codice Fiscale: testo sempre maiuscolo a video */
.tdf-field input.tdf-cf { text-transform: uppercase; }

/* Telefono con prefisso internazionale */
.tdf-phone-row {
    display: flex;
    gap: 10px;
    width: 100%;
}
.tdf-phone-row .tdf-phone-prefix {
    flex: 0 0 125px;
    width: 125px;
}
.tdf-phone-row .tdf-phone-custom-prefix {
    flex: 0 0 92px;
    width: 92px;
}
.tdf-phone-row .tdf-phone-number {
    flex: 1 1 auto;
    min-width: 0;
}
@media (max-width: 520px) {
    .tdf-phone-row { flex-direction: column; }
    .tdf-phone-row .tdf-phone-prefix, .tdf-phone-row .tdf-phone-custom-prefix { width: 100%; flex-basis: auto; }
}

/* CAPTCHA anti-bot */
.tdf-captcha { margin-top: 4px; }
.tdf-captcha-v3-note { font-size: 12px; color: #6b7280; margin-top: 2px; }
.tdf-captcha-v3-note a { color: inherit; text-decoration: underline; }

/* ---------- Opzioni su più colonne (radio / checkbox) ---------- */
.tdf-choices[class*="tdf-cols-"] {
    display: grid;
    column-gap: 18px;
    row-gap: 8px;
    align-items: start;
}
.tdf-choices.tdf-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tdf-choices.tdf-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tdf-choices.tdf-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tdf-choices.tdf-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* Tablet: max 3 colonne */
@media (max-width: 960px) {
    .tdf-choices.tdf-cols-4,
    .tdf-choices.tdf-cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Mobile: max 2 colonne */
@media (max-width: 640px) {
    .tdf-choices.tdf-cols-3,
    .tdf-choices.tdf-cols-4,
    .tdf-choices.tdf-cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Mobile stretto: tutto in colonna singola */
@media (max-width: 420px) {
    .tdf-choices[class*="tdf-cols-"] { grid-template-columns: 1fr; }
}

/* ============ Prenotazione da calendario (campo Data) ============ */
/* Layout in flexbox: prevedibile dentro il flex-column di .tdf-field, niente overflow su Safari. */
.tdf-form .tdf-booking {
    display: flex !important;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}
.tdf-booking, .tdf-bk-cal, .tdf-bk-slots, .tdf-bk-grid, .tdf-bk-day,
.tdf-bk-slotgrid, .tdf-bk-slot { box-sizing: border-box !important; }
.tdf-form .tdf-bk-cal {
    flex: 0 1 330px;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    border: 1px solid var(--tdf-border-color, #e5e7eb);
    border-radius: var(--tdf-radius, 12px);
    padding: 14px;
    background: var(--tdf-field-bg, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.tdf-bk-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.tdf-bk-title {
    font-weight: 700; font-size: 15px; text-transform: capitalize;
    color: #374151; letter-spacing: .2px;
}
.tdf-bk-nav {
    border: 1px solid var(--tdf-border-color, #e5e7eb);
    background: var(--tdf-field-bg, #fff);
    border-radius: 999px; width: 34px; height: 34px; cursor: pointer;
    font-size: 18px; line-height: 1; color: var(--tdf-field-color, #111827);
    display: inline-flex; align-items: center; justify-content: center;
    flex: none;
    transition: background .15s, border-color .15s, color .15s;
}
.tdf-bk-nav:hover:not(:disabled) { border-color: var(--tdf-accent, #6366f1); color: var(--tdf-accent, #6366f1); }
.tdf-bk-nav:disabled { opacity: .3; cursor: default; }
.tdf-bk-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; width: 100%; }
.tdf-bk-dow {
    text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase;
    color: var(--tdf-label-color, #9ca3af); opacity: .7; padding: 4px 0 8px;
    min-width: 0;
}
.tdf-bk-empty { visibility: hidden; }
.tdf-bk-day {
    min-width: 0; width: 100%;
    border: 1px solid transparent; border-radius: 10px;
    background: transparent; cursor: pointer;
    font-size: 14px; font-weight: 500; color: #4b5563;
    padding: 10px 0; line-height: 1.1;
    transition: background .12s, color .12s, box-shadow .12s;
}
.tdf-bk-day:hover:not(.is-disabled):not(.is-selected) {
    background: color-mix(in srgb, var(--tdf-accent, #6366f1) 12%, transparent);
}
.tdf-bk-day.is-selected {
    background: var(--tdf-btn-bg, #4f46e5); color: var(--tdf-btn-color, #fff);
    font-weight: 700; box-shadow: 0 2px 6px color-mix(in srgb, var(--tdf-btn-bg, #4f46e5) 40%, transparent);
}
.tdf-bk-day.is-disabled { opacity: .28; cursor: default; }

.tdf-form .tdf-bk-slots { flex: 1 1 200px; min-width: 0 !important; max-width: 100%; box-sizing: border-box; }
.tdf-bk-hint { color: var(--tdf-label-color, #6b7280); font-size: 13px; margin: 4px 0; opacity: .85; }
.tdf-bk-slotgrid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px;
    max-height: 320px; overflow: auto; padding: 2px;
}
.tdf-bk-slot {
    border: 1px solid var(--tdf-border-color, #e5e7eb);
    background: var(--tdf-field-bg, #fff);
    border-radius: var(--tdf-btn-radius, 10px); padding: 10px 4px; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--tdf-field-color, #111827);
    min-width: 0;
    transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}
.tdf-bk-slot:hover:not(.is-selected) {
    border-color: var(--tdf-btn-bg, #4f46e5);
    color: var(--tdf-btn-bg, #4f46e5);
}
.tdf-bk-slot.is-selected {
    background: var(--tdf-btn-bg, #4f46e5); color: var(--tdf-btn-color, #fff);
    border-color: var(--tdf-btn-bg, #4f46e5);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--tdf-btn-bg, #4f46e5) 40%, transparent);
}
.tdf-bk-chosen { flex-basis: 100%; width: 100%; margin-top: 4px; font-size: 14px; color: var(--tdf-field-color, #111827); }
.tdf-bk-label {
    font-size: var(--tdf-label-size, 14px); margin-bottom: 8px;
    color: var(--tdf-label-color, #374151); font-weight: var(--tdf-label-weight, 600);
}
@media (max-width: 640px) {
    .tdf-form .tdf-bk-cal { flex: 1 1 100%; padding: 12px 8px; }
    .tdf-form .tdf-bk-slots { flex: 1 1 100%; margin-top: 0; }
    .tdf-bk-grid { gap: 3px; }
    .tdf-bk-day { padding: 13px 0; font-size: 15px; }
    .tdf-bk-dow { font-size: 11px; padding: 2px 0 6px; }
    .tdf-bk-title { font-size: 16px; }
    .tdf-bk-nav { width: 38px; height: 38px; }
    .tdf-bk-slotgrid { max-height: none; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
    .tdf-bk-slot { padding: 13px 4px; }
    .tdf-bk-chosen { margin-top: 12px; }
}

/* Placeholder sui campi Data nativi (prima di gg/mm/aaaa) */
.tdf-field input[type=date][data-placeholder]:not(.tdf-has-value)::before {
    content: attr(data-placeholder) " ";
    color: var(--tdf-placeholder, #9ca3af);
}
.tdf-bk-label { font-size: 14px; margin-bottom: 6px; color: var(--tdf-label-color, #374151); font-weight: var(--tdf-label-weight, 600); }

/* ==========================================================================
   TEMA "MODERNO" (default dalla 1.23) — attivo con .tdf-ui-modern sul wrapper.
   Il tema "Classico" (stile precedente) resta disponibile per form: nessuna
   regola qui sotto si applica senza la classe. Tutto continua a usare le
   variabili --tdf-* scelte nel tab Stile del form.
   ========================================================================== */

.tdf-ui-modern {
    --tdf-muted: color-mix(in srgb, var(--tdf-field-color, #1f2933) 58%, transparent);
    --tdf-placeholder: color-mix(in srgb, var(--tdf-field-color, #1f2933) 42%, transparent);
    --tdf-soft: color-mix(in srgb, var(--tdf-accent, #2563eb) 10%, transparent);
    --tdf-err: #d92d20;
}

/* Campi: altezza costante, hover, focus morbido */
.tdf-ui-modern .tdf-field { gap: 7px; }
.tdf-ui-modern .tdf-field input[type=text],
.tdf-ui-modern .tdf-field input[type=email],
.tdf-ui-modern .tdf-field input[type=tel],
.tdf-ui-modern .tdf-field input[type=url],
.tdf-ui-modern .tdf-field input[type=number],
.tdf-ui-modern .tdf-field input[type=date],
.tdf-ui-modern .tdf-field input[type=time],
.tdf-ui-modern .tdf-field select,
.tdf-ui-modern .tdf-ms-control {
    min-height: 48px;
    padding-top: 12px;
    padding-bottom: 12px;
}
.tdf-ui-modern .tdf-field input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
.tdf-ui-modern .tdf-field textarea,
.tdf-ui-modern .tdf-field select,
.tdf-ui-modern .tdf-ms-control {
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    transition: border-color .16s, box-shadow .16s, background-color .16s;
}
.tdf-ui-modern .tdf-field input::placeholder,
.tdf-ui-modern .tdf-field textarea::placeholder { color: var(--tdf-placeholder); opacity: 1; }
.tdf-ui-modern .tdf-field input:not([type=checkbox]):not([type=radio]):not([type=range]):hover,
.tdf-ui-modern .tdf-field textarea:hover,
.tdf-ui-modern .tdf-field select:hover,
.tdf-ui-modern .tdf-ms-control:hover {
    border-color: color-mix(in srgb, var(--tdf-border-color) 55%, var(--tdf-field-color));
}
.tdf-ui-modern .tdf-field input:focus,
.tdf-ui-modern .tdf-field textarea:focus,
.tdf-ui-modern .tdf-field select:focus,
.tdf-ui-modern .tdf-ms.is-open .tdf-ms-control {
    border-color: var(--tdf-focus);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--tdf-focus) 16%, transparent);
}

/* Etichette e aiuti */
.tdf-ui-modern .tdf-label { letter-spacing: -.005em; }
.tdf-ui-modern .tdf-required { color: var(--tdf-err); font-weight: 600; }
.tdf-ui-modern .tdf-desc { color: var(--tdf-muted); font-size: 13px; line-height: 1.45; }
.tdf-ui-modern .tdf-required-note { color: var(--tdf-muted); }
.tdf-ui-modern .tdf-required-note::first-letter { color: var(--tdf-err); }

/* Checkbox e radio disegnati (colore = accento del form) */
.tdf-ui-modern .tdf-choices { gap: 10px; }
.tdf-ui-modern .tdf-choice { align-items: center; gap: 11px; }
.tdf-ui-modern .tdf-choice input[type=checkbox],
.tdf-ui-modern .tdf-choice input[type=radio] {
    -webkit-appearance: none;
    appearance: none;
    flex: 0 0 auto;
    width: 21px;
    height: 21px;
    margin: 0;
    border: 1.5px solid color-mix(in srgb, var(--tdf-border-color) 65%, var(--tdf-field-color));
    border-radius: 6px;
    background: var(--tdf-field-bg);
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.tdf-ui-modern .tdf-choice input[type=radio] { border-radius: 50%; }
.tdf-ui-modern .tdf-choice input[type=checkbox]::before {
    content: '';
    width: 12px;
    height: 12px;
    background: #fff;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.3 4.8 9 10 3.3' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.3 4.8 9 10 3.3' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transform: scale(0);
    transition: transform .14s cubic-bezier(.3, .8, .4, 1.4);
}
.tdf-ui-modern .tdf-choice input[type=radio]::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #fff;
    transform: scale(0);
    transition: transform .14s cubic-bezier(.3, .8, .4, 1.4);
}
.tdf-ui-modern .tdf-choice input:checked {
    background: var(--tdf-accent);
    border-color: var(--tdf-accent);
}
.tdf-ui-modern .tdf-choice input:checked::before { transform: scale(1); }
.tdf-ui-modern .tdf-choice input:focus-visible { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--tdf-accent) 22%, transparent); }
.tdf-ui-modern .tdf-choice:hover input:not(:checked) { border-color: var(--tdf-accent); }
.tdf-ui-modern .tdf-acceptance { font-size: 14px; color: var(--tdf-field-color); }
.tdf-ui-modern .tdf-acceptance input { align-self: flex-start; margin-top: 1px; }
.tdf-ui-modern .tdf-acceptance a { color: var(--tdf-accent); }

/* Caricamento file: area tratteggiata, bottone "sfoglia" a pillola */
.tdf-ui-modern .tdf-field input[type=file] {
    padding: 18px 16px;
    border-style: dashed;
    border-width: max(1.5px, var(--tdf-border-width));
    background: color-mix(in srgb, var(--tdf-accent) 4%, var(--tdf-field-bg));
    color: var(--tdf-muted);
    font-size: 14px;
    cursor: pointer;
}
.tdf-ui-modern .tdf-field input[type=file]:hover { border-color: var(--tdf-accent); }
.tdf-ui-modern .tdf-field input[type=file]::file-selector-button {
    margin-right: 14px;
    padding: 9px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--tdf-soft);
    color: var(--tdf-accent);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s;
}
.tdf-ui-modern .tdf-field input[type=file]::file-selector-button:hover { background: color-mix(in srgb, var(--tdf-accent) 18%, transparent); }

/* Slider */
.tdf-ui-modern .tdf-range input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tdf-accent) 18%, var(--tdf-border-color));
}
.tdf-ui-modern .tdf-range input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--tdf-field-bg);
    border: 2px solid var(--tdf-accent);
    box-shadow: 0 2px 6px rgba(16, 24, 40, .18);
    cursor: grab;
}
.tdf-ui-modern .tdf-range input[type=range]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--tdf-field-bg);
    border: 2px solid var(--tdf-accent);
    box-shadow: 0 2px 6px rgba(16, 24, 40, .18);
    cursor: grab;
}
.tdf-ui-modern .tdf-range-out { border-radius: 999px; padding: 4px 10px; font-variant-numeric: tabular-nums; }

/* Multi-step: barra di avanzamento a segmenti + contatore */
.tdf-ui-modern .tdf-steps-indicator {
    gap: 6px;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 6px;
}
.tdf-ui-modern .tdf-step-dot {
    flex: 1 1 0;
    width: auto;
    height: 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tdf-accent) 14%, var(--tdf-border-color));
    position: relative;
    overflow: hidden;
}
.tdf-ui-modern .tdf-step-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--tdf-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .35s cubic-bezier(.3, .7, .3, 1);
}
.tdf-ui-modern .tdf-step-dot.is-active { background: color-mix(in srgb, var(--tdf-accent) 14%, var(--tdf-border-color)); }
.tdf-ui-modern .tdf-step-dot.is-active::after { transform: scaleX(1); }
.tdf-ui-modern .tdf-step-count {
    display: inline-block;
    flex: 0 0 auto;
    margin-left: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--tdf-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tdf-ui-modern .tdf-page.is-active { animation: tdf-page-in .32s cubic-bezier(.3, .7, .3, 1); }
@keyframes tdf-page-in { from { opacity: 0; transform: translateY(6px); } }

/* Pulsanti */
.tdf-ui-modern .tdf-submit,
.tdf-ui-modern .tdf-next,
.tdf-ui-modern .tdf-prev {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    letter-spacing: .005em;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 4px 14px color-mix(in srgb, var(--tdf-btn-bg) 26%, transparent);
    transition: transform .15s, box-shadow .15s, filter .15s, background-color .15s;
}
.tdf-ui-modern .tdf-submit:hover,
.tdf-ui-modern .tdf-next:hover {
    filter: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(16, 24, 40, .08), 0 8px 22px color-mix(in srgb, var(--tdf-btn-bg) 34%, transparent);
}
.tdf-ui-modern .tdf-submit::after,
.tdf-ui-modern .tdf-next::after {
    content: '';
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform .15s;
}
.tdf-ui-modern .tdf-submit:hover::after,
.tdf-ui-modern .tdf-next:hover::after { transform: translateX(3px); }
.tdf-ui-modern .tdf-prev {
    background: transparent;
    color: var(--tdf-field-color);
    box-shadow: inset 0 0 0 1.5px var(--tdf-border-color);
}
.tdf-ui-modern .tdf-prev:hover { box-shadow: inset 0 0 0 1.5px var(--tdf-field-color); filter: none; }
.tdf-ui-modern .tdf-submit:disabled { opacity: 1; filter: saturate(.7); transform: none; }
.tdf-ui-modern .tdf-submit:disabled::after {
    -webkit-mask: none;
            mask: none;
    background: none;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    animation: tdf-spin .7s linear infinite;
}
@keyframes tdf-spin { to { transform: rotate(360deg); } }

/* Errori in linea */
.tdf-ui-modern .tdf-error:not(:empty) {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--tdf-err);
    font-size: 13px;
    font-weight: 500;
}
.tdf-ui-modern .tdf-error:not(:empty)::before {
    content: '';
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6.5' fill='none' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M8 4.8v3.8M8 10.9v.1' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6.5' fill='none' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M8 4.8v3.8M8 10.9v.1' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tdf-ui-modern .tdf-field.tdf-has-error input:not([type=checkbox]):not([type=radio]),
.tdf-ui-modern .tdf-field.tdf-has-error textarea,
.tdf-ui-modern .tdf-field.tdf-has-error select,
.tdf-ui-modern .tdf-field.tdf-has-error .tdf-ms-control {
    border-color: var(--tdf-err);
    background-color: color-mix(in srgb, var(--tdf-err) 3%, var(--tdf-field-bg));
}
.tdf-ui-modern .tdf-field.tdf-has-error .tdf-choice input { border-color: var(--tdf-err); }

/* Messaggi finali */
.tdf-ui-modern .tdf-message {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    padding: 22px 22px 22px 66px;
    border-radius: max(12px, var(--tdf-radius, 8px));
    font-size: 15px;
    line-height: 1.55;
    border: 0;
}
.tdf-ui-modern .tdf-message::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}
.tdf-ui-modern .tdf-message::after {
    content: '';
    position: absolute;
    left: 28px;
    top: 28px;
    width: 16px;
    height: 16px;
    background: #fff;
}
.tdf-ui-modern .tdf-message-success {
    background: color-mix(in srgb, #12b76a 9%, #fff);
    color: #054f31;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #12b76a 30%, transparent);
    animation: tdf-pop .4s cubic-bezier(.3, .8, .4, 1.2);
}
.tdf-ui-modern .tdf-message-success::before { background: #12b76a; }
.tdf-ui-modern .tdf-message-success::after {
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.4 6.4 11.6 13 4.6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.4 6.4 11.6 13 4.6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tdf-ui-modern .tdf-message-error {
    background: color-mix(in srgb, #d92d20 7%, #fff);
    color: #7a271a;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #d92d20 26%, transparent);
    margin-top: 12px;
}
.tdf-ui-modern .tdf-message-error::before { background: #d92d20; }
.tdf-ui-modern .tdf-message-error::after {
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 3.5v5.5M8 12v.2' stroke='black' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 3.5v5.5M8 12v.2' stroke='black' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
@keyframes tdf-pop { from { opacity: 0; transform: scale(.97) translateY(4px); } }

/* Titoli sezione e separatori */
.tdf-ui-modern .tdf-heading { letter-spacing: -.015em; line-height: 1.2; }
.tdf-ui-modern .tdf-heading-desc { color: var(--tdf-muted); }
.tdf-ui-modern .tdf-divider { border-top-color: color-mix(in srgb, var(--tdf-border-color) 70%, transparent); margin: 8px 0; }

/* Telefono: prefisso compatto, il numero prende lo spazio restante */
.tdf-ui-modern .tdf-phone-row { gap: 8px; }
.tdf-ui-modern .tdf-phone-row .tdf-phone-prefix { flex: 0 0 102px; width: 102px; padding-left: 12px; padding-right: 30px; background-position: right 10px center; }
.tdf-ui-modern .tdf-phone-row .tdf-phone-custom-prefix { flex: 0 0 78px; width: 78px; }
.tdf-ui-modern .tdf-phone-row .tdf-phone-number { min-width: 0; }
@media (max-width: 520px) {
    .tdf-ui-modern .tdf-phone-row { flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
    .tdf-ui-modern *,
    .tdf-ui-modern *::before,
    .tdf-ui-modern *::after { animation: none !important; transition: none !important; }
}
