/* ═══════════════════════════════════════
   TEAMHERO CHAT WIDGET — CSS
   Colori allineati al brand TeamHero
   ═══════════════════════════════════════ */

:root {
  --th-chat-primary: #E8222C;
  --th-chat-primary-light: #f03a43;
  --th-chat-primary-dark: #cc1d25;
  --th-chat-glow: rgba(232,34,44,.15);
  --th-chat-bg: #0A0A0A;
  --th-chat-surface: #151517;
  --th-chat-surface-2: #1C1C20;
  --th-chat-border: #28282E;
  --th-chat-text: #E8E8EC;
  --th-chat-text-muted: #A0A0AC;
  --th-chat-bot-bubble: #1C1C20;
  --th-chat-radius: 16px;
  --th-chat-shadow: 0 16px 48px rgba(0,0,0,0.4);
}

/* ── Toggle Button ── */
#th-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--th-chat-primary);
  border: none;
  cursor: pointer;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px var(--th-chat-glow);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: thTogglePulse 3s ease-in-out infinite;
}
#th-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 40px var(--th-chat-glow);
}
#th-toggle.open {
  animation: none;
  transform: rotate(90deg) scale(1);
}
#th-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: transform 0.3s;
}

@keyframes thTogglePulse {
  0%, 100% { box-shadow: 0 4px 24px var(--th-chat-glow), 0 0 0 0 rgba(232,34,44,0.25); }
  50% { box-shadow: 0 4px 24px var(--th-chat-glow), 0 0 0 10px rgba(232,34,44,0); }
}

/* ── Chat Window ── */
#th-chat {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--th-chat-surface);
  border: 1px solid var(--th-chat-border);
  border-radius: var(--th-chat-radius);
  box-shadow: var(--th-chat-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99998;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#th-chat.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
.th-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--th-chat-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--th-chat-surface);
}
.th-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--th-chat-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  color: var(--th-chat-primary);
}
.th-header-info h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  font-family: 'Outfit', system-ui, sans-serif;
}
.th-header-info span {
  font-size: 0.75rem;
  color: var(--th-chat-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.th-header-info span::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
  display: inline-block;
}

/* ── Messages area ── */
.th-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.th-messages::-webkit-scrollbar { width: 4px; }
.th-messages::-webkit-scrollbar-track { background: transparent; }
.th-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

/* ── Bubbles ── */
.th-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  font-weight: 300;
  font-family: 'Outfit', system-ui, sans-serif;
  animation: thMsgIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes thMsgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.th-msg.bot {
  align-self: flex-start;
  background: var(--th-chat-bot-bubble);
  color: var(--th-chat-text);
  border-bottom-left-radius: 4px;
}
.th-msg.user {
  align-self: flex-end;
  background: var(--th-chat-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ── */
.th-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  background: var(--th-chat-bot-bubble);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.th-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--th-chat-text-muted);
  animation: thBounce 1.4s infinite;
}
.th-typing span:nth-child(2) { animation-delay: 0.2s; }
.th-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thBounce {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ── Input area ── */
.th-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--th-chat-border);
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--th-chat-surface);
  flex-shrink: 0;
}
.th-input-area input {
  flex: 1;
  background: var(--th-chat-bg);
  border: 1px solid var(--th-chat-border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--th-chat-text);
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.3s;
}
.th-input-area input::placeholder { color: var(--th-chat-text-muted); }
.th-input-area input:focus { border-color: var(--th-chat-primary); }
.th-input-area input:disabled { opacity: 0.5; cursor: not-allowed; }

.th-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--th-chat-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, transform 0.15s;
  flex-shrink: 0;
}
.th-send:hover { background: var(--th-chat-primary-dark); transform: scale(1.05); }
.th-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.th-send svg { width: 18px; height: 18px; fill: #fff; }

/* ── Restart ── */
.th-restart {
  text-align: center;
  padding: 8px;
  background: var(--th-chat-surface);
  flex-shrink: 0;
}
.th-restart button {
  background: none;
  border: none;
  color: var(--th-chat-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: 'Outfit', system-ui, sans-serif;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.th-restart button:hover { color: var(--th-chat-text); }

/* ── Summary card ── */
.th-summary {
  background: rgba(232,34,44,0.06);
  border: 1px solid rgba(232,34,44,0.15);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 4px;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--th-chat-text);
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 300;
  align-self: flex-start;
  max-width: 90%;
  animation: thMsgIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.th-summary strong { color: #fff; font-weight: 500; }

/* ── Mobile ── */
@media (max-width: 768px) {
  #th-chat {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 88px;
    max-height: 70vh;
  }
  #th-toggle { bottom: 16px; right: 16px; width: 54px; height: 54px; }
}

/* Quick reply buttons */
.th-quick-replies{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin:12px 0 8px;
  padding:0 4px;
}
.th-quick-reply{
  background:transparent;
  border:1.5px solid #fff;
  color:#fff;
  padding:11px 18px;
  border-radius:10px;
  font-family:inherit;
  font-size:.92rem;
  font-weight:500;
  cursor:pointer;
  text-align:left;
  transition:all .2s ease;
  line-height:1.3;
}
.th-quick-reply:hover{
  background:#E8222C;
  border-color:#E8222C;
  color:#fff;
}
.th-quick-reply:disabled{
  opacity:.35;
  cursor:default;
  pointer-events:none;
}
.th-quick-replies.used .th-quick-reply{
  opacity:.35;
  cursor:default;
  pointer-events:none;
}
