/**
 * Widget de chat Lio — coin bas-droit. Variables reprises de styles.css
 * (--bg-elevated, --bg-inset, --line, --text, --accent…) pour rester dans le
 * même système visuel sans dupliquer la palette.
 */

.lio-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80; /* sous le market-gate (100), au-dessus du reste */
  font-family: var(--font);
}

.lio-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.lio-launcher:hover { transform: scale(1.05); }
.lio-launcher:active { transform: scale(0.96); }

.lio-launcher-icon,
.lio-launcher-close {
  width: 24px;
  height: 24px;
  position: absolute;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.lio-launcher-close { opacity: 0; transform: scale(0.6) rotate(-45deg); }
.lio-chat.is-open .lio-launcher-icon { opacity: 0; transform: scale(0.6) rotate(45deg); }
.lio-chat.is-open .lio-launcher-close { opacity: 1; transform: none; }

.lio-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.lio-chat.is-open .lio-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.lio-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.lio-head-title { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.lio-head-sub { color: var(--text-faint); font-size: 0.78rem; }
.lio-head-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.lio-head-close:hover { color: var(--text); }

.lio-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lio-msg { display: flex; }
.lio-msg--user { justify-content: flex-end; }
.lio-msg--assistant { justify-content: flex-start; }

.lio-bubble {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}
.lio-msg--user .lio-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.lio-msg--assistant .lio-bubble {
  background: var(--bg-inset);
  border-bottom-left-radius: 4px;
}

.lio-bubble p { margin: 0 0 6px; }
.lio-bubble p:last-child { margin-bottom: 0; }
.lio-bubble h4 { margin: 6px 0 4px; font-size: 0.88rem; color: var(--text); }
.lio-bubble ul, .lio-bubble ol { margin: 0 0 6px; padding-left: 20px; }
.lio-bubble li { margin: 2px 0; }
.lio-bubble a { color: var(--accent); }
.lio-msg--user .lio-bubble a { color: #fff; text-decoration: underline; }
.lio-bubble strong { color: inherit; }

.lio-typing { display: flex; align-items: center; gap: 4px; padding: 12px; }
.lio-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: lio-bounce 1.1s infinite ease-in-out;
}
.lio-typing span:nth-child(2) { animation-delay: 0.15s; }
.lio-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes lio-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.lio-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.lio-input {
  flex: 1;
  resize: none;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 9px 12px;
  max-height: 120px;
  outline: none;
}
.lio-input:focus { border-color: var(--accent); }
.lio-input::placeholder { color: var(--text-faint); }

.lio-send {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lio-send:disabled { opacity: 0.5; cursor: default; }
.lio-send:not(:disabled):hover { filter: brightness(1.1); }

@media (max-width: 1023px) {
  .lio-chat { right: 16px; bottom: 16px; }
  .lio-panel {
    position: fixed;
    right: 12px;
    bottom: 88px;
    left: 12px;
    width: auto;
    max-width: none;
    height: min(70vh, 560px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lio-launcher, .lio-panel, .lio-launcher-icon, .lio-launcher-close {
    transition: none;
  }
  .lio-typing span { animation: none; }
}
