/**
 * Configuratore Prodotti - Stili
 * Version: 1.0.0
 */

/* ========================================
   Variabili CSS
   ======================================== */
:root {
    --primary-color: #2271b1;
    --primary-hover: #135e96;
    --secondary-color: #f0f0f1;
    --success-color: #00a32a;
    --error-color: #d63638;
    --text-color: #1d2327;
    --border-color: #c3c4c7;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* ========================================
   Container principale
   ======================================== */
.configuratore-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 30px;
    background: #ffffff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.configuratore-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   Barra di progressione
   ======================================== */
.configuratore-progress {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--secondary-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-text {
    text-align: center;
    font-size: 16px;
    color: #666;
    font-weight: 600;
}

.progress-percentage {
    color: var(--primary-color);
    font-size: 18px;
}

/* ========================================
   Domande
   ======================================== */
.question-wrapper {
    min-height: 300px;
    animation: fadeIn 0.4s ease;
}

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

.question-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 15px;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.question-subtitle {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 30px;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.question-content {
    margin-bottom: 30px;
}

/* ========================================
   Opzioni - Image Cards
   ======================================== */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.option-card {
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.option-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.option-card.selected {
    border-color: var(--primary-color);
    background: #f0f6fc;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.option-image {
    width: 100%;
    height: 150px;
    margin-bottom: 15px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.option-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    margin-top: 10px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.3;
}

.additional-text-field {
    width: 100%;
    margin-top: 15px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

/* ========================================
   Opzioni - Buttons
   ======================================== */
.options-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.option-button {
    padding: 15px 25px;
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.5;
    display: block;
    overflow: visible;
    min-height: 48px;
}

.option-button:hover {
    border-color: var(--primary-color);
    background: #f0f6fc;
}

.option-button.selected {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
}

/* ========================================
   Input numerici
   ======================================== */
.number-input,
.number-select {
    width: 100%;
    max-width: 300px;
    padding: 12px 20px;
    font-size: 18px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    margin: 0 auto;
    display: block;
}

.number-input:focus,
.number-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.unknown-option {
    text-align: center;
    margin-top: 20px;
}

.unknown-option label {
    font-size: 16px;
    cursor: pointer;
}

.unknown-checkbox {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ========================================
   Box Prezzo TEST
   ======================================== */
.price-preview-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 40px;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.price-preview-loading {
    text-align: center;
    font-size: 18px;
    padding: 20px;
}

.price-preview-header h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    text-align: center;
    color: white;
}

.price-preview-main {
    text-align: center;
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.price-preview-total {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.price-preview-range {
    font-size: 16px;
    opacity: 0.9;
}

.price-preview-breakdown {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.price-preview-breakdown h4 {
    margin: 0 0 15px 0;
    color: var(--text-color);
    font-size: 18px;
}

.price-preview-breakdown table {
    width: 100%;
    border-collapse: collapse;
}

.price-preview-breakdown td {
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
    color: var(--text-color);
}

.price-preview-breakdown td:first-child {
    text-align: left;
}

.price-preview-breakdown td:last-child {
    text-align: right;
    font-weight: 600;
}

.price-preview-breakdown tr.total td {
    border-top: 2px solid var(--primary-color);
    border-bottom: none;
    padding-top: 15px;
    font-size: 18px;
    color: var(--primary-color);
}

.price-preview-notes {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.price-note {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    color: #856404;
    padding: 12px 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.price-note:last-child {
    margin-bottom: 0;
}

.price-preview-disclaimer {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-color);
}

.price-preview-disclaimer p {
    margin: 0;
}

.price-preview-disclaimer strong {
    color: var(--primary-color);
}

/* ========================================
   Form finale
   ======================================== */
.configuratore-form {
    max-width: 600px;
    margin: 0 auto;
}

.form-field {
    margin-bottom: 25px;
}

.form-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-color);
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    transition: var(--transition);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.form-field textarea {
    resize: vertical;
    min-height: 100px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-weight: 400 !important;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ========================================
   Navigazione
   ======================================== */
.configuratore-navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-prev,
.btn-next,
.btn-submit {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.btn-prev {
    background: var(--secondary-color);
    color: var(--text-color);
}

.btn-prev:hover {
    background: #dcdcde;
}

.btn-next,
.btn-submit {
    background: var(--primary-color);
    color: #fff;
    margin-left: auto;
}

.btn-next:hover,
.btn-submit:hover {
    background: var(--primary-hover);
}

.btn-submit {
    width: 100%;
    padding: 15px 30px;
    font-size: 18px;
    margin-top: 20px;
}

/* ========================================
   Completamento
   ======================================== */
.completion-message {
    text-align: center;
    padding: 60px 20px;
}

.completion-icon {
    width: 80px;
    height: 80px;
    background: var(--success-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    margin: 0 auto 30px;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.completion-message h2 {
    font-size: 32px;
    margin-bottom: 15px;
    color: var(--text-color);
}

.completion-message p {
    font-size: 18px;
    color: #666;
}

/* ========================================
   Riepilogo risposte
   ======================================== */
.response-summary {
    margin-top: 40px;
    padding: 25px;
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    text-align: left;
}

.response-summary h3 {
    font-size: 20px;
    margin-bottom: 20px;
}

.response-summary ul {
    list-style: none;
    padding: 0;
}

.response-summary li {
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
}

.response-summary li:last-child {
    border-bottom: none;
}

.response-summary strong {
    color: var(--text-color);
}

/* ========================================
   File Upload
   ======================================== */
.file-upload-wrapper {
    margin-top: 15px;
}

.file-upload {
    width: 100%;
    padding: 10px;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

.file-upload:hover {
    border-color: var(--primary-color);
}

/* ========================================
   Utility
   ======================================== */
.mt-2 {
    margin-top: 10px;
}

/* ========================================
   Responsive
   ======================================== */

/* Tablet Landscape (fino a 1024px) */
@media (max-width: 1024px) {
    .configuratore-container {
        max-width: 100%;
        margin: 30px 20px;
        padding: 25px;
    }

    .options-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 15px;
    }

    .question-title {
        font-size: 26px;
    }

    .question-subtitle {
        font-size: 19px;
    }

    .price-preview-total {
        font-size: 42px;
    }

    .price-preview-breakdown {
        padding: 18px;
    }
}

/* Tablet Portrait (fino a 768px) */
@media (max-width: 768px) {
    .configuratore-container {
        padding: 20px;
        margin: 20px 10px;
        border-radius: 6px;
    }

    .options-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }

    .question-title {
        font-size: 24px;
        margin-bottom: 12px;
    }

    .question-subtitle {
        font-size: 18px;
        margin-bottom: 25px;
    }

    .question-wrapper {
        min-height: 250px;
    }

    /* Barra di progressione */
    .configuratore-progress {
        margin-bottom: 25px;
    }

    .progress-bar {
        height: 6px;
    }

    .progress-text {
        font-size: 14px;
    }

    .progress-percentage {
        font-size: 16px;
    }

    /* Opzioni */
    .option-card {
        padding: 15px;
    }

    .option-image {
        height: 130px;
    }

    .option-label {
        font-size: 15px;
    }

    .option-button {
        padding: 12px 20px;
        font-size: 15px;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: break-word;
        line-height: 1.5;
        min-height: 48px;
        height: auto;
    }

    /* Prezzo */
    .price-preview-box {
        padding: 25px 20px;
        margin-bottom: 30px;
    }

    .price-preview-header h3 {
        font-size: 22px;
        margin-bottom: 15px;
    }

    .price-preview-total {
        font-size: 38px;
    }

    .price-preview-range {
        font-size: 15px;
    }

    .price-preview-breakdown {
        padding: 15px;
    }

    .price-preview-breakdown h4 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .price-preview-breakdown td {
        padding: 8px 0;
        font-size: 14px;
    }

    .price-preview-breakdown tr.total td {
        font-size: 16px;
    }

    /* Form */
    .configuratore-form {
        max-width: 100%;
    }

    .form-field {
        margin-bottom: 20px;
    }

    .form-field label {
        font-size: 14px;
    }

    .form-field input[type="text"],
    .form-field input[type="email"],
    .form-field input[type="tel"],
    .form-field select,
    .form-field textarea {
        padding: 10px 12px;
        font-size: 14px;
    }

    /* Navigazione */
    .configuratore-navigation {
        flex-direction: column;
        gap: 12px;
        margin-top: 25px;
    }

    .btn-prev,
    .btn-next,
    .btn-submit {
        width: 100%;
        padding: 14px 25px;
        font-size: 15px;
    }

    .btn-next {
        margin-left: 0;
    }

    .btn-submit {
        padding: 16px 25px;
        font-size: 17px;
    }

    /* Input numerici */
    .number-input,
    .number-select {
        max-width: 100%;
        padding: 10px 15px;
        font-size: 16px;
    }

    /* Completamento */
    .completion-message {
        padding: 40px 15px;
    }

    .completion-icon {
        width: 70px;
        height: 70px;
        font-size: 42px;
        margin-bottom: 25px;
    }

    .completion-message h2 {
        font-size: 28px;
    }

    .completion-message p {
        font-size: 16px;
    }

    /* Riepilogo */
    .response-summary {
        margin-top: 30px;
        padding: 20px;
    }

    .response-summary h3 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .response-summary li {
        padding: 8px 0;
        font-size: 14px;
    }
}

/* Mobile (fino a 480px) */
@media (max-width: 480px) {
    .configuratore-container {
        padding: 15px;
        margin: 15px 5px;
        border-radius: 4px;
    }

    /* Titoli */
    .question-title {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .question-subtitle {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .question-wrapper {
        min-height: 200px;
    }

    /* Progressione */
    .configuratore-progress {
        margin-bottom: 20px;
    }

    .progress-bar {
        height: 5px;
    }

    .progress-text {
        font-size: 13px;
    }

    .progress-percentage {
        font-size: 15px;
    }

    /* Griglia opzioni */
    .options-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .option-card {
        padding: 12px;
    }

    .option-image {
        height: 120px;
    }

    .option-label {
        font-size: 14px;
        margin-top: 8px;
    }

    .option-button {
        padding: 12px 15px;
        font-size: 14px;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: break-word;
        line-height: 1.5;
        min-height: 48px;
        height: auto;
    }

    .options-buttons {
        gap: 10px;
    }

    /* Prezzo */
    .price-preview-box {
        padding: 20px 15px;
        margin-bottom: 25px;
        border-radius: 8px;
    }

    .price-preview-header h3 {
        font-size: 19px;
        margin-bottom: 12px;
    }

    .price-preview-main {
        padding: 15px;
    }

    .price-preview-total {
        font-size: 32px;
        margin-bottom: 8px;
    }

    .price-preview-range {
        font-size: 14px;
    }

    .price-preview-breakdown {
        padding: 12px;
    }

    .price-preview-breakdown h4 {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .price-preview-breakdown td {
        padding: 6px 0;
        font-size: 13px;
    }

    .price-preview-breakdown tr.total td {
        font-size: 15px;
        padding-top: 12px;
    }

    .price-note {
        padding: 10px 12px;
        font-size: 13px;
    }

    .price-preview-disclaimer {
        padding: 12px;
        font-size: 13px;
    }

    /* Form */
    .form-field {
        margin-bottom: 18px;
    }

    .form-field label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .form-field input[type="text"],
    .form-field input[type="email"],
    .form-field input[type="tel"],
    .form-field select,
    .form-field textarea {
        padding: 10px;
        font-size: 14px;
    }

    .form-field textarea {
        min-height: 80px;
    }

    .checkbox-label {
        gap: 8px;
        font-size: 13px;
    }

    .checkbox-label input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }

    /* Navigazione */
    .configuratore-navigation {
        gap: 10px;
        margin-top: 20px;
        padding-top: 15px;
    }

    .btn-prev,
    .btn-next,
    .btn-submit {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 5px;
    }

    .btn-submit {
        padding: 14px 20px;
        font-size: 16px;
        margin-top: 15px;
    }

    /* Input numerici */
    .number-input,
    .number-select {
        padding: 10px 12px;
        font-size: 15px;
    }

    .unknown-option label {
        font-size: 14px;
    }

    .unknown-checkbox {
        width: 16px;
        height: 16px;
        margin-right: 6px;
    }

    /* Completamento */
    .completion-message {
        padding: 30px 10px;
    }

    .completion-icon {
        width: 60px;
        height: 60px;
        font-size: 36px;
        margin-bottom: 20px;
    }

    .completion-message h2 {
        font-size: 24px;
        margin-bottom: 12px;
    }

    .completion-message p {
        font-size: 15px;
    }

    /* Riepilogo */
    .response-summary {
        margin-top: 25px;
        padding: 15px;
    }

    .response-summary h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .response-summary li {
        padding: 6px 0;
        font-size: 13px;
    }

    /* File upload */
    .file-upload-wrapper {
        margin-top: 12px;
    }

    .file-upload {
        padding: 8px;
    }

    /* Campo testo aggiuntivo */
    .additional-text-field {
        margin-top: 12px;
        padding: 8px;
        font-size: 13px;
    }
}

/* Mobile molto piccoli (fino a 360px) */
@media (max-width: 360px) {
    .configuratore-container {
        padding: 12px;
        margin: 10px 3px;
    }

    .question-title {
        font-size: 18px;
    }

    .question-subtitle {
        font-size: 15px;
    }

    .price-preview-total {
        font-size: 28px;
    }

    .price-preview-header h3 {
        font-size: 17px;
    }

    .completion-message h2 {
        font-size: 22px;
    }

    .btn-prev,
    .btn-next,
    .btn-submit {
        padding: 10px 15px;
        font-size: 13px;
    }

    .btn-submit {
        font-size: 15px;
    }
}

/* Ottimizzazioni per touch */
@media (hover: none) and (pointer: coarse) {
    /* Aumenta le aree cliccabili per dispositivi touch */
    .option-card,
    .option-button {
        min-height: 60px;
    }

    .btn-prev,
    .btn-next,
    .btn-submit {
        min-height: 48px;
    }

    .checkbox-label input[type="checkbox"],
    .unknown-checkbox {
        min-width: 20px;
        min-height: 20px;
    }

    /* Rimuove hover effects su touch devices */
    .option-card:hover,
    .option-button:hover,
    .btn-prev:hover,
    .btn-next:hover {
        transform: none;
    }

    /* Migliora l'area tap per input */
    .form-field input,
    .form-field select,
    .form-field textarea,
    .number-input,
    .number-select {
        min-height: 44px;
    }
}

/* Landscape mode su mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .configuratore-container {
        margin: 10px 20px;
        padding: 15px 20px;
    }

    .question-wrapper {
        min-height: 150px;
    }

    .configuratore-progress {
        margin-bottom: 15px;
    }

    .options-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .option-image {
        height: 100px;
    }

    .price-preview-box {
        padding: 15px;
        margin-bottom: 20px;
    }

    .price-preview-total {
        font-size: 32px;
    }

    .completion-message {
        padding: 20px 15px;
    }

    .completion-icon {
        width: 50px;
        height: 50px;
        font-size: 30px;
        margin-bottom: 15px;
    }
}

/* ========================================
   Temi personalizzabili
   ======================================== */
.configuratore-container[data-tema="dark"] {
    --primary-color: #4a90e2;
    --text-color: #ffffff;
    background: #1e1e1e;
    color: #ffffff;
}

.configuratore-container[data-tema="dark"] .option-card {
    background: #2a2a2a;
    border-color: #444;
}

.configuratore-container[data-tema="dark"] .option-card.selected {
    background: #3a4a5c;
    border-color: var(--primary-color);
}
