/* ===== Chat Widget v2 ===== */
:root {
  --cw-bg: #ffffff;
  --cw-text: #111827;
  --cw-muted: #6b7280;
  --cw-border: rgba(17, 24, 39, 0.12);
  --cw-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
  --cw-primary: #2563eb;
  --cw-primary-2: #1d4ed8;
  --cw-bot: #f3f4f6;
  --cw-user: #2563eb;
  --cw-user-text: #ffffff;
  --cw-radius: 18px;
  --cw-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
}

/* Mini header bar */
.cw-mini-header {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 396px;
  max-width: calc(100vw - 44px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  background: linear-gradient(180deg, rgba(37,99,235,0.10), rgba(37,99,235,0.02));
  background-color: var(--cw-bg);
  border: 1px solid var(--cw-border);
  border-radius: 20px;
  box-shadow: var(--cw-shadow);
  cursor: pointer;
  z-index: 999999;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cw-mini-header:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

/* Widget container */
.cw-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 396px;
  max-width: calc(100vw - 44px);
  height: 572px;
  max-height: calc(100vh - 140px);
  background: var(--cw-bg);
  border: 1px solid var(--cw-border);
  border-radius: 20px;
  box-shadow: var(--cw-shadow);
  overflow: hidden;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
  animation: cw-pop 0.16s ease-out;
}

@keyframes cw-pop {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Header */
.cw-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--cw-border);
  background: linear-gradient(180deg, rgba(37,99,235,0.10), rgba(37,99,235,0.02));
}
.cw-avatar {
  width: 60px;
  height: 60px;
  border-radius: 100%;
  border: 1px solid var(--cw-border);
  background: #e5e7eb;
  overflow: hidden;
  flex: 0 0 auto;
}
.cw-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 70% 20%; /* move right */
}
.cw-title {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.cw-title strong {
  font-family: var(--cw-font);
  font-size: 17px;
  color: var(--cw-text);
}
.cw-title span {
  font-family: var(--cw-font);
  font-size: 12px;
  color: var(--cw-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.cw-header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.cw-iconbtn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--cw-border);
  background: rgba(255,255,255,0.7);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}
.cw-iconbtn:hover { background: rgba(255,255,255,1); }
.cw-iconbtn svg { width: 18px; height: 18px; fill: #111827; opacity: 0.85; }

/* Messages */
.cw-body {
  flex: 1;
  padding: 14px;
  overflow: auto;
  background: radial-gradient(1200px 600px at 20% 10%, rgba(37,99,235,0.07), rgba(255,255,255,0));
}

.cw-msg {
  display: flex;
  gap: 10px;
  margin: 10px 0;
  align-items: flex-end;
  font-family: var(--cw-font);
  font-size: 14px;
  color: var(--cw-text);
}
.cw-msg.cw-user { justify-content: flex-end; }

.cw-bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: var(--cw-radius);
  border: 1px solid var(--cw-border);
  background: var(--cw-bot);
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.cw-user .cw-bubble {
  background: linear-gradient(180deg, var(--cw-user), var(--cw-primary-2));
  border-color: rgba(37,99,235,0.35);
  color: var(--cw-user-text);
}

.cw-meta {
  font-size: 11px;
  color: var(--cw-muted);
  margin-top: 6px;
}

/* Typing indicator */
.cw-typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.cw-dot {
  width: 9px;
  height: 9px;
  background: #2563eb;
  border-radius: 999px;
  animation: cw-bounce 1.1s infinite ease-in-out;
}
.cw-dot:nth-child(2) { animation-delay: 0.15s; }
.cw-dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes cw-bounce {
  0%, 75%, 100% { transform: translateY(0); opacity: 0.45; }
  37% { transform: translateY(-7px); opacity: 1; }
}

/* Input area */
.cw-footer {
  border-top: 1px solid var(--cw-border);
  padding: 10px;
  display: flex;
  gap: 10px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
}

.cw-input {
  flex: 1;
  border: 1px solid var(--cw-border);
  border-radius: 14px;
  padding: 10px 12px;
  font-family: var(--cw-font);
  font-size: 14px;
  outline: none;
}
.cw-input:focus {
  border-color: rgba(37,99,235,0.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.10);
}

.cw-send {
  border: 1px solid rgba(37,99,235,0.45);
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-family: var(--cw-font);
  font-weight: 600;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.cw-send:hover { filter: brightness(1.03); }
.cw-send:active { transform: scale(0.98); }
.cw-send:disabled { opacity: 0.6; cursor: not-allowed; }

/* Mobile tweaks */
@media (max-width: 420px) {
  .cw-panel {
    right: 14px;
    left: 14px;
    width: auto;
    bottom: 14px;
  }
  .cw-mini-header {
    right: 14px;
    left: 14px;
    width: auto;
    bottom: 14px;
  }
  .cw-title span { max-width: 170px; }
}
/* Suggestion chips */
.cw-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 4px;
}
.cw-suggestion-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #2563eb;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 6px 12px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  white-space: normal;
  line-height: 1.4;
}
.cw-suggestion-btn:hover {
  background: #2563eb;
  color: #fff;
}
