/* Panthagani chat widget — floating bubble + overlay panel + inline /chat/ variant. */

.chat-bubble {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 22px 0 16px;
  border: 0; border-radius: 999px; cursor: pointer;
  color: #fff; font-family: var(--font-body); font-size: .96rem; font-weight: 600;
  background: var(--glass-navy-solid);
  box-shadow: 0 14px 34px -8px rgba(0, 59, 112, .48),
              inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform 220ms cubic-bezier(.2,.8,.2,1),
              box-shadow 220ms cubic-bezier(.2,.8,.2,1);
}
.chat-bubble:hover { transform: translateY(-2px); box-shadow: 0 20px 44px -10px rgba(0, 59, 112, .55); }
.chat-bubble.is-dismissed {
  opacity: 0; transform: translateY(20px) scale(.9); pointer-events: none;
  transition: opacity 260ms ease, transform 260ms ease;
}
.chat-bubble__icon { display: block; flex: 0 0 auto; }
.chat-bubble__label { white-space: nowrap; letter-spacing: .01em; }
.chat-bubble__pulse {
  position: absolute; inset: 0; border-radius: 999px; pointer-events: none;
  background: rgba(21, 165, 120, .55);
  opacity: 0; transform: scale(1);
  animation: chatPulse 3s ease-out infinite;
  will-change: transform, opacity;
}
/* transform + opacity only — these are composited, so the pulse
   doesn't trigger paint/layout on every frame (unlike box-shadow
   expansion, which does). */
@keyframes chatPulse {
  0%   { transform: scale(1);    opacity: .55; }
  70%  { transform: scale(1.45); opacity: 0; }
  100% { transform: scale(1.45); opacity: 0; }
}

@media (max-width: 640px) {
  .chat-bubble { width: 56px; padding: 0; justify-content: center; }
  .chat-bubble__label { display: none; }
}

/* ---------- Panel ---------- */
.chat-panel {
  display: flex; flex-direction: column;
  background: #fff; color: var(--color-text);
  font-family: var(--font-body);
  overflow: hidden;
}
.chat-panel--overlay {
  position: fixed; right: 22px; bottom: 92px; z-index: 100;
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 120px));
  border-radius: 18px;
  box-shadow: 0 40px 100px -24px rgba(0, 41, 82, .55);
  transform: translateY(16px) scale(.98); opacity: 0;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1),
              opacity 220ms ease;
  border: 1px solid rgba(0, 59, 112, .12);
}
.chat-panel--overlay.is-open { transform: none; opacity: 1; }
.chat-panel--overlay[hidden] { display: none; }

.chat-panel--inline {
  width: 100%; max-width: 860px; margin: 0 auto;
  min-height: min(720px, 85dvh);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
}

.chat-panel__header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px;
  color: #fff;
}
.chat-panel__brand { display: flex; align-items: center; gap: 12px; }
.chat-panel__avatar {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  background: rgba(255,255,255,.14);
  color: #fff;
}
.chat-panel__title {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 600;
  line-height: 1.1;
}
.chat-panel__sub {
  font-size: .76rem; opacity: .82; margin-top: 2px;
}
.chat-panel__close {
  border: 0; background: rgba(255,255,255,.12); color: #fff;
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; transition: background 180ms ease;
}
.chat-panel__close:hover { background: rgba(255,255,255,.22); }

/* ---------- Log ---------- */
.chat-panel__log {
  flex: 1 1 auto; overflow-y: auto;
  padding: 18px 18px 8px;
  background: linear-gradient(180deg, var(--color-surface) 0%, #fff 120px);
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: .94rem; line-height: 1.48;
  animation: chatIn 220ms cubic-bezier(.2,.8,.2,1);
}
@keyframes chatIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.chat-msg p { margin: 0; }
.chat-msg p + p { margin-top: 8px; }
.chat-msg--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 6px;
}
.chat-msg--user {
  align-self: flex-end;
  background: var(--glass-navy-solid);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.chat-msg--greeting {
  background: var(--color-surface-2);
  border: 0;
}
.chat-msg--thinking { display: flex; align-items: center; padding: 14px; }
.chat-dots { display: inline-flex; gap: 4px; }
.chat-dots span {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--color-accent-strong);
  animation: chatDot 1.1s infinite ease-in-out;
}
.chat-dots span:nth-child(2) { animation-delay: .15s; }
.chat-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes chatDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Suggestions ---------- */
.chat-panel__suggestions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 6px 18px 10px;
}
.chat-chip {
  border: 1px solid var(--color-border);
  background: #fff;
  font-family: var(--font-body); font-size: .82rem; color: var(--color-primary);
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  transition: all 180ms ease;
}
.chat-chip:hover {
  border-color: var(--color-accent-strong);
  color: var(--color-accent-strong);
  background: #f0faf5;
  transform: translateY(-1px);
}

/* ---------- Form ---------- */
.chat-panel__form {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--color-border);
  background: #fff;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-panel__book {
  align-self: stretch;
  justify-content: center;
  min-height: 40px;
  font-size: .9rem;
  gap: .5rem;
}
.chat-panel__input-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.chat-panel__input-row:focus-within {
  border-color: var(--color-accent-strong);
  box-shadow: 0 0 0 3px rgba(10, 122, 90, .14);
}
.chat-panel__input-row textarea {
  flex: 1 1 auto;
  border: 0; outline: 0; resize: none;
  background: transparent; color: var(--color-text);
  font: inherit;
  line-height: 1.45;
  max-height: 140px;
  padding: 6px 0;
}
.chat-panel__send {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 999px;
  border: 0; cursor: pointer;
  background: var(--color-accent-strong);
  color: #fff;
  display: grid; place-items: center;
  transition: background 180ms ease, transform 180ms ease;
}
.chat-panel__send:hover { background: var(--color-primary); transform: scale(1.05); }
.chat-panel__send[disabled] { opacity: .5; cursor: wait; }
.chat-panel__disclaimer {
  margin: 0; font-size: .72rem; color: var(--color-muted);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .chat-panel--overlay {
    right: 0; bottom: 0;
    width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-bubble__pulse, .chat-msg, .chat-dots span, .chat-panel { animation: none; transition: none; }
}

/* ---------- /chat/ page ---------- */
.chat-page { padding: clamp(40px, 6vw, 80px) 0 clamp(60px, 8vw, 110px); background: var(--color-surface); }
.chat-page__header { text-align: center; max-width: 680px; margin: 0 auto clamp(28px, 4vw, 44px); }
.chat-page__header h1 { margin: 6px 0 12px; }
.chat-page__lead { color: var(--color-muted); font-size: 1.1rem; line-height: 1.55; }

/* Word-level fade-in for streamed assistant replies. */
.chat-word {
  display: inline;
  animation: chatWord 260ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes chatWord {
  from { opacity: 0; filter: blur(3px); transform: translateY(3px); }
  to   { opacity: 1; filter: blur(0);   transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-word { animation: none; }
}
