.cmw-widget {
  --cmw-primary: #C18F60;
  --cmw-header-bg: #1D1D1D;
  --cmw-header-text: #C18F60;
  --cmw-widget-bg: #1D1D1D;
  --cmw-card-bg: #1D1D1D;
  --cmw-user-bubble-bg: #C18F60;
  --cmw-user-bubble-text: #FFFFFF;
  --cmw-operator-bubble-bg: #2b2b2b;
  --cmw-operator-bubble-text: #C18F60;
  --cmw-assistant-bubble-bg: #2b2b2b;
  --cmw-assistant-bubble-text: #C18F60;
  --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(193, 143, 96, 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(193, 143, 96, 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(193, 143, 96, 0.08);
  border: 1px dashed rgba(193, 143, 96, 0.28);
  color: #C18F60;
}

.cmw-widget__meta {
  font-size: 11px;
  color: #a2a2a2;
  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: #f8fafc;
  padding: 8px 10px;
  border-top: 1px solid #e2e8f0;
  flex: 0 0 auto;
}

.cmw-widget__quick-btn {
  border: 1px solid #7dd3fc;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.cmw-widget__quick-btn:hover {
  background: #bae6fd;
  border-color: #0ea5e9;
  color: #0c4a6e;
}

.cmw-widget__quick-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.cmw-widget__input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  padding: 10px;
  border-top: 1px solid #e2e8f0;
  flex: 0 0 auto;
}

.cmw-widget__media-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #0ea5e9;
  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: #0ea5e9;
  color: #0284c7;
}

.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 #cbd5e1;
  border-radius: 12px;
  padding: 9px 11px;
  resize: none;
  font-size: 14px;
  line-height: 1.35;
  outline: none;
  overflow-y: auto;
  background: #ffffff;
  color: #0f172a;
}

.cmw-widget__input textarea:focus {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.cmw-widget__send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: #0ea5e9;
  color: #ffffff;
  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(1.05);
  background: #0284c7;
}

.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%;
}

/* ── Скрыть кнопку и input отправки фото ────────────────────────────── */
[data-cmw-photo-btn],
[data-cmw-photo-input] {
  display: none !important;
}

/* Микрофон — светлая подложка ввода, голубой акцент */
.cmw-widget__media-btn {
  color: #0ea5e9 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

.cmw-widget__media-btn:hover {
  background: #e0f2fe !important;
  color: #0284c7 !important;
  border-color: #0ea5e9 !important;
}

.cmw-widget__media-btn.is-recording {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #fca5a5 !important;
  animation: cmw-pulse-recording 1.2s ease-in-out infinite;
}

@keyframes cmw-pulse-recording {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}


/* Иконка микрофона — в тон акценту */
[data-cmw-voice-btn] {
  color: #0ea5e9 !important;
}
[data-cmw-voice-btn]:hover {
  color: #0284c7 !important;
}

@media (max-width: 640px) {
  .cmw-widget {
    max-width: 100%;
  }

  .cmw-widget__card {
    height: min(84vh, 640px);
  }
}
