/*─────────────────────────────────────────────────────────────────────────────
  Studio One Informatica — chat.css v2.2
  Claud-IA · WhatsApp Style · Glow border · Drag & Resize
─────────────────────────────────────────────────────────────────────────────*/

/* ══════════════════════════════════════════════════════════════════════════
   FLOAT BUTTON — Claud-IA
══════════════════════════════════════════════════════════════════════════ */
.claudia-float-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  position: relative;
}

/* Label "Assistente 24H" — slide from right on hover */
.claudia-float-label {
  background: linear-gradient(135deg, #055d52 0%, #128C7E 100%);
  color: #fff;
  font-size: 12px;
  font-family: 'bold', 'Nunito', sans-serif;
  font-weight: 700;
  line-height: 1.3;
  padding: 8px 18px 8px 16px;
  border-radius: 30px 0 0 30px;
  white-space: nowrap;
  margin-right: -6px;
  box-shadow: -3px 3px 14px rgba(0,0,0,.22);
  transform: translateX(14px) scaleX(0.6);
  transform-origin: right center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease, transform .34s cubic-bezier(.34,1.4,.64,1);
}
.claudia-float-label span {
  display: block;
  font-size: 10px;
  font-family: 'regular', 'Nunito', sans-serif;
  opacity: .82;
  margin-top: 1px;
}
.claudia-float-wrap:hover .claudia-float-label,
.claudia-float-wrap:focus-within .claudia-float-label {
  opacity: 1;
  transform: translateX(0) scaleX(1);
  pointer-events: auto;
}

/* Bottone principale */
#chat-toggle-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 1.5px solid #2d3a4e;
  background: #1a2231;
  cursor: pointer;
  position: relative;
  overflow: visible;

  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;

  transition: transform .25s ease, box-shadow .35s ease;

  /* ombra base */
  box-shadow:
    0 8px 22px rgba(0,0,0,.40),
    0 0 0 1px rgba(255,255,255,.04);

  animation: haloShadow 3.2s ease-in-out infinite;
}

/* Hover */
#chat-toggle-btn:hover {
  transform: scale(1.07) translateY(-2px);
}

/* Avatar */
#chat-toggle-btn .claudia-av-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
  display: block;
  transition: opacity .2s;
}

#chat-toggle-btn .claudia-av-ico {
  font-size: 26px;
  color: #ff6c3a;
  display: none;
}

/* Stato chat aperta */
#chat-toggle-btn.is-open .claudia-av-img {
  opacity: .28;
}

#chat-toggle-btn .claudia-xmark {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  z-index: 2;
}

#chat-toggle-btn.is-open .claudia-xmark {
  display: flex;
}

/* ─────────────────────
   AUREOLA DI LUCE
───────────────────── */

#chat-toggle-btn::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;

  background: radial-gradient(
    circle,
    rgba(255,108,58,.45) 0%,
    rgba(255,108,58,.18) 40%,
    rgba(255,108,58,.05) 65%,
    transparent 75%
  );

  filter: blur(14px);
  opacity: .75;

  animation: haloGlow 3.2s ease-in-out infinite;

  pointer-events: none;
}

/* glow che respira */
@keyframes haloGlow {

  0% {
    transform: scale(.95);
    opacity: .55;
  }

  50% {
    transform: scale(1.18);
    opacity: .9;
  }

  100% {
    transform: scale(.95);
    opacity: .55;
  }

}

/* ombra che pulsa */
@keyframes haloShadow {

  0% {
    box-shadow:
      0 8px 22px rgba(0,0,0,.40),
      0 0 14px rgba(255,108,58,.18);
  }

  50% {
    box-shadow:
      0 14px 36px rgba(0,0,0,.48),
      0 0 30px rgba(255,108,58,.35);
  }

  100% {
    box-shadow:
      0 8px 22px rgba(0,0,0,.40),
      0 0 14px rgba(255,108,58,.18);
  }

}

/* chat aperta = niente animazioni */
#chat-toggle-btn.is-open::before {
  display: none;
}

#chat-toggle-btn.is-open {
  animation: none;

  box-shadow:
    0 6px 16px rgba(0,0,0,.28),
    0 2px 6px rgba(0,0,0,.18);
}
/* ══════════════════════════════════════════════════════════════════════════
   CHAT PANEL — glow border, drag, resize
══════════════════════════════════════════════════════════════════════════ */
#ai-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 100px;
  width: 370px;
  height: min(620px, calc(100dvh - 150px));
  max-height: min(620px, calc(100dvh - 150px));
  min-width: 300px;
  min-height: 400px;
  z-index: 9000;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /* Glow WA-style: bagliore verde sul bordo */
  box-shadow:
    0 0 0 1px rgba(37,211,102,.25),
    0 0 18px rgba(37,211,102,.18),
    0 0 40px rgba(37,211,102,.10),
    0 24px 64px rgba(0,0,0,.32),
    0 4px 16px rgba(0,0,0,.14);

  /* Bordo luminoso animato */
  outline: 1.5px solid rgba(37,211,102,.22);

  transform: scale(0.88) translateY(32px);
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform .32s cubic-bezier(.34,1.56,.64,1),
    opacity .25s ease,
    visibility .25s;
}
#ai-chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  animation: chatGlowPulse 3s ease-in-out infinite;
}
@keyframes chatGlowPulse {
  0%,100% {
    box-shadow:
      0 0 0 1px rgba(37,211,102,.22),
      0 0 16px rgba(37,211,102,.14),
      0 0 36px rgba(37,211,102,.08),
      0 24px 64px rgba(0,0,0,.32);
  }
  50% {
    box-shadow:
      0 0 0 1.5px rgba(37,211,102,.38),
      0 0 26px rgba(37,211,102,.26),
      0 0 54px rgba(37,211,102,.14),
      0 24px 64px rgba(0,0,0,.32);
  }
}

/* Resize handle — angolo basso sinistra */
.chat-resize-handle {
  position: absolute;
  left: 0; bottom: 0;
  width: 22px; height: 22px;
  cursor: nwse-resize;
  z-index: 10;
  opacity: .45;
  transition: opacity .2s;
}
.chat-resize-handle::before,
.chat-resize-handle::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,.6);
  border-radius: 2px;
}
.chat-resize-handle::before { width: 2px; height: 12px; left: 6px; bottom: 4px; }
.chat-resize-handle::after  { width: 12px; height: 2px; left: 4px; bottom: 6px; }
.chat-resize-handle:hover { opacity: .9; }

/* Mobile: full screen */
@media (max-width: 480px) {
  #ai-chat-panel {
    right: 0; left: 0; bottom: 0;
    width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0;
    outline: none;
  }
  .chat-resize-handle { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   HEADER — teal gradient + striscia arancio animata
══════════════════════════════════════════════════════════════════════════ */
.chat-header {
  background: linear-gradient(135deg, #055d52 0%, #0d7a6e 60%, #128C7E 100%);
  padding: 10px 12px 10px 14px;
  display: flex; align-items: center; gap: 11px;
  flex-shrink: 0;
  position: relative;
  border-bottom: 1px solid rgba(0,0,0,.1);
  user-select: none; /* serve per drag */
}
.chat-header::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, #2d3a4e 0%, #ffb347 50%, #2d3a4e 100%);
  background-size: 200% 100%;
  animation: headerStripe 4s linear infinite;
}
@keyframes headerStripe {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

.chat-back {
  display: none;
  background: none; border: none;
  color: rgba(255,255,255,.75); font-size: 17px;
  cursor: pointer; padding: 0 4px; transition: color .15s;
}
.chat-back:hover { color: #fff; }
@media (max-width: 480px) { .chat-back { display: block; } }

.chat-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.2);
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
  background: #1a2231;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.chat-avatar img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top; display: block;
}
.chat-avatar i { color: #2d3a4e; font-size: 20px; }
.chat-avatar::after {
  content: '';
  position: absolute; bottom: 1px; right: 1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #44d858; border: 2px solid #055d52;
  animation: onlinePulse 3s ease infinite;
}
@keyframes onlinePulse { 0%,100%{opacity:1} 50%{opacity:.45} }

.chat-info { flex: 1; min-width: 0; }
.chat-name {
  font-family: 'bold', 'Nunito', sans-serif;
  font-size: 15px; color: #fff; line-height: 1.25;
}
.chat-status {
  font-size: 11.5px; color: rgba(255,255,255,.78);
  display: flex; align-items: center; gap: 5px; margin-top: 1px;
}
.claudia-dot {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: #44d858;
  animation: onlinePulse 3s ease infinite;
  flex-shrink: 0;
}

.chat-actions { display: flex; align-items: center; gap: 2px; }
.chat-action-btn {
  background: none; border: none; color: rgba(255,255,255,.65);
  font-size: 15px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
  transition: background .15s, color .15s;
}
.chat-action-btn:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════
   BODY — sfondo WA pattern caldo
══════════════════════════════════════════════════════════════════════════ */
.chat-body {
  flex: 1; overflow-y: auto;
  padding: 10px 12px 6px;
  display: flex; flex-direction: column; gap: 3px;
  background-color: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5z' fill='%23c9b8a8' fill-opacity='0.13'/%3E%3C/svg%3E");
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 4px; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 2px; }

.chat-date-sep { text-align: center; margin: 8px 0 6px; }
.chat-date-sep span {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(6px);
  border-radius: 8px; font-size: 11px; color: #6b7c85;
  padding: 3px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

/* ── Bubbles ──────────────────────────────────────────────────────────── */
.msg {
  display: flex; flex-direction: column;
  max-width: 84%;
  animation: msgIn .22s ease;
}
@keyframes msgIn {
  from { opacity:0; transform:translateY(8px) scale(.96); }
  to   { opacity:1; transform:none; }
}
.msg.bot { align-self: flex-start; }
.msg.bot .msg-bubble {
  background: #fff;
  border-radius: 0 14px 14px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  padding: 9px 13px 7px; position: relative;
}
.msg.bot .msg-bubble::before {
  content: ''; position: absolute; top:0; left:-9px;
  border-width: 0 9px 9px 0; border-style: solid;
  border-color: transparent #fff transparent transparent;
}
.msg.user { align-self: flex-end; }
.msg.user .msg-bubble {
  background: #d9fdd3;
  border-radius: 14px 0 14px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  padding: 9px 13px 7px; position: relative;
}
.msg.user .msg-bubble::after {
  content: ''; position: absolute; top:0; right:-9px;
  border-width: 0 0 9px 9px; border-style: solid;
  border-color: transparent transparent transparent #d9fdd3;
}
.msg-text {
  font-size: 13.5px; line-height: 1.55; color: #111b21;
  word-break: break-word; white-space: pre-wrap;
}
.msg-text a { color: #075E54; text-decoration: underline; }
.msg-text strong { color: #1a1a1a; }
.msg-text code {
  background: #f0f2f5; padding: 1px 5px; border-radius: 4px;
  font-family: monospace; font-size: 12px; color: #c0392b;
}
.msg-meta {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 3px; margin-top: 3px;
}
.msg-time { font-size: 10px; color: #8696a0; white-space: nowrap; }
.msg-tick { font-size: 11px; color: #53bdeb; }
.msg.bot .msg-tick { display: none; }
.msg.error .msg-bubble { background: #fff4f2; border-left: 3px solid #ff6c3a; }
.msg.error .msg-text   { color: #b94a2c; font-size: 12.5px; }

/* ── Typing ───────────────────────────────────────────────────────────── */
.typing-indicator {
  align-self: flex-start;
  display: flex; align-items: center; gap: 5px;
  background: #fff;
  border-radius: 0 14px 14px 14px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  position: relative;
  animation: msgIn .22s ease;
}
.typing-indicator::before {
  content: ''; position: absolute; top:0; left:-9px;
  border-width: 0 9px 9px 0; border-style: solid;
  border-color: transparent #fff transparent transparent;
}
.typing-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #aab8c0;
  animation: typeDot 1.3s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typeDot {
  0%,60%,100% { transform: translateY(0); opacity:.45; }
  30%          { transform: translateY(-7px); opacity:1; }
}

/* ── Quick replies ─────────────────────────────────────────────────────── */
.quick-replies { display: flex; flex-wrap: wrap; gap: 7px; padding: 8px 0 4px; }
.qr-btn {
  background: #fff; border: 1.5px solid #075E54; color: #055d52;
  border-radius: 22px; padding: 6px 13px; font-size: 12px;
  font-family: 'regular', 'Nunito', sans-serif;
  cursor: pointer; transition: all .18s ease;
  white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.qr-btn:hover {
  background: #075E54; color: #fff;
  transform: translateY(-1px); box-shadow: 0 3px 8px rgba(7,94,84,.25);
}

/* ══════════════════════════════════════════════════════════════════════════
   FOOTER — input area
══════════════════════════════════════════════════════════════════════════ */
.chat-footer {
  background: #f0f2f5; padding: 8px 10px;
  display: flex; align-items: flex-end; gap: 8px;
  flex-shrink: 0; border-top: 1px solid rgba(0,0,0,.07);
}
.chat-input-wrap {
  flex: 1; background: #fff; border-radius: 24px;
  display: flex; align-items: flex-end;
  padding: 7px 14px; box-shadow: 0 1px 4px rgba(0,0,0,.1);
  min-height: 43px; max-height: 110px;
  transition: box-shadow .2s;
}
.chat-input-wrap:focus-within { box-shadow: 0 2px 8px rgba(7,94,84,.22); }
#chat-input {
  flex: 1; border: none; background: none;
  font-family: 'regular', 'Nunito', sans-serif;
  font-size: 14px; color: #111b21;
  resize: none; max-height: 100px;
  line-height: 1.45; outline: none;
  padding: 1px 0; scrollbar-width: thin;
}
#chat-input::placeholder { color: #8696a0; }
.chat-send {
  width: 43px; height: 43px; border-radius: 50%;
  background: linear-gradient(135deg, #25D366, #1ebe5b);
  border: none; color: #fff; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .18s ease; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(37,211,102,.38);
}
.chat-send:hover { background: linear-gradient(135deg,#1ebe5b,#17a84d); transform:scale(1.07); }
.chat-send:disabled { background: #d1d7db; box-shadow:none; cursor:default; transform:none; }
.chat-send .icon-send { display: none; }
.chat-send .icon-mic  { display: block; }
.chat-send.has-text .icon-send { display: block; }
.chat-send.has-text .icon-mic  { display: none; }

/* ══════════════════════════════════════════════════════════════════════════
   WELCOME
══════════════════════════════════════════════════════════════════════════ */
.chat-welcome {
  background: rgba(255,255,255,.93); backdrop-filter: blur(6px);
  border-radius: 12px; padding: 18px 16px; margin: 6px 0;
  text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.cw-icon {
  width: 68px; height: 68px; border-radius: 50%; overflow: hidden;
  margin: 0 auto 10px; border: 3px solid #ff6c3a;
  box-shadow: 0 4px 14px rgba(255,108,58,.3); background: #eee;
}
.cw-icon img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top; display: block;
}
.cw-title { font-family:'bold','Nunito',sans-serif; font-size:15px; color:#111b21; margin-bottom:5px; }
.cw-text  { font-size:12.5px; color:#667781; line-height:1.55; }

/* ══════════════════════════════════════════════════════════════════════════
   PRIVACY NOTICE
══════════════════════════════════════════════════════════════════════════ */
.chat-privacy {
  background: rgba(254,243,199,.9); border-radius: 10px;
  padding: 9px 13px; text-align: center; margin: 4px 0 6px;
  border: 1px solid rgba(251,191,36,.3);
}
.chat-privacy i { color: #d97706; font-size: 11px; margin-right: 4px; }
.chat-privacy span { font-size: 11px; color: #78350f; line-height: 1.45; }

/* ══════════════════════════════════════════════════════════════════════════
   WA BOTTONE DINAMICO — SINISTRA
   Bottone pill verde con icona WA + testo + badge
══════════════════════════════════════════════════════════════════════════ */
#wa-left-btn {
  position: fixed;
  left: 20px;
  bottom: 28px;
  z-index: 8998;
  transform: translateX(calc(-100% - 40px));
  opacity: 0;
  pointer-events: none;
  transition: transform .45s cubic-bezier(.34,1.56,.64,1), opacity .3s ease;
}
#wa-left-btn.wa-visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Pill principale */
.wa-left-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #25D366;
  color: #fff;
  text-decoration: none;
  padding: 10px 18px 10px 12px;
  border-radius: 50px;
  box-shadow:
    0 4px 18px rgba(37,211,102,.50),
    0 2px 6px rgba(0,0,0,.18);
  transition: transform .2s, background .2s, box-shadow .2s;
  white-space: nowrap;
  position: relative;
}
.wa-left-inner:hover {
  background: #1ebe5b;
  transform: scale(1.05) translateY(-1px);
  color: #fff;
  box-shadow: 0 6px 24px rgba(37,211,102,.6);
}

/* Icona WA grande */
.wa-left-ico {
  font-size: 28px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.2));
}

/* Testo */
.wa-left-label span {
  display: block;
  font-family: 'bold', 'Nunito', sans-serif;
  font-size: 13px;
  line-height: 1.2;
}
.wa-left-label small {
  display: block;
  font-size: 10.5px;
  opacity: .88;
  margin-top: 1px;
}

/* Badge stato dinamico (gestito via JS) */
.wa-status-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-family: 'bold', 'Nunito', sans-serif;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 1px 5px rgba(0,0,0,.28);
  white-space: nowrap;
  pointer-events: none;
  transition: background .4s ease, color .4s ease;
}
/* Online: stesso verde del label assistente */
.wa-status-badge.is-open {
  background: linear-gradient(135deg, #055d52 0%, #128C7E 100%);
  color: #fff;
}
/* Offline: grigio scuro neutro */
.wa-status-badge.is-closed {
  background: #546e7a;
  color: #fff;
}

/* Pulse ring sul bottone WA */
.wa-left-inner::before {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50px;
  background: transparent;
  border: 2px solid rgba(37,211,102,.4);
  animation: waPulse 2.5s ease-out infinite;
  pointer-events: none;
}
@keyframes waPulse {
  0%   { transform: scale(1); opacity: .5; }
  70%  { transform: scale(1.08); opacity: 0; }
  100% { opacity: 0; }
}

/* Mobile: comprimi a solo icona */
@media (max-width: 480px) {
  .wa-left-label { display: none; }
  .wa-left-inner { padding: 13px; border-radius: 50%; }
  /* wa-status-badge si nasconde su mobile */
  .wa-status-badge { display: none; }
}
