/* ============================================================
   APEX Assistant — chat widget
   Uses the site design tokens from styles.css (:root vars).
   ============================================================ */

.cw-btn {
  position: fixed; right: 22px; bottom: 22px; z-index: 9990;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--green, #84C13E); border: none; cursor: pointer;
  box-shadow: 0 6px 18px var(--green-glow, rgba(132,193,62,0.35));
  display: flex; align-items: center; justify-content: center;
  transition: transform .25s cubic-bezier(0.22,1,0.36,1), box-shadow .25s;
}
.cw-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px var(--green-glow, rgba(132,193,62,0.35)); }
.cw-btn svg { width: 26px; height: 26px; fill: #0c1a04; }
.cw-btn .cw-close-icon { display: none; }
.cw-open .cw-btn .cw-chat-icon { display: none; }
.cw-open .cw-btn .cw-close-icon { display: block; }

.cw-panel {
  position: fixed; right: 22px; bottom: 92px; z-index: 9991;
  width: 372px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 120px);
  background: var(--bg, #fff); border: 1px solid var(--line, #E6EBE6);
  border-radius: var(--radius-lg, 22px);
  box-shadow: 0 24px 60px rgba(14,20,19,0.18);
  display: none; flex-direction: column; overflow: hidden;
  font-family: var(--font, "Inter", sans-serif);
}
.cw-open .cw-panel { display: flex; }

.cw-head {
  background: var(--ink, #0E1413); color: #fff;
  padding: 16px 18px; display: flex; align-items: center; gap: 10px;
}
.cw-head-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green, #84C13E); flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(132,193,62,0.25);
}
.cw-head-title { font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.cw-head-sub { font-size: 0.74rem; color: rgba(255,255,255,0.65); margin-top: 1px; }

.cw-msgs {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-soft, #F6F9F4);
}
.cw-msg {
  max-width: 85%; padding: 10px 14px; border-radius: 16px;
  font-size: 0.9rem; line-height: 1.45; white-space: pre-wrap;
  word-wrap: break-word; overflow-wrap: break-word;
}
.cw-msg a { color: var(--green-700, #568A22); text-decoration: underline; }
.cw-msg-bot {
  align-self: flex-start; background: #fff; color: var(--body, #44504C);
  border: 1px solid var(--line, #E6EBE6); border-bottom-left-radius: 6px;
}
.cw-msg-user {
  align-self: flex-end; background: var(--ink, #0E1413); color: #fff;
  border-bottom-right-radius: 6px;
}

.cw-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; }
.cw-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted, #6B7770);
  animation: cw-bounce 1.2s infinite;
}
.cw-typing span:nth-child(2) { animation-delay: 0.15s; }
.cw-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cw-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.cw-input-row {
  display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line, #E6EBE6);
  background: #fff;
}
.cw-input {
  flex: 1; border: 1px solid var(--line-2, #D6DDD6); border-radius: 999px;
  padding: 10px 16px; font-size: 0.9rem; font-family: inherit; outline: none;
  color: var(--ink, #0E1413); background: #fff;
}
.cw-input:focus { border-color: var(--green, #84C13E); }
.cw-send {
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--green, #84C13E); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .2s;
}
.cw-send:hover { background: var(--green-600, #6BA52E); }
.cw-send:disabled { background: var(--line-2, #D6DDD6); cursor: default; }
.cw-send svg { width: 18px; height: 18px; fill: #0c1a04; }

.cw-note {
  text-align: center; font-size: 0.68rem; color: var(--muted, #6B7770);
  padding: 0 12px 10px; background: #fff;
}

@media (max-width: 520px) {
  .cw-panel {
    right: 0; bottom: 0; width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh; border-radius: 0; border: none;
  }
  .cw-open .cw-btn { bottom: auto; top: 12px; right: 12px; width: 44px; height: 44px; z-index: 9992; }
}

@media (prefers-reduced-motion: reduce) {
  .cw-btn, .cw-send { transition: none; }
  .cw-typing span { animation: none; opacity: .6; }
}
