/* ============================================================
   FORM VALUTAZIONE CONTENTTEZZA — STILE CSS
   Tema: pulito, professionale, colori che ispirano pulizia
   (azzurri, bianchi, verdi)
   ============================================================ */

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #e8f4f8 0%, #d1ecf1 50%, #c3e6cb 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  color: #2d3748;
  line-height: 1.6;
}

/* ---------- WRAPPER ---------- */
.form-wrapper {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(0, 0, 0, 0.04);
  max-width: 640px;
  width: 100%;
  padding: 2.5rem 2rem;
  transition: transform 0.3s ease;
}

@media (max-width: 480px) {
  .form-wrapper {
    padding: 1.5rem 1.25rem;
    border-radius: 12px;
  }
}

/* ---------- HEADER ---------- */
.form-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #e8f4f8;
}

.form-header h1 {
  font-size: 1.6rem;
  color: #1a73b2;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.form-header p {
  font-size: 0.95rem;
  color: #64748b;
}

/* ---------- SEZIONI ---------- */
.form-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #f1f5f9;
}

.form-section:last-of-type {
  border-bottom: none;
}

.form-section h2 {
  font-size: 1.15rem;
  color: #1a73b2;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.section-hint {
  font-size: 0.875rem;
  color: #94a3b8;
  margin-bottom: 1rem;
}

/* ---------- RATING (1-10) — Layout multi-domanda ---------- */

/* ===== LEGENDA ===== */
.rating-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  color: #475569;
  font-weight: 500;
}

.legend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 28px;
  padding: 0 0.4rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.legend-badge.badge-red {
  background: #fef2f2;
  color: #dc2626;
  border: 2px solid #fca5a5;
}

.legend-badge.badge-orange {
  background: #fff7ed;
  color: #ea580c;
  border: 2px solid #fdba74;
}

.legend-badge.badge-yellow {
  background: #fefce8;
  color: #ca8a04;
  border: 2px solid #fde047;
}

.legend-badge.badge-green {
  background: #f0fdf4;
  color: #16a34a;
  border: 2px solid #86efac;
}

/* ===== DOMANDE RATING ===== */
.rating-question {
  margin-bottom: 1.75rem;
  padding: 1.25rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rating-question.has-answer {
  border-color: #86efac;
  background: #f0fdf4;
}

.rating-question.error-state {
  border-color: #fca5a5;
  background: #fef2f2;
}

.rating-question-title {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.925rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.rating-question-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1a73b2;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
}

.rating-question-text {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

.rating-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.rating-container input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.rating-container label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 42px;
  border-radius: 8px;
  background: #ffffff;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.rating-container label:hover {
  background: #d1ecf1;
  color: #1a73b2;
  transform: translateY(-2px);
}

/* --- Bordi rossi: 1-4 (Insufficienza grave) --- */
.rating-container label[data-value="1"],
.rating-container label[data-value="2"],
.rating-container label[data-value="3"],
.rating-container label[data-value="4"] {
  border-color: #fca5a5;
}

.rating-container label[data-value="1"]:hover,
.rating-container label[data-value="2"]:hover,
.rating-container label[data-value="3"]:hover,
.rating-container label[data-value="4"]:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #dc2626;
}

/* --- Bordi arancioni: 5-6 (Insufficienza) --- */
.rating-container label[data-value="5"],
.rating-container label[data-value="6"] {
  border-color: #fdba74;
}

.rating-container label[data-value="5"]:hover,
.rating-container label[data-value="6"]:hover {
  background: #fff7ed;
  color: #ea580c;
  border-color: #ea580c;
}

/* --- Bordi gialli: 7-8 (Sufficienza) --- */
.rating-container label[data-value="7"],
.rating-container label[data-value="8"] {
  border-color: #fde047;
}

.rating-container label[data-value="7"]:hover,
.rating-container label[data-value="8"]:hover {
  background: #fefce8;
  color: #ca8a04;
  border-color: #ca8a04;
}

/* --- Bordi verdi: 9-10 (Ottimo) --- */
.rating-container label[data-value="9"],
.rating-container label[data-value="10"] {
  border-color: #86efac;
}

.rating-container label[data-value="9"]:hover,
.rating-container label[data-value="10"]:hover {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #16a34a;
}

/* --- Stato selezionato (tutti) --- */
.rating-container input[type="radio"]:checked + label {
  color: #ffffff;
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

/* Rosso selezionato */
.rating-container input[type="radio"]:checked + label[data-value="1"],
.rating-container input[type="radio"]:checked + label[data-value="2"],
.rating-container input[type="radio"]:checked + label[data-value="3"],
.rating-container input[type="radio"]:checked + label[data-value="4"] {
  background: linear-gradient(135deg, #dc2626, #f87171);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.35);
}

/* Arancione selezionato */
.rating-container input[type="radio"]:checked + label[data-value="5"],
.rating-container input[type="radio"]:checked + label[data-value="6"] {
  background: linear-gradient(135deg, #ea580c, #fb923c);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(234, 88, 12, 0.35);
}

/* Giallo selezionato */
.rating-container input[type="radio"]:checked + label[data-value="7"],
.rating-container input[type="radio"]:checked + label[data-value="8"] {
  background: linear-gradient(135deg, #ca8a04, #facc15);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(202, 138, 4, 0.35);
}

/* Verde selezionato */
.rating-container input[type="radio"]:checked + label[data-value="9"],
.rating-container input[type="radio"]:checked + label[data-value="10"] {
  background: linear-gradient(135deg, #16a34a, #00b4d8);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(22, 163, 74, 0.35);
}

/* ---------- TEXTAREA ---------- */
.textarea-wrapper {
  position: relative;
}

textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  color: #2d3748;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #fafbfc;
}

textarea:focus {
  outline: none;
  border-color: #1a73b2;
  box-shadow: 0 0 0 3px rgba(26, 115, 178, 0.15);
  background: #ffffff;
}

textarea::placeholder {
  color: #cbd5e1;
}

/* ---------- CHAR COUNTER ---------- */
.char-counter {
  text-align: right;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 0.5rem;
  transition: color 0.2s ease;
}

.char-counter.valid {
  color: #16a34a;
  font-weight: 600;
}

.char-counter.invalid {
  color: #dc2626;
  font-weight: 600;
}

/* ---------- CHECKBOX CONSENSO ---------- */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.925rem;
  color: #475569;
  line-height: 1.5;
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkmark {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin-top: 2px;
}

.checkmark::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid transparent;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: all 0.15s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: linear-gradient(135deg, #1a73b2, #00b4d8);
  border-color: #1a73b2;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  border-color: #ffffff;
  transform: rotate(45deg) scale(1);
}

.checkbox-label:hover .checkmark {
  border-color: #1a73b2;
}

.hint-text {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 0.5rem;
  margin-left: calc(22px + 0.75rem);
}

/* ---------- INPUT GROUPS (obbligatori) ---------- */
.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.35rem;
}

/* Asterisco campo obbligatorio */
.required {
  color: #dc2626;
  font-weight: 700;
  margin-left: 2px;
}

.input-group input[type="text"],
.input-group input[type="email"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  color: #2d3748;
  background: #fafbfc;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: #1a73b2;
  box-shadow: 0 0 0 3px rgba(26, 115, 178, 0.15);
  background: #ffffff;
}

.input-group input::placeholder {
  color: #cbd5e1;
}

/* ---------- BOTTONE INVIO ---------- */
.btn-submit {
  display: block;
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #1a73b2, #00b4d8);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 15px rgba(26, 115, 178, 0.3);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(26, 115, 178, 0.4);
}

.btn-submit:active {
  transform: translateY(0);
}

.btn-submit:focus-visible {
  outline: 3px solid #00b4d8;
  outline-offset: 2px;
}

/* ---------- ERROR MESSAGES ---------- */
.error-msg {
  display: block;
  font-size: 0.825rem;
  color: #dc2626;
  margin-top: 0.5rem;
  padding-left: 0.25rem;
}

.error-msg[hidden] {
  display: none;
}

/* ---------- SUCCESS / ERROR MESSAGES (globali) ---------- */
.success-message,
.error-message {
  text-align: center;
  padding: 2rem;
  border-radius: 12px;
  margin-top: 1.5rem;
}

.success-message {
  background: #f0fdf4;
  border: 2px solid #86efac;
  color: #16a34a;
}

.error-message {
  background: #fef2f2;
  border: 2px solid #fca5a5;
  color: #dc2626;
}

.success-message[hidden],
.error-message[hidden] {
  display: none;
}

/* ---------- ACCESSIBILITY — screen reader only ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ---------- ANIMAZIONE ENTRATA ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-wrapper {
  animation: fadeInUp 0.5s ease-out;
}