/* ============================================================
   chat-widget.css — dual-mode floating chat
   Custom "Need help?" card with two entry points:
     - Start a call  -> ElevenLabs ConvAI (voice)
     - Send a message -> /api/chat (text, Groq Llama)
   ============================================================ */

/* ---------- Floating "Need help?" card ---------- */
.cw-card {
  position: fixed;
  z-index: 9998;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: white;
  border-radius: 18px;
  box-shadow:
    0 24px 60px -28px hsl(202 80% 12% / 0.35),
    0 4px 12px -4px hsl(202 80% 12% / 0.15);
  font-family: inherit;
  min-width: 260px;
  max-width: 320px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.cw-card[hidden] { display: none; }

.cw-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cw-card__logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background:
    conic-gradient(from 60deg,
      hsl(165 55% 45%),
      hsl(15 75% 70%),
      hsl(165 55% 45%) 60%,
      hsl(15 85% 58%),
      hsl(165 55% 45%));
  box-shadow:
    0 4px 10px -4px hsl(202 80% 12% / 0.3) inset,
    0 2px 8px -2px hsl(15 85% 58% / 0.35);
}

.cw-card__title {
  font-weight: 600;
  font-size: 1rem;
  color: hsl(202 80% 12%);
  letter-spacing: -0.01em;
}

.cw-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.cw-card__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  line-height: 1;
}
.cw-card__btn:hover { transform: translateY(-1px); }
.cw-card__btn:active { transform: translateY(0); }

.cw-card__btn--call {
  background: hsl(202 80% 12%);
  color: white;
}
.cw-card__btn--call:hover {
  box-shadow: 0 6px 18px -6px hsl(202 80% 12% / 0.5);
}

.cw-card__btn--text {
  background: hsl(15 85% 58%);
  color: white;
}
.cw-card__btn--text:hover {
  box-shadow: 0 6px 18px -6px hsl(15 85% 58% / 0.5);
}

.cw-card__btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------- Text chat panel ---------- */
.cw-text-panel {
  position: fixed;
  z-index: 10000;
  bottom: 20px;
  right: 20px;
  width: min(380px, calc(100vw - 40px));
  height: min(540px, calc(100vh - 40px));
  background: hsl(38 40% 98.5%);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 24px 60px -28px hsl(202 80% 12% / 0.4),
    0 8px 16px -4px hsl(202 80% 12% / 0.2);
  overflow: hidden;
  font-family: inherit;
}
.cw-text-panel[hidden] { display: none; }

.cw-text-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: white;
  border-bottom: 1px solid hsl(196 70% 28% / 0.10);
}

.cw-text-panel__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.98rem;
  color: hsl(202 80% 12%);
}

.cw-text-panel__logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    conic-gradient(from 60deg,
      hsl(165 55% 45%),
      hsl(15 75% 70%),
      hsl(165 55% 45%) 60%,
      hsl(15 85% 58%),
      hsl(165 55% 45%));
  box-shadow:
    0 2px 6px -2px hsl(202 80% 12% / 0.3) inset,
    0 1px 4px -1px hsl(15 85% 58% / 0.35);
}

.cw-text-panel__close {
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(202 80% 12%);
  transition: background 0.15s ease;
}
.cw-text-panel__close:hover { background: hsl(196 70% 28% / 0.08); }
.cw-text-panel__close svg { width: 18px; height: 18px; }

.cw-text-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.cw-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.94rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: cwMsgIn 0.2s ease;
}
@keyframes cwMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.cw-msg--user {
  align-self: flex-end;
  background: hsl(202 80% 12%);
  color: white;
  border-bottom-right-radius: 4px;
}

.cw-msg--assistant {
  align-self: flex-start;
  background: white;
  color: hsl(202 80% 12%);
  border: 1px solid hsl(196 70% 28% / 0.12);
  border-bottom-left-radius: 4px;
}

.cw-msg--typing {
  align-self: flex-start;
  background: white;
  border: 1px solid hsl(196 70% 28% / 0.12);
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  min-width: 48px;
  color: hsl(202 80% 12%);
}
.cw-msg--typing::after {
  content: '…';
  display: inline-block;
  animation: cwBlink 1.2s infinite;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
}
@keyframes cwBlink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.cw-text-panel__inputrow {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid hsl(196 70% 28% / 0.10);
  background: white;
  align-items: center;
}

.cw-text-panel__input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid hsl(196 70% 28% / 0.2);
  font-size: 0.95rem;
  background: hsl(38 40% 98.5%);
  font-family: inherit;
  color: hsl(202 80% 12%);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cw-text-panel__input:focus {
  outline: none;
  border-color: hsl(15 85% 58%);
  box-shadow: 0 0 0 3px hsl(15 85% 58% / 0.18);
}
.cw-text-panel__input::placeholder {
  color: hsl(202 80% 12% / 0.4);
}

.cw-text-panel__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: hsl(15 85% 58%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, transform 0.08s ease;
  flex-shrink: 0;
}
.cw-text-panel__send:hover { transform: scale(1.05); }
.cw-text-panel__send:active { transform: scale(0.95); }
.cw-text-panel__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.cw-text-panel__send svg { width: 18px; height: 18px; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .cw-text-panel {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }
  .cw-card {
    bottom: 16px;
    right: 16px;
    left: auto;
  }
}

/* ---------- Mode escape hatches ---------- */
.cw-card[data-mode="voice"] { display: none; }
.cw-text-panel[data-mode="voice"] { display: none; }
