﻿.lgw {
  --lgw-primary: #0f3b57;
  --lgw-on-primary: #ffffff;
  --lgw-accent: #f5a623;
  --lgw-bg: #ffffff;
  --lgw-soft: #eef2f5;
  --lgw-text: #14232d;
  --lgw-muted: #5f707c;
  --lgw-line: #dde4e9;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--lgw-text);
}

.lgw *, .lgw *::before, .lgw *::after {
  box-sizing: border-box;
}

.lgw button, .lgw textarea {
  font: inherit;
}

.lgw button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.lgw svg {
  display: block;
}

/* ---------- Pulsante "Parla con noi" ---------- */
.lgw .lgw-launch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 20px 0 8px;
  border-radius: 26px;
  background: var(--lgw-primary);
  color: var(--lgw-on-primary);
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 6px 20px rgba(15, 59, 87, 0.35);
  transition: transform 0.15s ease, opacity 0.15s ease, visibility 0s;
}

.lgw .lgw-launch:hover {
  transform: translateY(-1px);
}

.lgw .lgw-launch-ico {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--lgw-accent);
  color: #10232f;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lgw .lgw-launch-ico svg {
  width: 20px;
  height: 20px;
}

.lgw.is-open .lgw-launch {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lgw .lgw-launch:focus-visible, .lgw .lgw-send:focus-visible, .lgw .lgw-x:focus-visible, .lgw .lgw-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--lgw-primary);
}

/* ---------- Pannello ---------- */
.lgw .lgw-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 380px;
  height: min(600px, 100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--lgw-bg);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(16, 35, 47, 0.28), 0 0 0 1px rgba(16, 35, 47, 0.06);
  visibility: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s 0.18s;
}

.lgw.is-open .lgw-panel {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}

.lgw .lgw-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 10px 14px 16px;
  background: var(--lgw-primary);
  color: var(--lgw-on-primary);
}

.lgw .lgw-ava {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--lgw-accent);
  color: #10232f;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lgw .lgw-ava svg {
  width: 20px;
  height: 20px;
}

.lgw .lgw-ht {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.lgw .lgw-ht strong {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.lgw .lgw-ht span {
  font-size: 12.5px;
  opacity: 0.8;
}

.lgw .lgw-x {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lgw-on-primary);
}

.lgw .lgw-x:hover {
  background: rgba(255, 255, 255, 0.14);
}

.lgw a.lgw-x.notification {
  background: #1b810f;
  color: #fff;
}

.lgw a.lgw-x.notification.hdn {
  display: none;
}

.lgw a.lgw-x.notification:hover {
  background: #1b810f;
}

.lgw .lgw-x svg {
  width: 20px;
  height: 20px;
}

/* ---------- Messaggi ---------- */
.lgw .lgw-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lgw .lgw-msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lgw .lgw-msg.bot {
  align-self: flex-start;
  background: var(--lgw-soft);
  border-bottom-left-radius: 4px;
}

.lgw .lgw-msg.user {
  align-self: flex-end;
  background: var(--lgw-primary);
  color: var(--lgw-on-primary);
  border-bottom-right-radius: 4px;
}

.lgw .lgw-msg a {
  color: inherit;
  text-decoration: underline;
}

.lgw .lgw-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 13px 14px;
  background: var(--lgw-soft);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.lgw .lgw-typing[hidden] {
  display: none;
}

.lgw .lgw-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lgw-muted);
  opacity: 0.5;
  animation: lgw-dot 1.1s infinite ease-in-out;
}

.lgw .lgw-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.lgw .lgw-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes lgw-dot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
/* ---------- Risposte rapide ---------- */
.lgw .lgw-quick {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.lgw .lgw-quick:empty {
  display: none;
}

.lgw .lgw-chip {
  padding: 6px 13px;
  border: 1px solid var(--lgw-primary);
  border-radius: 16px;
  color: var(--lgw-primary);
  background: var(--lgw-bg);
  font-size: 13.5px;
}

.lgw .lgw-chip:hover {
  background: var(--lgw-soft);
}

/* ---------- Composer ---------- */
.lgw .lgw-form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--lgw-line);
  background: var(--lgw-bg);
}

.lgw .lgw-input {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 110px;
  padding: 10px 14px;
  border: 1px solid var(--lgw-line);
  border-radius: 20px;
  background: var(--lgw-bg);
  color: var(--lgw-text);
  line-height: 1.35;
  font-size: 14.5px;
}

.lgw .lgw-input:focus {
  outline: none;
  border-color: var(--lgw-primary);
  box-shadow: 0 0 0 1px var(--lgw-primary);
}

.lgw .lgw-input::placeholder {
  color: var(--lgw-muted);
}

.lgw .lgw-send {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--lgw-primary);
  color: var(--lgw-on-primary) !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lgw .lgw-send[disabled] {
  opacity: 0.4;
  cursor: default;
}

.lgw .lgw-send svg {
  width: 20px;
  height: 20px;
}

/* ---------- Mobile: pannello a schermo intero ---------- */
@media (max-width: 520px) {
  .lgw {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
  }
  .lgw .lgw-panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    transform: translateY(24px);
  }
  .lgw .lgw-head {
    padding-top: max(14px, env(safe-area-inset-top));
  }
  .lgw .lgw-form {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .lgw .lgw-input {
    font-size: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .lgw .lgw-panel, .lgw.is-open .lgw-panel, .lgw .lgw-launch {
    transition: none;
  }
  .lgw .lgw-typing i {
    animation: none;
    opacity: 0.7;
  }
}
