/* ---- Chat widget ---- */
.chat-launcher {
  position: fixed;
  bottom: 26px; right: 26px;
  z-index: 300;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--blue-600), var(--blue-900));
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px -8px rgba(10, 34, 64, 0.5);
  border: none;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.chat-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 16px 36px -8px rgba(10, 34, 64, 0.55); }
.chat-launcher svg { width: 26px; height: 26px; transition: opacity 0.2s ease, transform 0.2s ease; }
.chat-launcher .icon-close { position: absolute; opacity: 0; transform: scale(0.7); }
.chat-launcher.is-open .icon-chat { opacity: 0; transform: scale(0.7); }
.chat-launcher.is-open .icon-close { opacity: 1; transform: scale(1); }
.chat-launcher .ping {
  position: absolute; top: -3px; right: -3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--white);
}

.chat-panel {
  position: fixed;
  bottom: 100px; right: 26px;
  z-index: 300;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-header {
  background: linear-gradient(135deg, var(--blue-800), var(--blue-950));
  color: var(--white);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-header .avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-header .avatar svg { width: 20px; height: 20px; }
.chat-header .meta strong { display: block; font-family: var(--font-body); font-size: 0.95rem; }
.chat-header .meta span { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; color: rgba(255,255,255,0.7); }
.chat-header .meta span::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; display: inline-block; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--blue-50);
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--blue-200); border-radius: 3px; }

.chat-msg { max-width: 84%; font-size: 0.9rem; line-height: 1.5; padding: 11px 14px; border-radius: 14px; }
.chat-msg.from-bot { align-self: flex-start; background: var(--white); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-msg.from-user { align-self: flex-end; background: var(--blue-700); color: var(--white); border-bottom-right-radius: 4px; }
.chat-msg.is-error { background: #fdecec; border-color: #f3c6c6; color: #8a1f1f; }

.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px; background: var(--blue-50); flex-shrink: 0; }
.chat-suggestion {
  font-size: 0.78rem;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--blue-200);
  background: var(--white);
  color: var(--blue-700);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.chat-suggestion:hover { background: var(--blue-100); border-color: var(--blue-400); }

.chat-typing { display: inline-flex; gap: 4px; align-self: flex-start; padding: 12px 14px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; border-bottom-left-radius: 4px; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--blue-300); animation: chatTyping 1.2s ease-in-out infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTyping { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--white);
  flex-shrink: 0;
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.88rem;
  max-height: 90px;
  background: var(--blue-50);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.chat-input-row textarea:focus { outline: none; border-color: var(--blue-500); background: var(--white); }
.chat-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--blue-700);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: none;
  transition: background 0.2s ease, transform 0.2s ease;
}
.chat-send:hover:not(:disabled) { background: var(--blue-600); transform: scale(1.05); }
.chat-send:disabled { opacity: 0.5; cursor: default; }
.chat-send svg { width: 18px; height: 18px; }

.chat-footnote { font-size: 0.68rem; color: var(--ink-soft); text-align: center; padding: 0 16px 12px; background: var(--white); flex-shrink: 0; }

@media (max-width: 480px) {
  .chat-panel { right: 16px; left: 16px; width: auto; bottom: 92px; height: min(560px, calc(100vh - 130px)); }
  .chat-launcher { right: 16px; bottom: 18px; }
}
