/* Chat di assistenza (support.js). Tema scuro/oro coerente con styles.css.
 * z-index: pulsante e pannello (100-101) sopra i contenuti e l'header (40), sotto il banner cookie (130).
 * Banner cookie: finché è aperto il pulsante e il pannello sono nascosti (classe sf-banner-open su <html>),
 * così non coprono mai i pulsanti di scelta. */
.sf-support-btn {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  width: 56px;
  height: 56px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f5c542;
  color: #12141a;
  border: 2px solid #12141a;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sf-support-btn:hover { background: #ffd75e; }
.sf-support-btn:focus-visible { outline: 3px solid #eef2ea; outline-offset: 3px; }
.sf-support-btn svg { width: 28px; height: 28px; display: block; }

.sf-support-panel {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 101;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  max-height: 80dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #12141a;
  color: #eef2ea;
  border: 1px solid #f5c542;
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.45;
}
.sf-support-panel[hidden] { display: none !important; }
.sf-support-panel:focus { outline: none; }

.sf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sf-title { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 700; color: #f5c542; }
.sf-close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -8px -8px 0 0;
  background: transparent;
  color: #eef2ea;
  border: 0;
  border-radius: 6px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.sf-close:hover { background: rgba(238, 242, 234, 0.12); }
.sf-intro { margin: 0 0 14px; color: rgba(238, 242, 234, 0.88); font-size: 15px; }

.sf-form { display: grid; gap: 12px; }
.sf-field { display: grid; gap: 6px; }
.sf-field label,
.sf-field .sf-label { font-weight: 600; font-size: 15px; }
.sf-opt { font-weight: 400; color: rgba(238, 242, 234, 0.75); }
.sf-field input[type="text"],
.sf-field input[type="email"],
.sf-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: #07090c;
  color: #eef2ea;
  border: 1px solid rgba(238, 242, 234, 0.45);
  border-radius: 6px;
  font: inherit;
  font-size: 16px; /* 16px: evita lo zoom automatico su iOS */
}
.sf-field textarea { min-height: 112px; resize: vertical; }
.sf-field input[aria-invalid="true"],
.sf-field textarea[aria-invalid="true"] { border-color: #fca5a5; border-width: 2px; }
.sf-panel input:focus-visible,
.sf-support-panel input:focus-visible,
.sf-support-panel textarea:focus-visible,
.sf-support-panel button:focus-visible,
.sf-support-panel a:focus-visible { outline: 3px solid #f5c542; outline-offset: 2px; }
.sf-count { font-size: 13px; color: rgba(238, 242, 234, 0.75); text-align: right; margin: 0; }
.sf-err { margin: 0; min-height: 0; color: #fca5a5; font-size: 14px; font-weight: 600; }
.sf-err:empty { display: none; }

.sf-check { display: flex; align-items: flex-start; gap: 12px; font-size: 15px; }
.sf-check input { flex: none; width: 24px; height: 24px; margin: 2px 0 0; accent-color: #f5c542; }
.sf-check label { font-weight: 400; display: block; }
.sf-support-panel a { color: #f5c542; }

/* Honeypot: fuori schermo (non display:none, così i bot lo compilano) */
.sf-hp { position: absolute !important; left: -10000px !important; top: auto; width: 1px; height: 1px; overflow: hidden; }

.sf-submit {
  min-height: 48px;
  padding: 12px 20px;
  background: #f5c542;
  color: #12141a;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.sf-submit:hover { background: #ffd75e; }
.sf-submit[disabled] { opacity: 0.75; cursor: progress; }

.sf-ok { display: grid; gap: 14px; }
.sf-ok p { margin: 0; font-weight: 700; font-size: 17px; }
.sf-ok:focus { outline: none; }

body.sf-has-support footer { padding-bottom: 112px; }
html.sf-banner-open .sf-support-btn,
html.sf-banner-open .sf-support-panel { display: none !important; }

@media (max-width: 480px) {
  .sf-support-panel {
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    width: auto;
    max-width: none;
    padding: 16px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .sf-support-btn { transition: background 0.15s, transform 0.15s; }
  .sf-support-btn:hover { transform: translateY(-2px); }
  .sf-support-panel { animation: sf-pop 0.16s ease-out; }
  @keyframes sf-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
