/* =============================================
   CHAT WIDGET — matches site design tokens
   ============================================= */

/* ── Container ─────────────────────────────── */
.cw {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ── Bubble (collapsed trigger) ────────────── */
.cw__bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px 13px 16px;
  background: #C17F3E;
  color: #FFFFFF;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(193, 127, 62, 0.40);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition:
    transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.18s ease;
  white-space: nowrap;
  transform-origin: bottom right;
}

.cw__bubble:hover {
  background: #A86C2E;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(193, 127, 62, 0.50);
}

.cw__bubble:focus-visible {
  outline: 2px solid #C17F3E;
  outline-offset: 3px;
}

/* ── Launcher stack ─────────────────────────── */
.cw__launchers {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  transition:
    opacity 0.18s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide launchers when any panel is open */
.cw.chat-open .cw__launchers,
.cw.proposal-open .cw__launchers {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.88) translateY(6px);
}

/* Secondary (ghost) bubble — Get Proposal button */
.cw__bubble--secondary {
  background: #FFFFFF;
  color: #0F1623;
  border: 1.5px solid #DDD8D0;
  box-shadow: 0 2px 14px rgba(15, 22, 35, 0.10);
}

.cw__bubble--secondary:hover {
  background: #FFFFFF;
  border-color: #C17F3E;
  color: #C17F3E;
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(15, 22, 35, 0.14);
}

/* ── Panel (expanded chat) ──────────────────── */
.cw__panel {
  /* Take panels out of flex flow so they don't push launchers off-screen.
     100% = height of .cw (the launcher stack). Panels float above it. */
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;

  width: 360px;
  height: 480px;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow:
    0 2px 8px rgba(15, 22, 35, 0.08),
    0 16px 48px rgba(15, 22, 35, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #DDD8D0;

  /* Hidden state */
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  transition:
    opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Visible state — Q&A panel */
.cw.chat-open .cw__panel:not(.cw__panel--proposal) {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* Visible state — Proposal panel */
.cw.proposal-open .cw__panel--proposal {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ── Panel Header ────────────────────────────── */
.cw__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #0F1623;
  flex-shrink: 0;
}

.cw__header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cw__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(193, 127, 62, 0.2);
  color: #C17F3E;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.cw__name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.93rem;
  font-weight: 600;
  color: #FFFFFF;
  line-height: 1.2;
}

.cw__status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.06em;
  margin-top: 1px;
}

.cw__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ADE80;
  flex-shrink: 0;
}

.cw__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.cw__close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
}

.cw__close:focus-visible {
  outline: 2px solid #C17F3E;
  outline-offset: 2px;
}

/* ── Messages area ────────────────────────────── */
.cw__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: #F9F7F4;
}

.cw__messages::-webkit-scrollbar {
  width: 4px;
}
.cw__messages::-webkit-scrollbar-track {
  background: transparent;
}
.cw__messages::-webkit-scrollbar-thumb {
  background: #DDD8D0;
  border-radius: 4px;
}

/* ── Message bubbles ──────────────────────────── */
.cw__msg {
  max-width: 82%;
  animation: msgIn 0.2s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cw__msg p {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.55;
  padding: 10px 13px;
  border-radius: 12px;
}

/* AI message — left */
.cw__msg--ai {
  align-self: flex-start;
}

.cw__msg--ai p {
  background: #FFFFFF;
  color: #0F1623;
  border: 1px solid #EAE6E0;
  border-bottom-left-radius: 4px;
}

/* User message — right */
.cw__msg--user {
  align-self: flex-end;
}

.cw__msg--user p {
  background: #0F1623;
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

/* Error message */
.cw__msg--error p {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
  font-size: 0.82rem;
}

/* ── Typing indicator ─────────────────────────── */
.cw__typing {
  align-self: flex-start;
  animation: msgIn 0.2s ease both;
}

.cw__typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  background: #FFFFFF;
  border: 1px solid #EAE6E0;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.cw__typing-dots span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #C17F3E;
  animation: typingBounce 1.1s ease-in-out infinite;
}

.cw__typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.cw__typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1;   }
}

/* ── Input area ───────────────────────────────── */
.cw__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #EAE6E0;
  background: #FFFFFF;
  flex-shrink: 0;
}

.cw__input {
  flex: 1;
  border: 1.5px solid #DDD8D0;
  border-radius: 8px;
  padding: 9px 13px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  color: #0F1623;
  background: #F9F7F4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}

.cw__input::placeholder {
  color: #B0AAA4;
}

.cw__input:focus {
  border-color: #C17F3E;
  box-shadow: 0 0 0 3px rgba(193, 127, 62, 0.12);
  background: #FFFFFF;
}

.cw__input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cw__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #C17F3E;
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

.cw__send:hover:not(:disabled) {
  background: #A86C2E;
  transform: scale(1.06);
}

.cw__send:disabled {
  background: #DDD8D0;
  color: #B0AAA4;
  cursor: not-allowed;
  transform: none;
}

.cw__send:focus-visible {
  outline: 2px solid #C17F3E;
  outline-offset: 2px;
}

/* ── Proposal header variant ─────────────────── */
.cw__header--proposal {
  background: #1A1008;
  border-bottom: 2px solid #C17F3E;
}

.cw__avatar--proposal {
  background: rgba(193, 127, 62, 0.18);
  color: #C17F3E;
}

/* ── Progress bar ─────────────────────────────── */
.cw__progress {
  height: 3px;
  background: #EAE6E0;
  flex-shrink: 0;
  overflow: hidden;
}

.cw__progress-bar {
  height: 100%;
  background: #C17F3E;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Mobile ───────────────────────────────────── */
@media (max-width: 480px) {
  .cw {
    bottom: 16px;
    right: 16px;
    left: 16px;
    align-items: flex-end;
  }

  .cw__panel {
    width: 100%;
    height: 72vh;
    max-height: 520px;
  }

  .cw__bubble-label {
    display: none;
  }

  .cw__bubble {
    padding: 14px;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    justify-content: center;
  }
}
