/* Tablet sondaggio — layout kiosk orizzontale, stile pulito da sala attesa */
:root {
  --brand: #0066b3;
  --brand-dark: #004d88;
  --brand-mid: #3d94d9;
  --brand-soft: #b8dff5;
  --brand-btn: #c5e4f7;
  --brand-btn-hover: #a8d8f3;
  --brand-btn-active: #8ec9eb;
  --brand-glow: rgba(0, 102, 179, 0.12);
  --text: #1a2b3c;
  --text-soft: #475569;
  --surface: #ffffff;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --radius-btn: 14px;
  --shadow-btn: 0 4px 14px rgba(0, 77, 136, 0.1);
  --shadow-btn-hover: 0 8px 22px rgba(0, 77, 136, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body.page-feedback {
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.page-feedback .status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
  background: rgba(241, 245, 249, 0.95);
  color: var(--text-soft);
  backdrop-filter: blur(6px);
}
.page-feedback .status-bar.online {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}
.page-feedback .status-bar.offline { color: #dc2626; background: #fef2f2; }

/* Setup */
.setup-panel {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #f0f7fc 0%, #fff 45%);
}
.setup-panel__card {
  width: min(420px, 100%);
  padding: 1.75rem;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}
.setup-panel h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
}
.setup-panel__lead {
  font-size: 0.9rem;
  color: var(--text-soft);
  margin-bottom: 1.25rem;
  line-height: 1.45;
}
.setup-panel label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin: 0.85rem 0 0.3rem;
  color: var(--text-soft);
}
.setup-panel input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
}
.setup-panel .btn-primary {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

/* Shell */
.survey-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.survey-bg {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 60% at 100% 0%, var(--brand-glow) 0%, transparent 55%),
    linear-gradient(180deg, #fafcff 0%, #fff 38%);
  z-index: 0;
}

.survey-header,
.survey-main {
  position: relative;
  z-index: 1;
}

/* Header brand */
.survey-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: clamp(1.25rem, 3.5vh, 2.25rem) clamp(1.5rem, 5vw, 3.5rem) 0;
  gap: 1rem;
}

.survey-brand {
  display: flex;
  align-items: flex-start;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  max-width: min(620px, 68vw);
}

.survey-brand--has-logo {
  align-items: center;
}

.survey-logo {
  max-height: clamp(72px, 14vh, 112px);
  max-width: min(220px, 34vw);
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.survey-brand--has-logo .survey-logo {
  max-height: clamp(80px, 16vh, 128px);
  max-width: min(260px, 38vw);
}

.survey-brand__text h1 {
  font-size: clamp(1.65rem, 4.2vw, 2.75rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.survey-brand--has-logo .survey-brand__text h1 {
  font-size: clamp(1.35rem, 3.2vw, 2.1rem);
}

.survey-tagline {
  font-size: clamp(0.62rem, 1.2vw, 0.78rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-top: 0.45rem;
  font-weight: 600;
}

/* Decorazione onda + facce */
.survey-decor {
  position: relative;
  width: clamp(200px, 32vw, 340px);
  height: clamp(90px, 16vh, 130px);
  flex-shrink: 0;
  margin-top: -0.25rem;
}

.survey-wave-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 20px rgba(0, 102, 179, 0.15));
}

.survey-face {
  position: absolute;
  width: clamp(38px, 6.5vw, 54px);
  height: clamp(38px, 6.5vw, 54px);
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  align-content: center;
  gap: 0;
}

.survey-face__eye {
  width: 7px;
  height: 7px;
  background: #fff;
  border-radius: 50%;
  margin: 0 5px;
  margin-top: -6px;
}

.survey-face__mouth {
  width: 14px;
  height: 7px;
  margin-top: 2px;
  flex-basis: 100%;
  margin-left: auto;
  margin-right: auto;
}

.survey-face__mouth--smile {
  border-bottom: 3px solid #fff;
  border-radius: 0 0 50% 50%;
}

.survey-face__mouth--neutral {
  width: 12px;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  margin-top: 4px;
}

.survey-face--green {
  background: linear-gradient(145deg, #34d399, #16a34a);
  top: 4%;
  right: 14%;
  z-index: 3;
  animation: survey-float 4.5s ease-in-out infinite;
}

.survey-face--yellow {
  background: linear-gradient(145deg, #fde047, #eab308);
  bottom: 2%;
  right: 38%;
  z-index: 2;
  animation: survey-float 5.2s ease-in-out infinite 0.6s;
}

.survey-face--blue {
  background: linear-gradient(145deg, #60a5fa, #2563eb);
  top: 28%;
  right: 2%;
  width: clamp(32px, 5vw, 44px);
  height: clamp(32px, 5vw, 44px);
  z-index: 1;
  opacity: 0.95;
  animation: survey-float 4.8s ease-in-out infinite 1.1s;
}

@keyframes survey-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Contenuto principale */
.survey-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(0.5rem, 2vh, 1.5rem) clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 3vh, 2rem);
}

.survey-stage {
  width: 100%;
  max-width: 860px;
  animation: survey-fade-in 0.45s ease;
}

.survey-question-card {
  position: relative;
  width: 100%;
  max-width: none;
  padding: clamp(1.1rem, 2.5vw, 1.5rem) clamp(1.25rem, 3vw, 1.75rem);
  padding-left: clamp(1.75rem, 3vw, 2rem);
  margin-bottom: 0.85rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(0, 102, 179, 0.1);
  border-left: 4px solid var(--brand);
  border-radius: 0 16px 16px 0;
  box-shadow: 0 8px 28px rgba(0, 77, 136, 0.07);
  backdrop-filter: blur(4px);
}

.survey-question-mark {
  position: absolute;
  top: -0.15rem;
  left: 0.65rem;
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  line-height: 1;
  font-weight: 800;
  color: var(--brand-soft);
  font-family: Georgia, "Times New Roman", serif;
  pointer-events: none;
  user-select: none;
}

.survey-question {
  position: relative;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.45;
  padding-left: 0.5rem;
  color: var(--text);
  text-wrap: pretty;
}

.survey-hint {
  font-size: clamp(0.82rem, 1.5vw, 0.95rem);
  color: var(--text-soft);
  margin-bottom: clamp(1rem, 2.5vh, 1.5rem);
  letter-spacing: 0.01em;
}

/* Pulsanti valutazione */
.survey-ratings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.65rem, 1.8vw, 1.1rem);
  width: 100%;
  max-width: none;
}

.survey-rate {
  appearance: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-btn);
  background: linear-gradient(180deg, #e8f4fc 0%, var(--brand-btn) 55%, #b3daf2 100%);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  min-height: clamp(72px, 12vh, 96px);
  padding: 0.75rem 0.5rem 0.85rem;
  box-shadow: var(--shadow-btn);
  transition:
    transform 0.14s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
  overflow: hidden;
}

.survey-rate__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: transform 0.18s ease;
}

.survey-rate--excellent { color: #15803d; }
.survey-rate--good { color: #0369a1; }
.survey-rate--fair { color: #a16207; }
.survey-rate--poor { color: #b91c1c; }

.survey-rate::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, transparent 42%);
  pointer-events: none;
}

.survey-rate__label {
  position: relative;
  display: block;
  font-size: clamp(0.82rem, 1.7vw, 1rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  line-height: 1.2;
  color: var(--text);
}

.survey-rate:hover .survey-rate__icon,
.survey-rate:focus-visible .survey-rate__icon {
  transform: scale(1.08);
}

.survey-rate:hover,
.survey-rate:focus-visible {
  background: linear-gradient(180deg, #e0f2fc 0%, var(--brand-btn-hover) 50%, #a8d8f3 100%);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-2px);
  outline: none;
  border-color: rgba(255, 255, 255, 1);
}

.survey-rate:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
  background: linear-gradient(180deg, #b8daf0 0%, var(--brand-btn-active) 100%);
  box-shadow: 0 2px 8px rgba(0, 77, 136, 0.12);
}

.survey-rate:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}

.survey-rate.is-selected {
  border-color: currentColor;
  box-shadow: 0 0 0 3px var(--brand-glow), var(--shadow-btn-hover);
  animation: survey-pulse 0.35s ease;
}

.survey-rate--excellent.is-selected { background: linear-gradient(180deg, #ecfdf5, #bbf7d0); }
.survey-rate--good.is-selected { background: linear-gradient(180deg, #eff6ff, #bfdbfe); }
.survey-rate--fair.is-selected { background: linear-gradient(180deg, #fffbeb, #fde68a); }
.survey-rate--poor.is-selected { background: linear-gradient(180deg, #fef2f2, #fecaca); }

@keyframes survey-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes survey-pulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* Schermate feedback */
.survey-feedback {
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem 0;
}

.survey-feedback__icon {
  width: 88px;
  height: 88px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.survey-feedback__icon--success {
  background: linear-gradient(145deg, #ecfdf5, #d1fae5);
}

.survey-feedback__icon--success svg {
  display: block;
}

.survey-check-circle {
  stroke: #22c55e;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: survey-draw-circle 0.55s ease forwards 0.1s;
}

.survey-check-mark {
  stroke: #16a34a;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: survey-draw-check 0.4s ease forwards 0.55s;
}

@keyframes survey-draw-circle {
  to { stroke-dashoffset: 0; }
}

@keyframes survey-draw-check {
  to { stroke-dashoffset: 0; }
}

.survey-feedback__icon--info {
  background: linear-gradient(145deg, #eff6ff, #dbeafe);
  color: var(--brand);
  font-size: 2.25rem;
  font-weight: 800;
}

.survey-feedback__title {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.survey-feedback__text {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--text-soft);
  line-height: 1.5;
  max-width: 28rem;
  margin: 0 auto;
}

.survey-error {
  margin-top: 1.25rem;
  padding: 0.85rem 1.1rem;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 12px;
  max-width: 36rem;
  border: 1px solid #fecaca;
  font-size: 0.95rem;
}

.survey-footer {
  position: relative;
  z-index: 1;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem 1.25rem;
  font-size: clamp(0.78rem, 1.4vw, 0.88rem);
  color: #94a3b8;
  letter-spacing: 0.02em;
}
.survey-shell.is-ready .survey-footer {
  display: flex;
}
.survey-footer__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-soft);
  flex-shrink: 0;
}

/* Landscape tablet — domanda ampia quanto i pulsanti */
@media (orientation: landscape) and (min-width: 700px) {
  .survey-main {
    padding-left: clamp(2.5rem, 7vw, 4.5rem);
    padding-bottom: 0.5rem;
  }

  .survey-stage {
    max-width: min(960px, calc(100vw - 12rem));
  }

  .survey-question {
    font-size: clamp(1.2rem, 2vw, 1.45rem);
    line-height: 1.35;
  }

  .survey-header {
    padding-bottom: 0.25rem;
  }
}

@media (max-width: 720px) {
  .survey-ratings {
    grid-template-columns: repeat(2, 1fr);
  }

  .survey-decor {
    width: clamp(160px, 42vw, 220px);
    height: 80px;
  }

  .survey-face--blue {
    display: none;
  }
}

@media (max-width: 480px) {
  .survey-header {
    flex-direction: column;
    align-items: stretch;
  }

  .survey-decor {
    align-self: flex-end;
    margin-top: 0.5rem;
  }

  .survey-brand {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .survey-face,
  .survey-stage,
  .survey-rate,
  .survey-check-circle,
  .survey-check-mark {
    animation: none !important;
    transition: none !important;
  }
}

/* Modalità anteprima admin */
body.survey-preview-mode .survey-rate {
  cursor: default;
}
body.survey-preview-mode .survey-rate:active {
  transform: none;
}
.survey-preview-mode .survey-shell::after {
  content: "Anteprima";
  position: fixed;
  bottom: 0.65rem;
  right: 0.75rem;
  z-index: 20;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  pointer-events: none;
}
