:root {
  --wc-primary: #0a84ff;
  --wc-bg: #ffffff;
  --wc-fg: #111827;
  --wc-muted: #6b7280;
  --wc-bubble-user: #0a84ff;
  --wc-bubble-assistant: #f3f4f6;
  --wc-border: #e5e7eb;
  --wc-shadow: 0 10px 40px rgba(0, 0, 0, 0.16);
}

.woaichat-launcher {
  position: fixed;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--wc-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--wc-shadow);
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.woaichat-launcher:hover { transform: scale(1.05); }
.woaichat-launcher svg { width: 26px; height: 26px; fill: #fff; }
.woaichat-pos-right { right: 20px; }
.woaichat-pos-left { left: 20px; }

.woaichat-panel {
  position: fixed;
  bottom: 90px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--wc-bg);
  color: var(--wc-fg);
  border-radius: 14px;
  box-shadow: var(--wc-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  transition: width 0.25s ease, height 0.25s ease;
}
.woaichat-panel.open { display: flex; }

/* Compact mode — used for auto-open so the panel isn't intrusive until the
 * visitor actually engages. Expands to full size when they send a message. */
.woaichat-panel.woaichat-compact {
  width: 320px;
  height: 300px;
}
@media (max-width: 600px) {
  .woaichat-panel.woaichat-compact {
    width: calc(100vw - 24px);
    height: 240px;
  }
}

.woaichat-header {
  background: var(--wc-primary);
  color: #fff;
  padding: 14px 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.woaichat-header-title { display: flex; align-items: center; gap: 8px; }
.woaichat-close {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.woaichat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fafafa;
}
.woaichat-msg {
  display: flex;
  margin-bottom: 10px;
  animation: wc-fade 0.18s ease;
}
.woaichat-msg.user { justify-content: flex-end; }
.woaichat-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.woaichat-msg.user .woaichat-bubble {
  background: var(--wc-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.woaichat-msg.assistant .woaichat-bubble {
  background: var(--wc-bubble-assistant);
  color: var(--wc-fg);
  border-bottom-left-radius: 4px;
}
.woaichat-bubble a { color: inherit; text-decoration: underline; }
.woaichat-bubble ul { margin: 6px 0 6px 18px; padding: 0; }

.woaichat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 6px 0;
}
.woaichat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wc-muted);
  animation: wc-bounce 1.2s infinite;
}
.woaichat-typing span:nth-child(2) { animation-delay: 0.15s; }
.woaichat-typing span:nth-child(3) { animation-delay: 0.3s; }

.woaichat-input {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--wc-border);
  background: #fff;
}
.woaichat-attach {
  background: transparent;
  border: none;
  color: var(--wc-muted);
  padding: 0 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease;
}
.woaichat-attach:hover { color: var(--wc-primary); }
.woaichat-attach:disabled { opacity: 0.5; cursor: not-allowed; }

.woaichat-image-preview {
  display: none;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-top: 1px solid var(--wc-border);
  flex-wrap: wrap;
}
.woaichat-image-preview.has-items { display: flex; }
.woaichat-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--wc-border);
  background: #f1f5f9;
}
.woaichat-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.woaichat-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.woaichat-bubble-images {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  margin-bottom: 6px;
}
.woaichat-bubble-img {
  width: 100%;
  border-radius: 6px;
  display: block;
  object-fit: cover;
  max-height: 200px;
}

.woaichat-panel.woaichat-drop-active {
  outline: 3px dashed var(--wc-primary);
  outline-offset: -6px;
}
.woaichat-input textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  max-height: 120px;
  background: transparent;
  color: var(--wc-fg);
}
.woaichat-send {
  background: var(--wc-primary);
  border: none;
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
}
.woaichat-send:disabled { opacity: 0.5; cursor: not-allowed; }

.woaichat-footer {
  padding: 6px 14px;
  font-size: 11px;
  color: var(--wc-muted);
  text-align: center;
  background: #fff;
  border-top: 1px solid var(--wc-border);
}

.woaichat-rtl .woaichat-bubble { text-align: right; }
.woaichat-rtl .woaichat-msg.user { justify-content: flex-start; }
.woaichat-rtl .woaichat-msg.user .woaichat-bubble { border-bottom-right-radius: 12px; border-bottom-left-radius: 4px; }
.woaichat-rtl .woaichat-msg.assistant { justify-content: flex-end; }
.woaichat-rtl .woaichat-msg.assistant .woaichat-bubble { border-bottom-left-radius: 12px; border-bottom-right-radius: 4px; }
.woaichat-rtl .woaichat-input textarea { text-align: right; }
.woaichat-rtl ul { margin: 6px 18px 6px 0; }

.woaichat-error {
  color: #b91c1c;
  background: #fef2f2;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 0 14px 8px;
}

@keyframes wc-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes wc-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}
