/* ============================================
   Survey Page — Antherbis
   ============================================ */

/* --- CSS Variables --- */
:root {
  --primary: #0D5A2F;
  --primary-light: #0C582D;
  --accent: #76B82A;
  --accent-border: #23b865;
  --accent-active: #37c474;
  --yellow: #FFED00;
  --error: #B00020;
  --warning-bg: #ffdddd;
  --warning-text: #a94442;
  --white: #ffffff;
  --black: #000000;
  --gray-logo: #7C868C;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body.survey-page-body {
  font-family: Arial, Helvetica, sans-serif;
  background-color: var(--white);
  color: var(--black);
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}

body.survey-page-body .chaty-outer-forms,
body.survey-page-body .chaty.chaty-widget-0 {
  display: none !important;
}

img,
svg {
  user-select: none;
  -webkit-user-drag: none;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus {
  outline: none;
  box-shadow: none;
}

button::-moz-focus-inner {
  border: 0;
}

/* --- Steps visibility --- */
.survey-step {
  display: none;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  animation: fadeIn 0.4s ease;
}

.survey-step.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- Background --- */
.survey-background {
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  width: 100%;
  height: 100%;
  clip-path: polygon(0 8%, 80% 15%, 100% 100%, 0 100%);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.survey-background--full {
  clip-path: polygon(0 8%, 100% 15%, 100% 100%, 0 100%);
}

/* --- Logo --- */
.survey-logo {
  position: absolute;
  top: 15px;
  right: 20px;
  width: clamp(140px, 30vw, 280px);
  z-index: 10;
}

/* --- Home button --- */
.btn-home {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: none;
  padding: 0;
}

.btn-home svg {
  width: 44px;
  height: 44px;
}

/* --- Step content wrapper --- */
.step-content {
  position: relative;
  z-index: 5;
  padding: 20px;
  padding-top: 80px;
  max-width: 700px;
  margin: 0 auto;
}

/* ============================================
   STEP 1 — Home
   ============================================ */
.step1-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  padding-top: 100px;
}

.svg-ciao {
  width: clamp(260px, 65vw, 500px);
  filter: drop-shadow(-10px 10px 8px rgba(0, 0, 0, 0.45));
}

.svg-intro {
  width: clamp(300px, 80vw, 650px);
  filter: drop-shadow(-10px 5px 8px rgba(0, 0, 0, 0.45));
}

.btn-start {
  display: inline-block;
  background-color: var(--white);
  color: var(--primary);
  font-size: clamp(18px, 4vw, 28px);
  font-weight: bold;
  padding: 14px 48px;
  border-radius: 30px;
  margin-top: 12px;
  margin-left: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: background-color 0.15s, color 0.15s;
}

.btn-start:active {
  background-color: var(--accent-active);
  color: var(--white);
}

/* ============================================
   STEP 2 — Selezione
   ============================================ */
.step2-content {
  padding-top: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.svg-selection {
  width: clamp(300px, 90vw, 650px);
  filter: drop-shadow(-10px 5px 8px rgba(0, 0, 0, 0.45));
}

#options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  max-width: 700px;
  width: 100%;
  padding: 0 10px;
}

.option-btn {
  flex: 0 0 calc(50% - 8px);
  min-height: 56px;
  background-color: var(--primary);
  color: var(--white);
  border: 2px solid var(--accent-border);
  border-radius: 12px;
  font-size: clamp(13px, 2.6vw, 17px);
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 8px 10px;
  transition: background-color 0.15s, color 0.15s;
}

.option-btn.selected {
  background-color: var(--white);
  color: var(--primary);
}

.option-btn:active {
  opacity: 0.85;
}

.btn-submit {
  display: inline-block;
  background-color: var(--white);
  color: var(--primary);
  font-size: clamp(16px, 3.5vw, 24px);
  font-weight: bold;
  padding: 12px 40px;
  border-radius: 30px;
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: background-color 0.15s, color 0.15s, opacity 0.15s;
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-submit:not(:disabled):active {
  background-color: var(--accent-active);
  color: var(--white);
}

/* Loading overlay (Step 2 — chiamata API AI) */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}

.spinner--large {
  width: 72px;
  height: 72px;
  border-width: 6px;
}

/* Warning overlay & box */
.overlay-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
}

.warning-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--warning-bg);
  color: var(--warning-text);
  padding: 20px 30px;
  border-radius: 8px;
  font-weight: bold;
  font-size: clamp(16px, 3.5vw, 22px);
  text-align: center;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  max-width: 90%;
}

.warning-box--error {
  background-color: var(--white);
  color: var(--error);
}

/* ============================================
   STEP 3 — Registrazione
   ============================================ */
.step3-content {
  padding-top: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.svg-registration {
  width: clamp(300px, 85vw, 600px);
  filter: drop-shadow(-10px 5px 8px rgba(0, 0, 0, 0.45));
}

.form-container {
  width: 100%;
  max-width: 560px;
  background: rgba(255, 255, 255, 0.9);
  padding: 24px 20px;
  border-radius: 10px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  font-size: clamp(14px, 3vw, 18px);
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 4px;
}

.form-row label .required {
  color: var(--error);
}

.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="tel"] {
  width: 100%;
  height: 44px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 8px 12px;
  transition: border 0.2s, background-color 0.2s;
}

.form-row input:focus {
  border: 2px solid var(--accent);
  background-color: #f4fff0;
  outline: none;
}

.form-row input.input-error {
  border: 2px solid var(--error);
  background-color: #fff5f5;
}

/* Checkboxes */
.form-row--checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.form-row--checkbox label {
  font-weight: normal;
  font-size: clamp(13px, 2.5vw, 15px);
  line-height: 1.4;
  color: var(--black);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.form-row--checkbox input[type="checkbox"] {
  transform: scale(1.4);
  margin-top: 3px;
  flex-shrink: 0;
}

.privacy-link {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

/* Submit button */
.form-row--submit {
  text-align: center;
  margin-top: 10px;
}

.btn-submit-form {
  display: inline-block;
  padding: 12px 40px;
  font-size: clamp(18px, 4vw, 26px);
  font-weight: bold;
  background-color: var(--primary);
  color: var(--white);
  border-radius: 30px;
  transition: background-color 0.15s;
}

.btn-submit-form:active {
  background-color: var(--accent-active);
}

/* Privacy popup */
.privacy-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--white);
  color: var(--primary);
  padding: 30px 24px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.privacy-popup h2 {
  text-align: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.privacy-popup p {
  margin-bottom: 10px;
}

.privacy-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  font-size: 28px;
  color: var(--primary);
  font-weight: bold;
  line-height: 1;
}

/* ============================================
   STEP 4 — Prodotto
   ============================================ */
.step4-content {
  padding-top: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.product-title-heading {
  font-size: clamp(22px, 5vw, 36px);
  font-weight: bold;
  text-align: center;
  color: var(--black);
}

#product-container {
  width: 100%;
  max-width: 560px;
  text-align: center;
}

.product-loading {
  padding: 60px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--primary);
  font-size: 18px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(13, 90, 47, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.product-card {
  background: var(--white);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.product-card img {
  width: 100%;
  max-height: 350px;
  object-fit: contain;
  padding: 16px;
}

.product-info {
  padding: 20px;
  text-align: left;
}

.product-info h3 {
  font-size: clamp(20px, 4.5vw, 30px);
  font-weight: bold;
  margin-bottom: 10px;
}

.product-info .product-desc {
  font-size: clamp(14px, 3vw, 18px);
  line-height: 1.5;
  margin-bottom: 12px;
  color: #333;
}

.product-info .product-price {
  font-size: clamp(18px, 4vw, 26px);
  font-weight: bold;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.product-price--old {
  text-decoration: line-through;
  color: #999;
}

.product-price--free {
  color: var(--primary);
}

/* Product error */
.product-error {
  color: var(--error);
  font-size: 18px;
  padding: 40px 0;
}

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

/* Small phones */
@media (max-width: 400px) {
  .option-btn {
    flex: 0 0 100%;
    font-size: 14px;
  }

  .step-content {
    padding: 15px;
    padding-top: 70px;
  }

  .survey-logo {
    width: 120px;
  }
}

/* Tablet / larger screens */
@media (min-width: 768px) {
  .step-content {
    max-width: 800px;
  }

  .option-btn {
    flex: 0 0 calc(33.333% - 10px);
    min-height: 64px;
    font-size: 16px;
  }

  .survey-logo {
    width: 260px;
    top: 20px;
    right: 30px;
  }

  .btn-home {
    top: 20px;
    left: 20px;
  }

  .btn-home svg {
    width: 52px;
    height: 52px;
  }

  .form-container {
    padding: 32px;
  }

  .product-card img {
    max-height: 450px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .step-content {
    max-width: 900px;
    padding-top: 100px;
  }

  .step1-content {
    padding-top: 120px;
    padding-left: 40px;
  }

  .survey-logo {
    width: 300px;
    top: 25px;
    right: 40px;
  }

  .btn-home svg {
    width: 56px;
    height: 56px;
  }

  #options-grid {
    max-width: 900px;
  }

  .option-btn {
    flex: 0 0 calc(33.333% - 10px);
    min-height: 70px;
    font-size: 17px;
  }
}
