/* Creatin Chat Widget — cw- prefix */
.cw-root *, .cw-root *::before, .cw-root *::after { box-sizing: border-box; margin: 0; padding: 0; }

.cw-root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #e4e4e7;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  line-height: 1.4;
}

/* Toggle button */
.cw-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #6d28d9;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  transition: transform .2s, opacity .2s;
  position: absolute; bottom: 0; right: 0;
}
.cw-btn:hover { transform: scale(1.08); }
.cw-btn svg { width: 26px; height: 26px; fill: #fff; }
.cw-btn.cw-hidden { opacity: 0; pointer-events: none; transform: scale(.5); }

/* Panel */
.cw-panel {
  width: 360px; height: 480px;
  background: #1a1a2e;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: absolute; bottom: 68px; right: 0;
  transform: scale(.5); opacity: 0; pointer-events: none;
  transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .2s;
}
.cw-panel.cw-open { transform: scale(1); opacity: 1; pointer-events: auto; }

/* Header */
.cw-header {
  background: #6d28d9;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.cw-title { font-weight: 600; font-size: 15px; color: #fff; }
.cw-close {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 0 2px; opacity: .8;
}
.cw-close:hover { opacity: 1; }

/* Messages area */
.cw-messages {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}

/* Individual message */
.cw-msg { max-width: 82%; word-wrap: break-word; }
.cw-msg-visitor { align-self: flex-end; }
.cw-msg-ai { align-self: flex-start; }
.cw-msg-internal { align-self: flex-start; }

.cw-msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
}
.cw-msg-visitor .cw-msg-bubble {
  background: #6d28d9;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cw-msg-ai .cw-msg-bubble {
  background: #27273f;
  color: #e4e4e7;
  border-bottom-left-radius: 4px;
}
.cw-msg-internal .cw-msg-bubble {
  background: transparent;
  color: #888;
  font-size: 11.5px;
  padding: 4px 8px;
  font-style: italic;
}

.cw-msg-meta {
  font-size: 10px; color: #666; margin-top: 2px;
}
.cw-msg-visitor .cw-msg-meta { text-align: right; }

/* Typing indicator */
.cw-typing { display: flex; gap: 4px; padding: 9px 13px; align-items: center; }
.cw-typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #888;
  animation: cw-blink 1.4s infinite both;
}
.cw-typing-dot:nth-child(2) { animation-delay: .2s; }
.cw-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes cw-blink { 0%,80%,100%{opacity:.25} 40%{opacity:1} }

/* Name prompt */
.cw-name-prompt {
  padding: 12px 14px;
  background: #22223a;
  border-top: 1px solid #2d2d4a;
}
.cw-name-prompt label { display: block; font-size: 12px; color: #aaa; margin-bottom: 6px; }
.cw-name-row { display: flex; gap: 6px; }
.cw-name-input {
  flex: 1; padding: 8px 10px; border-radius: 8px;
  border: 1px solid #3d3d5c; background: #1a1a2e; color: #e4e4e7;
  font-size: 13px; outline: none;
}
.cw-name-input:focus { border-color: #6d28d9; }
.cw-name-btn {
  padding: 8px 14px; border-radius: 8px;
  background: #6d28d9; color: #fff; border: none; cursor: pointer; font-size: 13px;
}
.cw-name-btn:hover { background: #7c3aed; }

/* Input area */
.cw-input-area {
  display: flex; gap: 6px; padding: 10px 12px;
  background: #1a1a2e; border-top: 1px solid #2d2d4a; flex-shrink: 0;
}
.cw-input {
  flex: 1; padding: 9px 12px; border-radius: 10px;
  border: 1px solid #3d3d5c; background: #12121f; color: #e4e4e7;
  font-size: 13px; outline: none; resize: none;
}
.cw-input:focus { border-color: #6d28d9; }
.cw-send {
  width: 38px; height: 38px; border-radius: 10px;
  background: #6d28d9; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cw-send:hover { background: #7c3aed; }
.cw-send svg { width: 18px; height: 18px; fill: #fff; }
.cw-send:disabled { opacity: .4; cursor: default; }

/* Welcome */
.cw-welcome { color: #aaa; font-size: 13px; text-align: center; padding: 20px 14px; }

/* Mobile responsive */
@media (max-width: 480px) {
  .cw-panel { width: calc(100vw - 16px); height: calc(100vh - 90px); bottom: 60px; right: 8px; border-radius: 12px; }
  .cw-root { bottom: 12px; right: 12px; }
}
