/* ================================================================
   Creative Loop — Chatbot Widget CSS
   Floating chat bubble + panel, matches landing page design system
   ================================================================ */

/* ── Floating Button ─────────────────────────────────────────── */
.cl-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124,58,237,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.cl-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(124,58,237,0.45);
}
.cl-chat-btn svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: opacity 0.2s, transform 0.2s;
}
.cl-chat-btn .icon-close { display: none; }
.cl-chat-btn.active .icon-chat { display: none; }
.cl-chat-btn.active .icon-close { display: block; }

/* Pulse animation on load */
.cl-chat-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(124,58,237,0.3);
  animation: chatPulse 2s ease-out 3;
}
@keyframes chatPulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ── Chat Panel ──────────────────────────────────────────────── */
.cl-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}
.cl-chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ── Header ──────────────────────────────────────────────────── */
.cl-chat-header {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cl-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cl-chat-avatar img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.cl-chat-header-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}
.cl-chat-header-info p {
  font-size: 12px;
  opacity: 0.8;
  margin: 2px 0 0;
  line-height: 1.3;
}

/* ── Messages Area ───────────────────────────────────────────── */
.cl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.cl-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.cl-chat-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

/* ── Message Bubbles ─────────────────────────────────────────── */
.cl-chat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msgAppear 0.25s ease-out;
}
@keyframes msgAppear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.cl-chat-msg--bot {
  align-self: flex-start;
}
.cl-chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cl-chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.cl-chat-msg--bot .cl-chat-msg-avatar {
  background: rgba(124,58,237,0.1);
  color: #7c3aed;
}
.cl-chat-msg--user .cl-chat-msg-avatar {
  background: rgba(99,102,241,0.1);
  color: #6366f1;
}

.cl-chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.cl-chat-msg--bot .cl-chat-bubble {
  background: #f3f4f6;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.cl-chat-msg--user .cl-chat-bubble {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────── */
.cl-chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}
.cl-chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  animation: typingBounce 1.2s infinite;
}
.cl-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.cl-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Input Area ──────────────────────────────────────────────── */
.cl-chat-input-wrap {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  background: #fafbfc;
}
.cl-chat-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #1e293b;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.2s;
}
.cl-chat-input:focus {
  border-color: #7c3aed;
}
.cl-chat-input::placeholder {
  color: #94a3b8;
}
.cl-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}
.cl-chat-send:hover {
  opacity: 0.9;
  transform: scale(1.05);
}
.cl-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.cl-chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ── Suggested Questions ─────────────────────────────────────── */
.cl-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.cl-chat-suggestion {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  line-height: 1.4;
}
.cl-chat-suggestion:hover {
  background: #ede9fe;
  border-color: #7c3aed;
  color: #7c3aed;
}

/* ── Powered by ──────────────────────────────────────────────── */
.cl-chat-powered {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  padding: 6px 16px 10px;
  background: #fafbfc;
}
.cl-chat-powered a {
  color: #7c3aed;
  text-decoration: none;
}

/* ── Mobile Responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  .cl-chat-btn {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  .cl-chat-panel {
    bottom: 82px;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: none;
    height: calc(100vh - 110px);
    max-height: none;
  }
}
