/* ============================================
   Chat Widget — METAMORPHO MEDIA
   ============================================ */

#cw-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7C3AED 0%, #06B6D4 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(124, 58, 237, 0.5), 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1), box-shadow 0.25s ease;
  z-index: 9990;
}

#cw-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(124, 58, 237, 0.65), 0 3px 12px rgba(0,0,0,0.3);
}

#cw-bubble.active {
  background: linear-gradient(135deg, #6D28D9 0%, #0891B2 100%);
}

#cw-bubble svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

#cw-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #EF4444;
  border: 2.5px solid #fff;
  border-radius: 50%;
  display: none;
  animation: cwPulse 2s ease-in-out infinite;
}

@keyframes cwPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ─── PANEL ─────────────────────────────────── */
#cw-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 360px;
  height: 520px;
  background: #0D0822;
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9989;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16,1,0.3,1), transform 0.3s cubic-bezier(0.16,1,0.3,1);
}

#cw-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ─── HEADER ─────────────────────────────────── */
#cw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(124,58,237,0.3) 0%, rgba(6,182,212,0.15) 100%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

#cw-header-left { display: flex; flex-direction: column; gap: 2px; }

#cw-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
}

#cw-subtitle {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
}

#cw-close {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
#cw-close:hover { background: rgba(239,68,68,0.2); color: #EF4444; }
#cw-close svg { width: 14px; height: 14px; }

/* ─── MESSAGES ───────────────────────────────── */
#cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#cw-messages::-webkit-scrollbar { width: 4px; }
#cw-messages::-webkit-scrollbar-track { background: transparent; }
#cw-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.cw-msg {
  display: flex;
  max-width: 88%;
  animation: cwFadeIn 0.25s ease;
}

@keyframes cwFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cw-msg--bot  { align-self: flex-start; }
.cw-msg--user { align-self: flex-end; }

.cw-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.82rem;
  line-height: 1.55;
  word-break: break-word;
}

.cw-msg--bot  .cw-bubble {
  background: rgba(255,255,255,0.07);
  color: rgba(248,247,255,0.9);
  border-radius: 4px 14px 14px 14px;
  border: 1px solid rgba(255,255,255,0.06);
}

.cw-msg--user .cw-bubble {
  background: linear-gradient(135deg, #7C3AED 0%, #06B6D4 100%);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

.cw-bubble a {
  color: #06B6D4;
  text-decoration: underline;
  word-break: break-all;
}

.cw-msg--user .cw-bubble a { color: rgba(255,255,255,0.85); }

/* Typing indicator */
.cw-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.cw-dot-anim {
  width: 7px;
  height: 7px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  animation: cwBounce 1.2s ease-in-out infinite;
}
.cw-dot-anim:nth-child(2) { animation-delay: 0.2s; }
.cw-dot-anim:nth-child(3) { animation-delay: 0.4s; }

@keyframes cwBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* ─── QUICK CHIPS ─────────────────────────────── */
#cw-chips {
  padding: 6px 12px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.cw-chip {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(248,247,255,0.75);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: left;
  font-family: 'Inter', sans-serif;
}
.cw-chip:hover {
  background: rgba(124,58,237,0.25);
  color: #fff;
  border-color: rgba(124,58,237,0.5);
}

/* ─── INPUT AREA ──────────────────────────────── */
#cw-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}

#cw-input {
  flex: 1;
  padding: 9px 14px;
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  color: #F8F7FF;
  font-size: 0.82rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#cw-input:focus {
  outline: none;
  border-color: #7C3AED;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
#cw-input::placeholder { color: rgba(248,247,255,0.3); }

#cw-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7C3AED 0%, #06B6D4 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
#cw-send:hover { opacity: 0.85; transform: scale(1.05); }
#cw-send svg { width: 15px; height: 15px; color: #fff; }

/* ─── MOBILE ──────────────────────────────────── */
@media (max-width: 480px) {
  #cw-panel {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 90px;
  }
  #cw-bubble {
    right: 16px;
    bottom: 20px;
  }
}
