/* TLL chat assistant widget. Two themes: .chat--site (dark, website) and .chat--admin (light, staff). */
.chat {
  --c-bg: #0b1734; --c-panel: #0a1a3f; --c-line: rgba(255,255,255,.12); --c-ink: #fff; --c-soft: rgba(255,255,255,.62);
  --c-user: #ff6a3d; --c-user-ink: #1a0d06; --c-bot: rgba(255,255,255,.07); --c-accent: #ff6a3d; --c-input: rgba(255,255,255,.06);
  --c-shadow: 0 30px 80px -20px rgba(0,0,0,.6);
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60;
  font-family: "General Sans", ui-sans-serif, system-ui, sans-serif; color: var(--c-ink);
}
.chat--admin {
  --c-bg: #fff; --c-panel: #fff; --c-line: #e6e9f0; --c-ink: #0f1b33; --c-soft: #5a6580;
  --c-user: #11275a; --c-user-ink: #fff; --c-bot: #f3f5f9; --c-accent: #ff6a3d; --c-input: #f3f5f9;
  --c-shadow: 0 24px 60px -18px rgba(17,39,90,.35);
}
[data-theme="dark"] .chat--admin {
  --c-bg: #111a2e; --c-panel: #111a2e; --c-line: #2a3653; --c-ink: #e7ecf5; --c-soft: #8e99b0;
  --c-user: #2c4c9a; --c-user-ink: #fff; --c-bot: rgba(255,255,255,.06); --c-input: rgba(255,255,255,.05);
  --c-shadow: 0 24px 60px -18px rgba(0,0,0,.7);
}
[data-theme="dark"] .chat--admin .chat__msg--assistant a { color: #a4bdff; }
[data-theme="dark"] .chat--admin .chat__launcher, [data-theme="dark"] .chat--admin .chat__avatar { background: #2c4c9a; }
.chat svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.chat__launcher {
  display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 22px 0 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--c-accent); color: #1a0d06; font-family: inherit; font-weight: 500; font-size: 15px; line-height: 1;
  box-shadow: 0 14px 34px -10px rgba(255,106,61,.6), 0 0 0 1px rgba(255,255,255,.08) inset;
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s;
}
.chat__launcher:hover { transform: translateY(-2px); }
.chat__launcher:active { transform: scale(.97); }
.chat--admin .chat__launcher { background: #11275a; color: #fff; box-shadow: 0 14px 30px -12px rgba(17,39,90,.6); }
.chat.is-open .chat__launcher { display: none; }

.chat__panel {
  position: absolute; right: 0; bottom: 0; width: min(400px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 32px));
  display: flex; flex-direction: column; background: var(--c-panel); border: 1px solid var(--c-line); border-radius: 22px; overflow: hidden;
  box-shadow: var(--c-shadow); animation: chat-in .35s cubic-bezier(.22,1,.36,1);
}
.chat--site .chat__panel { background: radial-gradient(420px 260px at 100% 0%, rgba(255,106,61,.16), transparent 60%), var(--c-panel); }
.chat__panel[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.chat__head { display: flex; align-items: center; gap: 10px; padding: 16px 14px 14px 18px; border-bottom: 1px solid var(--c-line); }
.chat__avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--c-accent); color: #1a0d06; flex: none; }
.chat--admin .chat__avatar { background: #11275a; color: #fff; }
.chat__title { flex: 1; min-width: 0; line-height: 1.25; }
.chat__title b { display: block; font-weight: 500; font-size: 15px; }
.chat__title small { color: var(--c-soft); font-size: 12px; }
.chat__icon { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--c-soft); cursor: pointer; }
.chat__icon:hover { background: var(--c-bot); color: var(--c-ink); }
.chat__icon svg { width: 18px; height: 18px; }

.chat__log { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; scrollbar-width: thin; }
.chat__msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.chat__msg p { margin: 0; }
.chat__msg p + p, .chat__msg p + ul, .chat__msg ul + p, .chat__msg p + ol, .chat__msg ol + p { margin-top: 8px; }
.chat__msg ul, .chat__msg ol { margin: 4px 0 0; padding-left: 18px; }
.chat__msg li + li { margin-top: 3px; }
.chat__msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.chat__msg b { font-weight: 600; }
.chat__msg--assistant { align-self: flex-start; background: var(--c-bot); border-bottom-left-radius: 6px; }
.chat--site .chat__msg--assistant a { color: #ffb08f; }
.chat--admin .chat__msg--assistant a { color: #11275a; font-weight: 500; }
.chat__msg--user { align-self: flex-end; background: var(--c-user); color: var(--c-user-ink); border-bottom-right-radius: 6px; }
.chat__msg.is-error { background: rgba(255,106,61,.12); }
.chat__typing { display: flex; gap: 5px; padding: 14px 16px; }
.chat__typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--c-soft); animation: chat-dot 1.2s infinite ease-in-out; }
.chat__typing i:nth-child(2) { animation-delay: .15s; } .chat__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.chat__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chat__chips:empty { display: none; }
.chat__chip { display: inline-flex; align-items: center; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--c-line); background: none; color: var(--c-ink); font-family: inherit; font-weight: 500; font-size: 13px; cursor: pointer; text-decoration: none; transition: border-color .2s, background-color .2s; }
.chat__chip:hover { border-color: var(--c-accent); background: rgba(255,106,61,.08); }
.chat__offline { display: grid; gap: 8px; justify-items: start; padding: 4px 2px; font-size: 14px; color: var(--c-soft); }
.chat__offline p { margin: 0 0 2px; }

.chat__form { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px; padding: 6px 6px 6px 14px; border: 1px solid var(--c-line); border-radius: 16px; background: var(--c-input); }
.chat__form[hidden] { display: none; }
.chat__form:focus-within { border-color: var(--c-accent); }
.chat__form textarea { flex: 1; min-height: 24px; max-height: 140px; padding: 7px 0; border: 0; outline: 0; resize: none; background: none; color: var(--c-ink); font-family: inherit; font-size: 14.5px; line-height: 1.45; box-shadow: none; height: auto; }
.chat__form textarea::placeholder { color: var(--c-soft); }
.chat__send { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 12px; background: var(--c-accent); color: #1a0d06; cursor: pointer; flex: none; }
.chat__send:disabled { opacity: .5; cursor: progress; }
.chat__note { margin: 0; padding: 8px 16px 12px; font-size: 11.5px; line-height: 1.4; color: var(--c-soft); text-align: center; }
.chat__note a { color: inherit; }

@media (max-width: 560px) {
  .chat__launcher span { display: none; }
  .chat__launcher { width: 56px; padding: 0; justify-content: center; }
  .chat.is-open { inset: 0; }
  .chat__panel { position: fixed; inset: 0; width: auto; height: 100dvh; border-radius: 0; border: 0; }
}
@media (prefers-reduced-motion: reduce) { .chat__panel, .chat__typing i { animation: none; } }
@media print { .chat { display: none !important; } }
