.cmw-widget {
  --cmw-primary: #2f6feb;
  --cmw-header-bg: #0f172a;
  --cmw-header-text: #f8fafc;
  --cmw-widget-bg: #e9eef8;
  --cmw-card-bg: #ffffff;
  --cmw-user-bubble-bg: #2f6feb;
  --cmw-user-bubble-text: #ffffff;
  --cmw-operator-bubble-bg: #f3f4f6;
  --cmw-operator-bubble-text: #111827;
  --cmw-assistant-bubble-bg: #ede9fe;
  --cmw-assistant-bubble-text: #312e81;
  --cmw-radius: 18px;
  width: 100%;
  max-width: 440px;
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.cmw-widget-host,
.cmw-widget,
.cmw-widget__card {
  box-shadow: none !important;
}

.elementor-widget-cmw_chat_widget > .elementor-widget-container {
  box-shadow: none !important;
}

.cmw-widget__card {
  background: var(--cmw-widget-bg);
  border-radius: var(--cmw-radius);
  border: 1px solid rgba(15, 23, 42, 0.14);
  box-shadow: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: clamp(500px, 72vh, 680px);
}

.cmw-widget__header {
  background: var(--cmw-header-bg);
  color: var(--cmw-header-text);
  padding: 14px 16px;
  flex: 0 0 auto;
}

.cmw-widget__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.cmw-widget__visit {
  margin: 4px 0 0;
  opacity: 0.75;
  font-size: 12px;
}

.cmw-widget__panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.cmw-widget__messages {
  background: var(--cmw-card-bg);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cmw-widget__message {
  display: flex;
  flex-direction: column;
  max-width: 84%;
  gap: 4px;
}

.cmw-widget__message--visitor {
  align-self: flex-end;
}

.cmw-widget__message--operator {
  align-self: flex-start;
}

.cmw-widget__message--assistant {
  align-self: flex-start;
}

.cmw-widget__message--pending {
  opacity: 0.92;
}

.cmw-widget__message--typing {
  align-self: flex-start;
}

.cmw-widget__message--system {
  align-self: center;
  max-width: 92%;
}

.cmw-widget__bubble {
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.cmw-widget__message--visitor .cmw-widget__bubble {
  background: var(--cmw-user-bubble-bg);
  color: var(--cmw-user-bubble-text);
  border-bottom-right-radius: 4px;
}

.cmw-widget__message--operator .cmw-widget__bubble {
  background: var(--cmw-operator-bubble-bg);
  color: var(--cmw-operator-bubble-text);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-bottom-left-radius: 4px;
}

.cmw-widget__message--assistant .cmw-widget__bubble {
  background: var(--cmw-assistant-bubble-bg);
  color: var(--cmw-assistant-bubble-text);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-bottom-left-radius: 4px;
}

.cmw-widget__bubble--typing {
  opacity: 0.85;
  font-style: italic;
}

.cmw-widget__message--system .cmw-widget__bubble {
  background: rgba(37, 99, 235, 0.08);
  border: 1px dashed rgba(37, 99, 235, 0.28);
  color: #1e3a8a;
}

.cmw-widget__meta {
  font-size: 11px;
  color: #64748b;
  padding: 0 4px;
}

.cmw-widget__message--visitor .cmw-widget__meta {
  text-align: right;
}

.cmw-widget__quick {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  background: var(--cmw-card-bg);
  padding: 8px 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  flex: 0 0 auto;
}

.cmw-widget__quick-btn {
  border: 1px solid rgba(47, 111, 235, 0.35);
  background: rgba(47, 111, 235, 0.08);
  color: #1e3a8a;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.cmw-widget__quick-btn:hover {
  background: rgba(47, 111, 235, 0.15);
}

.cmw-widget__quick-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.cmw-widget__input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cmw-card-bg);
  padding: 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  flex: 0 0 auto;
}

.cmw-widget__media-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  font-size: 16px;
}

.cmw-widget__media-btn:hover {
  border-color: rgba(47, 111, 235, 0.55);
  color: #1e3a8a;
}

.cmw-widget__media-btn.is-recording {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.cmw-widget__input textarea {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 96px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  border-radius: 12px;
  padding: 9px 11px;
  resize: none;
  font-size: 14px;
  line-height: 1.35;
  outline: none;
  overflow-y: auto;
}

.cmw-widget__input textarea:focus {
  border-color: var(--cmw-primary);
  box-shadow: 0 0 0 2px rgba(47, 111, 235, 0.15);
}

.cmw-widget__send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--cmw-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 42px;
}

.cmw-widget.is-sending .cmw-widget__send,
.cmw-widget.is-sending .cmw-widget__media-btn {
  opacity: 0.6;
}

.cmw-widget__send:hover {
  filter: brightness(0.94);
}

.cmw-widget__send svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.cmw-widget__attach {
  margin-top: 8px;
}

.cmw-widget__attach--photo {
  display: inline-block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.14);
}

.cmw-widget__attach--photo img {
  display: block;
  max-width: 220px;
  width: 100%;
  height: auto;
}

.cmw-widget__attach--voice {
  width: 220px;
  max-width: 100%;
}

@media (max-width: 640px) {
  .cmw-widget {
    max-width: 100%;
  }

  .cmw-widget__card {
    height: min(84vh, 640px);
  }
}
