/* ============================================================
   vn-crea-visura — Stili per il wizard di creazione visura
   ============================================================ */

/* Alpine.js: nasconde elementi x-cloak prima dell'inizializzazione */
[x-cloak] { display: none !important; }

/* ── Contenitore principale ──────────────────────────────── */

.vn-crea-visura {
    max-width: 640px;
    margin: 2rem auto;
    padding: 0 1rem;
    font-family: inherit;
}

/* ── Passo ───────────────────────────────────────────────── */

.vn-crea-visura-step {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ── Intestazione del passo ──────────────────────────────── */

.vn-crea-visura-intestazione {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 1rem;
}

.vn-crea-visura-numero-step {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.vn-crea-visura-titolo-step {
    margin: 0 0 0.25rem;
    font-size: 1.375rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}

.vn-crea-visura-sottotitolo-step {
    margin: 0;
    font-size: 0.9rem;
    color: #6b7280;
}

.vn-crea-visura-citta-selezionata {
    color: #374151;
}

/* ── Messaggi di errore ──────────────────────────────────── */

.vn-crea-visura-errore {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #b91c1c;
    font-size: 0.9rem;
}

.vn-crea-visura-avviso {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    color: #92400e;
    font-size: 0.9rem;
}

.vn-crea-visura-completata {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    min-height: 60vh;
    padding: 1rem;
    color: #065f46;
    font-size: 0.95rem;
    text-align: center;
}

.vn-crea-visura-completata p {
    margin: 0;
}

.vn-crea-visura-completata-loader {
    width: 3rem;
    height: 3rem;
    border: 4px solid #d1d5db;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: vn-spin 0.7s linear infinite;
}

/* ── Campi del form ──────────────────────────────────────── */

.vn-crea-visura-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.vn-crea-visura-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.vn-crea-visura-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.vn-crea-visura-label-nota {
    font-weight: 400;
    color: #9ca3af;
    margin-left: 0.25rem;
}

.vn-crea-visura-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    color: #111827;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.vn-crea-visura-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.vn-crea-visura-input--errore {
    border-color: #ef4444;
}

.vn-crea-visura-input--errore:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.vn-crea-visura-hint {
    margin: 0;
    font-size: 0.8rem;
    color: #9ca3af;
}

/* ── Riga via + civico ───────────────────────────────────── */

.vn-crea-visura-indirizzo-row {
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
}

.vn-crea-visura-indirizzo-row .vn-crea-visura-field--autocomplete {
    flex: 1 1 auto;
    min-width: 0;
}

.vn-crea-visura-field--civico {
    flex: 0 0 auto;
}

.vn-crea-visura-input--civico {
    width: calc(5ch + 1.75rem + 2px);
}

/* ── Autocomplete città ──────────────────────────────────── */

.vn-crea-visura-field--autocomplete {
    position: relative;
}

.vn-crea-visura-autocomplete-wrapper {
    position: relative;
}

.vn-crea-visura-autocomplete-lista {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 100;
    margin: 0;
    padding: 0;
    list-style: none;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 240px;
    overflow-y: auto;
}

.vn-crea-visura-autocomplete-voce {
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
    color: #374151;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    outline: none;
}

.vn-crea-visura-autocomplete-voce:last-child {
    border-bottom: none;
}

.vn-crea-visura-autocomplete-voce:hover,
.vn-crea-visura-autocomplete-voce:focus {
    background: #f5f3ff;
    color: #4338ca;
}

/* ── Fieldset e liste di selezione ──────────────────────── */

.vn-crea-visura-fieldset {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem;
    margin: 0;
}

.vn-crea-visura-legend {
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
}

/* Lista listini */

.vn-crea-visura-lista-listini {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.vn-crea-visura-listino-item {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: border-color 0.15s, background 0.15s;
}

.vn-crea-visura-listino-item:has(.vn-crea-visura-listino-radio:checked) {
    border-color: #6366f1;
    background: #f5f3ff;
}

.vn-crea-visura-listino-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
}

.vn-crea-visura-listino-radio {
    margin-top: 0.125rem;
    accent-color: #6366f1;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.vn-crea-visura-listino-titolo {
    font-weight: 600;
    color: #111827;
    display: block;
}

.vn-crea-visura-listino-descrizione {
    font-size: 0.825rem;
    color: #6b7280;
    display: block;
    margin-top: 0.125rem;
}

/* Lista tipi di valore */

.vn-crea-visura-lista-tipi {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.625rem;
}

.vn-crea-visura-tipo-item {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: border-color 0.15s, background 0.15s;
}

.vn-crea-visura-tipo-item:has(.vn-crea-visura-tipo-radio:checked) {
    border-color: #6366f1;
    background: #f5f3ff;
}

.vn-crea-visura-tipo-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
    height: 100%;
    box-sizing: border-box;
}

.vn-crea-visura-tipo-radio {
    margin-top: 0.125rem;
    accent-color: #6366f1;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.vn-crea-visura-tipo-titolo {
    font-weight: 600;
    color: #111827;
    display: block;
}

.vn-crea-visura-tipo-sottotipi {
    font-size: 0.775rem;
    color: #6b7280;
    display: block;
    margin-top: 0.25rem;
}

/* Nota di consultazione */

.vn-crea-visura-note-consultazione {
    margin-top: 1.25rem;
}

.vn-crea-visura-note-consultazione-label {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
}

.vn-crea-visura-note-consultazione-checkbox {
    margin-top: 0.125rem;
    accent-color: #6366f1;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* ── Pulsanti ────────────────────────────────────────────── */

.vn-crea-visura-azioni {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.vn-crea-visura-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
}

.vn-crea-visura-btn--primario {
    background: #6366f1;
    color: #ffffff;
}

.vn-crea-visura-btn--primario:hover {
    background: #4f46e5;
}

.vn-crea-visura-btn:disabled,
.vn-crea-visura-btn--disabilitato {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Indicatore di caricamento (HTMX) ───────────────────── */

.vn-crea-visura-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    opacity: 0;
    transition: opacity 200ms ease;
    pointer-events: none;
}

.htmx-request .vn-crea-visura-loading,
.vn-crea-visura-loading.htmx-request {
    opacity: 1;
}

.vn-crea-visura-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #d1d5db;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: vn-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes vn-spin {
    to { transform: rotate(360deg); }
}
