/* =============================================
   CHAT WIDGET — Carbon Intelligence India
   Design tokens: --black #000, --green #86BC25,
   --green-dark #009A44
   ============================================= */

/* ── 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: #000000;
  color: #86BC25;
  border: 1.5px solid #86BC25;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(134, 188, 37, 0.25);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition:
    transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.18s ease;
  white-space: nowrap;
  transform-origin: bottom right;
}

.cw__bubble:hover {
  background: #86BC25;
  color: #000000;
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(134, 188, 37, 0.40);
}

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

/* ── Bubble icon ────────────────────────────── */
.cw__bubble-icon {
  font-size: 1rem;
  line-height: 1;
}

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

/* ── Panel (expanded chat) ──────────────────── */
.cw__panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;

  width: 370px;
  height: 500px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.12),
    0 16px 48px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #D0D0D0;

  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);
}

.cw.chat-open .cw__panel {
  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: #000000;
  flex-shrink: 0;
  border-bottom: 2px solid #86BC25;
}

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

.cw__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(134, 188, 37, 0.15);
  color: #86BC25;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  border: 1px solid rgba(134, 188, 37, 0.3);
}

.cw__name {
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.cw__subtitle {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.05em;
  margin-top: 1px;
  text-transform: uppercase;
}

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

.cw__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #86BC25;
  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.6);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.cw__close:hover {
  background: rgba(134, 188, 37, 0.2);
  color: #86BC25;
}

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

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

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

@keyframes cwMsgIn {
  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.855rem;
  line-height: 1.55;
  padding: 10px 13px;
  border-radius: 10px;
}

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

.cw__msg--ai p {
  background: #ffffff;
  color: #1A1A1A;
  border: 1px solid #E8E8E8;
  border-bottom-left-radius: 3px;
}

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

.cw__msg--user p {
  background: #000000;
  color: #ffffff;
  border-bottom-right-radius: 3px;
}

/* Error */
.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: cwMsgIn 0.2s ease both;
}

.cw__typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 11px 14px;
  background: #ffffff;
  border: 1px solid #E8E8E8;
  border-radius: 10px;
  border-bottom-left-radius: 3px;
}

.cw__typing-dots span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #86BC25;
  animation: cwTypingBounce 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 cwTypingBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Suggested questions ──────────────────────── */
.cw__suggestions {
  padding: 0 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #F8F8F8;
  flex-shrink: 0;
}

.cw__suggestion-label {
  font-size: 0.68rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  margin-bottom: 2px;
}

.cw__suggestion-btn {
  background: #ffffff;
  border: 1px solid #D0D0D0;
  border-radius: 6px;
  padding: 7px 11px;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: #333;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.4;
}

.cw__suggestion-btn:hover {
  border-color: #86BC25;
  background: rgba(134, 188, 37, 0.06);
  color: #1A1A1A;
}

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

.cw__input {
  flex: 1;
  border: 1.5px solid #D0D0D0;
  border-radius: 7px;
  padding: 9px 13px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.855rem;
  color: #1A1A1A;
  background: #F8F8F8;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}

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

.cw__input:focus {
  border-color: #86BC25;
  box-shadow: 0 0 0 3px rgba(134, 188, 37, 0.14);
  background: #ffffff;
}

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

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

.cw__send:hover:not(:disabled) {
  background: #86BC25;
  color: #000000;
  transform: scale(1.05);
}

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

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

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

  .cw__bubble-label { display: none; }

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