/* llm-chat-widget — theme via CSS custom properties.
   Override any of these from the host page to match its brand:
   :root { --cw-primary: #1f5c5c; --cw-primary-dark: #0f3a3d; ... }
*/
:root {
  --cw-primary: #1f5c5c;
  --cw-primary-dark: #0f3a3d;
  --cw-bg: #ffffff;
  --cw-bg-soft: #f5f0e6;
  --cw-text: #2e2a22;
  --cw-muted: #746a5c;
  --cw-border: rgba(0, 0, 0, 0.12);
  --cw-radius: 14px;
  --cw-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --cw-z: 999999;
}

.cw-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--cw-z);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--cw-primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  transition: transform 0.15s ease;
  font-family: var(--cw-font);
}

.cw-launcher:hover {
  transform: translateY(-2px);
}

.cw-launcher img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cw-launcher svg {
  width: 26px;
  height: 26px;
}

.cw-launcher--left {
  right: auto;
  left: 20px;
}

.cw-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: var(--cw-z);
  width: 350px;
  max-width: calc(100vw - 40px);
  height: 480px;
  max-height: calc(100vh - 140px);
  background: var(--cw-bg);
  border-radius: var(--cw-radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--cw-font);
  color: var(--cw-text);
}

.cw-panel--left {
  right: auto;
  left: 20px;
}

.cw-panel.cw-open {
  display: flex;
}

.cw-header {
  background: var(--cw-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cw-header img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.2);
}

.cw-header-text {
  flex: 1;
  min-width: 0;
}

.cw-header-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

.cw-header-subtitle {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.3;
}

.cw-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.85;
  padding: 4px;
  font-size: 18px;
  line-height: 1;
}

.cw-close:hover {
  opacity: 1;
}

.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cw-bg-soft);
}

.cw-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.cw-msg--bot {
  align-self: flex-start;
  background: var(--cw-bg);
  border: 1px solid var(--cw-border);
  border-bottom-left-radius: 4px;
}

.cw-msg--user {
  align-self: flex-end;
  background: var(--cw-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cw-msg--error {
  align-self: flex-start;
  background: #fff4f2;
  border: 1px solid #e8b4a8;
  color: #7a3b2e;
  border-bottom-left-radius: 4px;
}

.cw-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 11px 13px;
  background: var(--cw-bg);
  border: 1px solid var(--cw-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.cw-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cw-muted);
  opacity: 0.5;
  animation: cw-blink 1.2s infinite ease-in-out;
}

.cw-typing span:nth-child(2) { animation-delay: 0.2s; }
.cw-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cw-blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.cw-inputrow {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--cw-border);
  background: var(--cw-bg);
}

.cw-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--cw-border);
  border-radius: 10px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  max-height: 90px;
  color: var(--cw-text);
}

.cw-input:focus {
  outline: 2px solid var(--cw-primary);
  outline-offset: 1px;
}

.cw-send {
  background: var(--cw-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.cw-send:hover {
  background: var(--cw-primary-dark);
}

.cw-send:disabled {
  opacity: 0.5;
  cursor: default;
}

.cw-footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--cw-muted);
  padding: 6px 10px 10px;
  background: var(--cw-bg);
}

@media (max-width: 480px) {
  .cw-panel {
    right: 12px;
    left: 12px;
    bottom: 84px;
    width: auto;
  }
  .cw-panel--left {
    right: 12px;
    left: 12px;
  }
}
