/* Palette */
:root {
  --color-primary: #78b1a2;
  --color-accent: #cc4999;
  --color-bg: #ffffff;
  --color-text: #222222;
  --color-muted: #6b7280;
  --border: #e5e7eb;
  /* Estensioni palette per header e ombre */
  --header-from: #76b3a4;
  --header-to: #9fd2c7;
  --shadow-1: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-2: 0 8px 20px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.gtest-page { max-width: 960px; margin: 0 auto; padding: 24px; }
.gtest-header {
  margin-bottom: 16px;
  padding: 20px 16px;
  background: linear-gradient(135deg, var(--header-from), var(--header-to));
  border-radius: 16px;
  box-shadow: var(--shadow-1);
}
.gtest-header h1 { margin: 0; color: #ffffff; font-size: 28px; line-height: 1.2; font-weight: 700; }
.gtest-header p { margin: 4px 0 0; color: #edf7f4; font-size: 15px; }
.gtest-brand { display: flex; align-items: center; gap: 12px; }
.gtest-logo { height: 40px; width: auto; object-fit: contain; }
@media (min-width: 768px) { .gtest-logo { height: 48px; } }
.gtest-footer { margin-top: 24px; color: var(--color-muted); }

.gtest-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-1);
}

.gtest-root {}
.gtest-title h2 { margin: 0; color: var(--color-primary); }
.gtest-title p { margin: 6px 0 12px; color: var(--color-muted); }

/* Scala tipografica base */
h1, .h1 { font-size: 32px; line-height: 1.2; font-weight: 700; }
h2, .h2 { font-size: 24px; line-height: 1.25; font-weight: 700; }
h3, .h3 { font-size: 20px; line-height: 1.3; font-weight: 600; }
p, .text { font-size: 16px; line-height: 1.6; }
small, .small { font-size: 12px; line-height: 1.5; color: var(--color-muted); }

.gtest-status { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.gtest-status.info { background: rgba(120,177,162,0.12); color: var(--color-primary); border: 1px solid var(--color-primary); }
.gtest-status.warn { background: #fff7ed; color: #b45309; border: 1px solid #fbbf24; }
.gtest-status.error { background: #fee2e2; color: #b91c1c; border: 1px solid #ef4444; }
.hidden { display: none; }

.gtest-view { min-height: 220px; }
.gtest-progress { color: var(--color-muted); margin-bottom: 8px; font-weight: 600; }
.gtest-question { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.gtest-question-title { font-weight: 600; margin-bottom: 10px; }
.gtest-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.gtest-answer { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); padding: 10px; border-radius: 10px; cursor: pointer; transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease; }
.gtest-answer:hover { border-color: var(--color-primary); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.gtest-answer input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.gtest-answer .emoji { font-size: 22px; line-height: 1; display: inline-block; width: 24px; text-align: center; }
.gtest-answer .text { flex: 1; }
.gtest-answer .answer-title { display: block; font-weight: 600; color: var(--color-text); }
.gtest-answer .answer-desc { display: block; font-size: 13px; color: var(--color-muted); margin-top: 2px; }
.gtest-answer.selected { border-color: var(--color-primary); box-shadow: 0 2px 8px rgba(120,177,162,0.12); background-color: rgba(120,177,162,0.10); }
.gtest-answer.selected .emoji { transform: scale(1.06); }

.gtest-actions { display: flex; gap: 8px; margin-top: 14px; }
.gtest-result-actions { display: flex; justify-content: flex-start; margin: 12px 0; position: relative; }
.gtest-cta-annot { margin-left: 8px; color: var(--color-accent); font-weight: 700; }
.gtest-heat-dot { position: absolute; border-radius: 999px; background: rgba(204,73,153,0.25); pointer-events: none; transform: translate(-50%, -50%); }
.gtest-metrics { margin-top: 8px; font-size: 12px; color: var(--color-muted); }
.gtest-metrics strong { color: var(--color-text); }
.gtest-btn { border-radius: 10px; padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease; }
.gtest-btn.primary { background: var(--color-primary); color: #fff; border: 1px solid var(--color-primary); box-shadow: 0 2px 8px rgba(120,177,162,0.35); }
.gtest-btn.primary:hover { filter: brightness(1.04); transform: translateY(-1px); }
.gtest-btn.outline { background: #fff; color: var(--color-primary); border: 1px solid var(--color-primary); }
.gtest-btn.primary:hover { filter: brightness(0.97); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(120,177,162,0.35); }
.gtest-btn.outline:hover { background: rgba(120,177,162,0.08); transform: translateY(-1px); }

/* Contenitore CTA dentro il riquadro del punteggio */
.gtest-cta-box { margin-top: 12px; display: flex; align-items: center; gap: 8px; }

/* Icona email nel bottone CTA */
.gtest-btn .icon { display: inline-flex; width: 16px; height: 16px; align-items: center; justify-content: center; }
.gtest-btn .icon img { display: block; width: 100%; height: 100%; }
.gtest-btn .label { display: inline-block; line-height: 1.2; }

/* Video verticale nella pagina risultati */
.gtest-result-video { margin-top: 12px; width: 100%; max-width: 360px; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: #000; }
.gtest-result-video iframe, .gtest-result-video video { width: 100%; height: 100%; border: 0; display: block; }
.gtest-result-video video { object-fit: cover; }

.gtest-result { margin-top: 16px; }
.gtest-result-box { border: 1px solid var(--border); border-radius: 16px; padding: 16px; background: #fff; box-shadow: var(--shadow-1); }
.gtest-result-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.gtest-result-icon img { width: 56px; height: 56px; display: block; }
.gtest-score { font-size: 20px; margin-bottom: 4px; color: var(--color-accent); }
.gtest-band { color: var(--color-text); }
.gtest-generic { color: var(--color-muted); }
.gtest-level { margin-top: 6px; }
.gtest-level-badge { display: inline-block; padding: 6px 10px; border-radius: 999px; font-weight: 600; border: 1px solid var(--border); }
.gtest-level-toggle { margin-top: 8px; background: transparent; border: none; color: var(--color-accent); font-weight: 600; cursor: pointer; }
.gtest-level-toggle:hover { text-decoration: underline; }
.gtest-level-panel { display: none; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: #fff; }
.gtest-level-panel.open { display: block; }
.gtest-level-desc p { margin: 0 0 6px; color: var(--color-text); }
.gtest-level-desc ul { margin: 0; padding-left: 18px; color: var(--color-muted); }

/* Varianti visive per fasce */
.gtest-result-box.band-low { border-color: #78b1a2; background: linear-gradient(180deg, #f8fffd 0%, #ffffff 100%); }
.gtest-result-box.band-moderate { border-color: #f59e0b; background: linear-gradient(180deg, #fff7ed 0%, #ffffff 100%); }
.gtest-result-box.band-high { border-color: #ef4444; background: linear-gradient(180deg, #fef2f2 0%, #ffffff 100%); }
.gtest-result-box.band-very-high { border-color: #cc4999; background: linear-gradient(180deg, #fff0f7 0%, #ffffff 100%); }

.band-low .gtest-level-badge { background: #e6f5f1; border-color: #78b1a2; color: #0f766e; }
.band-moderate .gtest-level-badge { background: #fff4e6; border-color: #f59e0b; color: #92400e; }
.band-high .gtest-level-badge { background: #fee2e2; border-color: #ef4444; color: #7f1d1d; }
.band-very-high .gtest-level-badge { background: #ffe6f2; border-color: #cc4999; color: #7a1c52; }

.gtest-summary { margin-top: 16px; }
.gtest-summary-title { font-weight: 700; color: var(--color-primary); margin-bottom: 8px; }
.gtest-summary-list { display: grid; gap: 8px; }
.gtest-summary-item { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--border); background: #fff; border-radius: 10px; cursor: pointer; transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease; }
.gtest-summary-item:hover { border-color: var(--color-primary); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.gtest-summary-item .q { color: var(--color-text); font-weight: 600; }
.gtest-summary-item .a { color: var(--color-muted); }

.gtest-form { display: grid; gap: 12px; }
.gtest-field label { display: block; font-weight: 600; margin-bottom: 4px; }
.gtest-field input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.gtest-checkbox { display: flex; align-items: center; gap: 8px; }
.gtest-error { color: #b91c1c; background: #fee2e2; border: 1px solid #ef4444; padding: 10px; border-radius: 8px; }

/* Evidenza campi obbligatori e errori inline */
.gtest-field .required-star { color: #b91c1c; margin-left: 4px; }
.gtest-field-error { color: #b91c1c; font-size: 12px; margin-top: 4px; }
.gtest-field.invalid input { border-color: #ef4444; background: #fff7f7; }
.gtest-field.invalid label { color: #b91c1c; }
.gtest-checkbox.invalid { color: #b91c1c; }

.gtest-analysis { display: grid; gap: 10px; }
.gtest-analysis-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #fff; }
.gtest-analysis-q { font-weight: 600; margin-bottom: 6px; }
.gtest-analysis-a { margin-bottom: 6px; }
.gtest-analysis-s { color: var(--color-muted); }

/* Vista stato post invio */
.gtest-status-view { display: grid; gap: 12px; }
.gtest-status-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fff; box-shadow: var(--shadow-1); }
.gtest-status-card.info { border-color: var(--color-primary); }
.gtest-status-card.success { border-color: #78b1a2; background: #f8fffd; color: #0f766e; }
.gtest-status-card.error { border-color: #ef4444; background: #fff7f7; color: #b91c1c; }

@media (max-width: 640px) {
  .gtest-page { padding: 16px; }
  .gtest-answers { grid-template-columns: 1fr; }
}

/* Animazioni transizione */
.slide-in { animation: slideIn 200ms ease-out; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}
/* Admin Brevo */
.gtest-admin-toggle { position: fixed; bottom: 16px; right: 16px; padding: 10px 12px; background: var(--color-accent); color: #fff; border: none; border-radius: 10px; font-weight: 600; box-shadow: 0 3px 10px rgba(0,0,0,.1); cursor: pointer; z-index: 1000; }
.gtest-admin-toggle:hover { filter: brightness(1.05); transform: translateY(-1px); }
.gtest-admin-panel { position: fixed; bottom: 60px; right: 16px; width: 340px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.12); z-index: 999; }
.gtest-admin-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.gtest-admin-field.inline { flex-direction: row; align-items: center; gap: 8px; }
.gtest-admin-field label { font-size: 12px; color: #666; }
.gtest-admin-field input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.gtest-admin-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
/* Modal password per l’admin */
.gtest-admin-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 1001; }
.gtest-admin-modal.show { display: flex; }
.gtest-admin-modal .box { background: #fff; padding: 16px; border-radius: 10px; width: 320px; box-shadow: 0 3px 12px rgba(0,0,0,.2); }
.gtest-admin-modal .box h3 { margin: 0 0 10px; font-size: 18px; }
.gtest-admin-modal .box label { display: block; font-weight: 600; margin-bottom: 6px; }
.gtest-admin-modal .box input.pwd { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.gtest-admin-modal .box .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }