/* Contenitore generale del widget */
#help-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Bottone "Hai bisogno di aiuto?" */
#help-widget-toggle {
  border: none;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  font-size: 14px;
  background: #2563eb;
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
  min-height: 44px; /* tap target più grande per mobile */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#help-widget-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  background: #1d4ed8;
}

/* Finestra di chat */
#help-widget-window {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: clamp(280px, 90vw, 360px); /* responsivo: min 280, max 360, altrimenti 90vw */
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  overflow: hidden;
  display: none;          /* nascosta di default */
  flex-direction: column; /* attivata via JS quando visibile */
  max-height: calc(100vh - 100px); /* non supera l’altezza dello schermo */
}

/* Header */
#help-widget-window .hw-header {
  background: #2563eb;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

#help-widget-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

/* Corpo */
#help-widget-window .hw-body {
  padding: 10px 12px 4px 12px;
  background: #f9fafb;
  font-size: 13px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* scrolling fluido su iOS */
}

.hw-body p {
  margin: 0 0 8px 0;
}

.hw-field {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hw-field label {
  font-size: 12px;
  color: #374151;
}

.hw-field input,
.hw-field textarea {
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.hw-field input:focus,
.hw-field textarea:focus {
  border-color: #2563eb;
}

.hw-field textarea {
  resize: vertical;
  min-height: 60px;
}

.hw-field-privacy {
  margin-top: 4px;
}

.hw-privacy-label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  color: #4b5563;
  cursor: pointer;
}

.hw-privacy-label input {
  margin-top: 2px;
  width: 14px;
  height: 14px;
}

.hw-privacy-text {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}

.hw-privacy-text a {
  color: #2563eb;
  text-decoration: none;
}

.hw-privacy-text a:hover {
  text-decoration: underline;
}

/* Footer del widget */
#help-widget-window .hw-footer {
  padding: 8px 12px 10px 12px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #ffffff;
}

#hw-feedback {
  flex: 1;
  font-size: 11px;
}

#help-widget-send {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  background: #2563eb;
  color: white;
  font-weight: 500;
  white-space: nowrap;
  min-height: 44px; /* tap target più grande */
}

#help-widget-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hw-error {
  color: #b91c1c;
}

.hw-success {
  color: #15803d;
}

/* --- OTTIMIZZAZIONE SPECIFICA PER SMARTPHONE --- */
@media (max-width: 480px) {
  #help-widget {
    bottom: 12px;
    right: 12px;
    left: 12px; /* il toggle può stare “centrato” e usare quasi tutta la larghezza */
  }

  #help-widget-toggle {
    width: 100%;
    font-size: 15px;
    padding-inline: 16px;
  }

  #help-widget-window {
    bottom: 56px;    /* sopra il bottone */
    right: 0;
    left: 0;
    width: auto;     /* prende tutta la larghezza disponibile */
    max-width: 100%;
    border-radius: 16px;
    max-height: calc(100vh - 80px); /* lascia un po’ di spazio sopra/sotto */
  }

  #help-widget-window .hw-header {
    font-size: 15px;
    padding: 12px 14px;
  }

  #help-widget-window .hw-body {
    font-size: 14px;
    padding: 12px 14px 6px 14px;
  }

  .hw-field label {
    font-size: 13px;
  }

  .hw-field input,
  .hw-field textarea {
    font-size: 14px;
  }

  .hw-privacy-label,
  .hw-privacy-text {
    font-size: 12px;
  }

  #help-widget-window .hw-footer {
    padding: 10px 14px 12px 14px;
  }

  #hw-feedback {
    font-size: 12px;
  }

  #help-widget-send {
    font-size: 14px;
    padding-inline: 18px;
  }
}
