/*
 * Coded by Radici Soluzioni Informatiche per Mediafog srl
 * https://radici.biz
 * info@radici.biz
 */

/**
 * Mediazione Wizard - Stili CSS
 * Plugin WordPress per domande di mediazione
 */

/* ==========================================================================
   CONTENITORE PRINCIPALE
   ========================================================================== */

#mediazione-wizard {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ==========================================================================
   STEP DEL WIZARD
   ========================================================================== */

.mw-step {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mw-step h3 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #0073aa;
    color: #23282d;
    font-size: 1.4em;
}

/* ==========================================================================
   FORM ELEMENTI
   ========================================================================== */

.mw-step p {
    margin-bottom: 15px;
}

.mw-step label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #444;
}

.mw-step input[type="text"],
.mw-step input[type="email"],
.mw-step input[type="number"],
.mw-step input[type="date"],
.mw-step select,
.mw-step textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.mw-step input[type="text"]:focus,
.mw-step input[type="email"]:focus,
.mw-step input[type="number"]:focus,
.mw-step input[type="date"]:focus,
.mw-step select:focus,
.mw-step textarea:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
    outline: none;
}

.mw-step input[type="checkbox"] {
    margin-right: 8px;
}

.mw-step textarea {
    min-height: 100px;
    resize: vertical;
}

.mw-valore-field {
    margin-bottom: 15px;
}

.mw-auto-metadata {
    margin-top: 15px;
    padding: 12px 14px;
    border: 1px solid #d0def5;
    background: #f5f8ff;
    border-radius: 4px;
    color: #213452;
}

.mw-auto-metadata p {
    margin: 0 0 6px;
}

.mw-auto-metadata p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   FIELDSET
   ========================================================================== */

.mw-step fieldset {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    background: #fafafa;
}

.mw-step fieldset legend {
    font-weight: 600;
    color: #0073aa;
    padding: 0 10px;
    font-size: 1.1em;
}

/* ==========================================================================
   PARTI (BLOCCHI DINAMICI)
   ========================================================================== */

.mw-parte {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

.mw-parte legend {
    font-weight: 600;
    color: #23282d;
    background: #fff;
    padding: 5px 15px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.mw-parte p {
    display: inline-block;
    width: 48%;
    vertical-align: top;
    margin-right: 2%;
}

.mw-parte p:nth-child(even) {
    margin-right: 0;
}

/* Campi a larghezza piena (Telefono e Cellulare) */
.mw-parte p.mw-full-width {
    display: block;
    width: 100%;
    margin-right: 0;
}

@media (max-width: 600px) {
    .mw-parte p {
        display: block;
        width: 100%;
        margin-right: 0;
    }
}

/* ==========================================================================
   BOTTONI
   ========================================================================== */

.mw-step button {
    display: inline-block;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.1s;
    margin-right: 10px;
    margin-top: 15px;
}

.mw-next-step,
.mw-submit {
    background-color: #0073aa;
    color: #fff;
}

.mw-next-step:hover,
.mw-submit:hover {
    background-color: #005a87;
}

.mw-prev-step {
    background-color: #f0f0f0;
    color: #444;
    border: 1px solid #ccc;
}

.mw-prev-step:hover {
    background-color: #e0e0e0;
}

button:active {
    transform: translateY(1px);
}

/* ==========================================================================
   RISULTATO / MESSAGGI
   ========================================================================== */

#mw-result {
    padding: 15px 20px;
    border-radius: 4px;
    font-size: 14px;
}

#mw-result:empty {
    display: none;
}

#mw-result.mw-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

#mw-result.mw-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

#mw-result.mw-loading {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    #mediazione-wizard {
        padding: 10px;
    }
    
    .mw-step {
        padding: 15px;
    }
    
    .mw-step h3 {
        font-size: 1.2em;
    }
    
    .mw-step button {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
}

/* ==========================================================================
   INDICATORE STEP
   ========================================================================== */

.mw-step-indicator {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.mw-step-indicator .step {
    display: flex;
    align-items: center;
    margin: 0 10px;
}

.mw-step-indicator .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ddd;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 8px;
}

.mw-step-indicator .step.active .step-number {
    background: #0073aa;
    color: #fff;
}

.mw-step-indicator .step.completed .step-number {
    background: #46b450;
    color: #fff;
}

.mw-step-indicator .step-label {
    font-size: 13px;
    color: #666;
}

.mw-step-indicator .step.active .step-label {
    color: #0073aa;
    font-weight: 500;
}

/* ==========================================================================
   VALIDAZIONE
   ========================================================================== */

.mw-step input:invalid,
.mw-step select:invalid,
.mw-step textarea:invalid {
    border-color: #dc3545;
}

.mw-step input:valid,
.mw-step select:valid,
.mw-step textarea:valid {
    border-color: #28a745;
}

.mw-field-error {
    border-color: #dc3545 !important;
    background-color: #fff5f5;
    box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.15);
}

/* Solo mostra validazione dopo che l'utente ha interagito */
.mw-step input:not(:focus):not(:placeholder-shown):invalid,
.mw-step select:not(:focus):invalid,
.mw-step textarea:not(:focus):not(:placeholder-shown):invalid {
    border-color: #dc3545;
    background-color: #fff5f5;
}

/* ==========================================================================
   CAMPI OBBLIGATORI
   ========================================================================== */

.mw-required::after {
    content: " *";
    color: #dc3545;
}

/* ==========================================================================
   AUTOCOMPLETE CITTÀ
   ========================================================================== */

.mw-city-field {
    position: relative;
}

.mw-autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    list-style: none;
    margin: 0;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
}

.mw-autocomplete-list li {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    transition: background-color 0.15s;
}

.mw-autocomplete-list li:last-child {
    border-bottom: none;
}

.mw-autocomplete-list li:hover,
.mw-autocomplete-list li.focused {
    background-color: #0073aa;
    color: #fff;
}

/* Campo sola lettura (Provincia e CAP auto-compilati) */
.mw-step input[readonly] {
    background-color: #f5f5f5;
    color: #666;
    cursor: not-allowed;
    border-color: #ddd;
}

.mw-step input[readonly]:focus {
    border-color: #ddd;
    box-shadow: none;
}

/* ==========================================================================
   CAMPI IMPRESA / PERSONA FISICA
   ========================================================================== */

.mw-persona-fisica-fields,
.mw-impresa-fields {
    transition: opacity 0.2s ease;
}

.mw-impresa-fields p,
.mw-persona-fisica-fields p {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   MOBILE IMPROVEMENTS
   ========================================================================== */

@media (max-width: 600px) {
    .mw-autocomplete-list {
        max-height: 150px;
    }
    
    .mw-autocomplete-list li {
        padding: 12px 15px;
        font-size: 16px; /* Larger touch target */
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .mw-autocomplete-list li {
        padding: 14px 15px;
    }
}

/* ==========================================================================
   MATERIE CHECKBOXES SECTION
   ========================================================================== */

.mw-materie-section {
    margin-top: 15px;
    margin-bottom: 15px;
}

.mw-materie-section > label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #23282d;
}

.mw-materie-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mw-materie-checkboxes label {
    display: flex;
    align-items: flex-start;
    width: calc(50% - 5px); /* Half of gap (10px / 2) for proper spacing */
    padding: 8px 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 400;
    transition: background-color 0.2s, border-color 0.2s;
    box-sizing: border-box;
}

.mw-materie-checkboxes label:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.mw-materie-checkboxes input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 2px;
    flex-shrink: 0;
}

#materia_specificare_field {
    margin-top: 15px;
}

@media (max-width: 600px) {
    .mw-materie-checkboxes label {
        width: 100%;
    }
}
