/* =========================================================
   BbC LexBot — assistente legale AI
   ========================================================= */

.lexbot-mascot { width: 100%; height: 100%; display: block; }

/* ---------- Launcher: personaggio che galleggia (stile Otto/yoctoit) ---------- */
.lexbot-launcher {
  position: fixed; right: 22px; bottom: 18px; z-index: 1000;
  width: 132px; height: 158px; padding: 0; border: none; background: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.lexbot-launcher__halo {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: 116px; height: 116px; border-radius: 50%; z-index: 0;
  background: radial-gradient(circle, rgba(185,99,111,0.45) 0%, rgba(38,65,93,0.30) 45%, transparent 72%);
  filter: blur(6px); animation: lexHalo 3.4s ease-in-out infinite;
}
@keyframes lexHalo { 0%,100% { transform: translateX(-50%) scale(0.92); opacity: .75; } 50% { transform: translateX(-50%) scale(1.08); opacity: 1; } }
.lexbot-launcher__figure {
  position: relative; z-index: 1; display: block; width: 100%; height: 100%;
  filter: drop-shadow(0 12px 14px rgba(13,27,42,0.32));
  transition: transform .3s cubic-bezier(.22,1,.36,1);
}
.lexbot-launcher:hover .lexbot-launcher__figure { transform: translateY(-6px) scale(1.05) rotate(-1deg); }
.lexbot-launcher:active .lexbot-launcher__figure { transform: scale(0.97); }
.lexbot-launcher--excited .lexbot-launcher__figure { animation: lexJump .55s cubic-bezier(.3,1.4,.5,1); }
@keyframes lexJump { 0%{transform:translateY(-6px) scale(1.05);} 35%{transform:translateY(-16px) scale(1.08) rotate(3deg);} 70%{transform:translateY(-2px) scale(1.03) rotate(-2deg);} 100%{transform:translateY(-6px) scale(1.05);} }
.lexbot-launcher__figure .lexbot-mascot { width: 100%; height: 100%; }

/* fumetto di saluto */
.lexbot-launcher__bubble {
  position: absolute; bottom: 118px; right: 4px; z-index: 2;
  background: var(--white); color: var(--navy-900);
  border: 1px solid var(--line); border-radius: 14px; border-bottom-right-radius: 4px;
  padding: 9px 13px; font-family: var(--sans); font-size: 0.82rem; font-weight: 600;
  white-space: nowrap; box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(6px) scale(.9); transform-origin: bottom right;
  transition: opacity .35s, transform .35s;
}
.lexbot-launcher__bubble.show { opacity: 1; transform: none; }

/* avatar testa nel pannello e facce piccole: inquadriamo testa + parrucca */
.lexbot-head__avatar .lexbot-mascot,
.lexbot-face .lexbot-mascot { transform-origin: 50% 18%; transform: scale(1.55); }

/* Figura intera (es. teaser home) */
.lexbot-figure {
  width: 170px; height: 190px; margin: -8px auto 0; position: relative;
}
.lexbot-figure::before {
  content: ""; position: absolute; inset: 18% 8% 14%;
  background: radial-gradient(circle, rgba(185,99,111,0.28), transparent 70%);
  filter: blur(6px); z-index: 0;
}
.lexbot-figure .lexbot-mascot { position: relative; z-index: 1; }
.lexbot-showcase { padding-top: 26px; }

.lexbot-panel {
  position: fixed; right: 26px; bottom: 26px; z-index: 1001;
  width: min(400px, calc(100vw - 32px)); height: min(620px, calc(100vh - 48px));
  background: var(--paper); border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  opacity: 0; transform: translateY(20px) scale(0.98); pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.lexbot-panel.open { opacity: 1; transform: none; pointer-events: auto; }

.lexbot-head {
  background: linear-gradient(150deg, var(--navy-900), var(--navy-700));
  color: #fff; padding: 18px 20px; display: flex; align-items: center; gap: 13px;
}
.lexbot-head__avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  background: #f3ece2; border: 1px solid rgba(255,255,255,0.4);
  display: grid; place-items: center; overflow: hidden;
}
.lexbot-head__title { font-family: var(--serif); font-size: 1.2rem; line-height: 1.1; }
.lexbot-head__status { font-size: 0.74rem; color: var(--gold-light); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.lexbot-head__status::before { content:""; width:7px; height:7px; border-radius:50%; background:#5ad07f; }
.lexbot-head__close { margin-left: auto; background: rgba(255,255,255,0.1); border: none; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; line-height: 1; transition: background .2s; }
.lexbot-head__close:hover { background: rgba(255,255,255,0.22); }

.lexbot-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.lexbot-body::-webkit-scrollbar { width: 7px; }
.lexbot-body::-webkit-scrollbar-thumb { background: rgba(13,27,42,0.18); border-radius: 10px; }

.lex-msg { max-width: 84%; padding: 12px 16px; border-radius: 16px; font-size: 0.94rem; line-height: 1.55; }
.lex-msg p { margin: 0 0 0.6em; color: inherit; }
.lex-msg p:last-child { margin: 0; }
.lex-msg ul { margin: 0.4em 0; padding-left: 1.1em; }
.lex-msg--bot { background: var(--white); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 5px; align-self: flex-start; }
.lex-msg--user { background: var(--navy-900); color: #fff; border-bottom-right-radius: 5px; align-self: flex-end; }

.lex-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lex-chip {
  background: var(--white); border: 1px solid var(--gold); color: var(--gold);
  border-radius: 999px; padding: 0.5em 1em; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: var(--t); font-family: var(--sans);
}
.lex-chip:hover { background: var(--gold); color: #fff; }

.lex-typing { display: inline-flex; gap: 4px; align-items: center; padding: 14px 16px; }
.lex-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--slate-300); animation: lexbounce 1.2s infinite; }
.lex-typing span:nth-child(2){ animation-delay:.2s;} .lex-typing span:nth-child(3){ animation-delay:.4s;}
@keyframes lexbounce { 0%,60%,100%{transform:translateY(0);opacity:.4;} 30%{transform:translateY(-5px);opacity:1;} }

.lexbot-foot { border-top: 1px solid var(--line); padding: 14px 16px; background: var(--white); }
.lexbot-input { display: flex; gap: 10px; align-items: flex-end; }
.lexbot-input textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; font-family: var(--sans); font-size: 0.94rem; max-height: 110px;
  line-height: 1.4; color: var(--ink); background: var(--paper);
}
.lexbot-input textarea:focus { outline: none; border-color: var(--gold); }
.lexbot-send {
  width: 44px; height: 44px; border-radius: 12px; border: none; flex: none;
  background: var(--gold); color: #fff; cursor: pointer; display: grid; place-items: center;
  transition: background .2s, transform .2s;
}
.lexbot-send:hover { background: var(--navy-900); transform: translateY(-1px); }
.lexbot-send:disabled { opacity: 0.5; cursor: default; transform: none; }
.lexbot-disclaimer { font-size: 0.68rem; color: var(--slate-300); text-align: center; margin-top: 8px; line-height: 1.4; }

@media (max-width: 560px) {
  .lexbot-launcher { right: 14px; bottom: 12px; width: 108px; height: 130px; padding: 0; }
  .lexbot-launcher__bubble { display: none; }
}
