/* chat-widget.css - live-chat виджет (Mattermost backend).
   Все классы с префиксом cw- чтобы не конфликтовать со стилями лендинга.
   Цвета берутся из CSS-переменных темы (.dir-a / .dir-b) с фолбэками. */

.cw-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  font-family: var(--sans, system-ui, sans-serif);
  transition: opacity 180ms ease;
}

/* Hide the chat widget while the mobile nav drawer is open so it doesn't
   overlap the menu / its CTA buttons. */
body.nav-drawer-open .cw-root {
  opacity: 0;
  pointer-events: none;
}

/* ===== Floating button ===== */
.cw-fab {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent, #ff5b2e);
  color: var(--accent-ink, #1a0a04);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.cw-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}
.cw-fab:active {
  transform: translateY(0);
}

.cw-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #e5484d;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  font-family: var(--mono, monospace);
}

/* ===== Panel ===== */
.cw-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  background: var(--card, #ffffff);
  color: var(--ink, #0d0c0a);
  border: 1px solid var(--line, #d9d3c3);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  animation: cw-pop 160ms ease;
}

@keyframes cw-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line, #d9d3c3);
  background: var(--bg-2, #e8e2d4);
}
.cw-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cw-title {
  font-weight: 700;
  font-size: 0.9375rem;
  font-family: var(--display, var(--sans));
}
.cw-substatus {
  font-size: 0.75rem;
  color: var(--ink-3, #8a877d);
  font-family: var(--mono, monospace);
}
.cw-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-3, #8a877d);
  flex: 0 0 auto;
}
.cw-dot-online { background: #30a46c; }
.cw-dot-connecting { background: #f5a623; animation: cw-blink 1.2s ease-in-out infinite; }
.cw-dot-offline,
.cw-dot-idle { background: var(--ink-3, #8a877d); }

@keyframes cw-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.cw-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--ink-2, #4a4842);
  transition: background 150ms;
}
.cw-close:hover { background: color-mix(in oklab, var(--ink, #000) 8%, transparent); }

/* ===== Messages ===== */
.cw-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg, #f3efe6);
}

.cw-hint {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink-3, #8a877d);
  text-align: center;
  padding: 16px 8px;
}

.cw-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}
.cw-msg-user { align-self: flex-end; align-items: flex-end; }
.cw-msg-operator { align-self: flex-start; align-items: flex-start; }

.cw-bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.cw-msg-user .cw-bubble {
  background: var(--accent, #ff5b2e);
  color: var(--accent-ink, #1a0a04);
  border-bottom-right-radius: 4px;
}
.cw-msg-operator .cw-bubble {
  background: var(--bg-3, #ffffff);
  color: var(--ink, #0d0c0a);
  border: 1px solid var(--line, #d9d3c3);
  border-bottom-left-radius: 4px;
}
.cw-time {
  font-size: 0.625rem;
  color: var(--ink-3, #8a877d);
  margin-top: 3px;
  font-family: var(--mono, monospace);
}

/* ===== Error banner ===== */
.cw-error {
  padding: 8px 16px;
  font-size: 0.75rem;
  color: #e5484d;
  background: color-mix(in oklab, #e5484d 10%, transparent);
  border-top: 1px solid var(--line, #d9d3c3);
}

/* ===== Input ===== */
.cw-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line, #d9d3c3);
  background: var(--card, #ffffff);
}
.cw-text {
  flex: 1;
  resize: none;
  border: 1px solid var(--line, #d9d3c3);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 0.875rem;
  line-height: 1.4;
  max-height: 120px;
  background: var(--bg, #f3efe6);
  color: var(--ink, #0d0c0a);
  outline: none;
  transition: border-color 150ms;
}
.cw-text:focus { border-color: var(--accent, #ff5b2e); }
.cw-text::placeholder { color: var(--ink-3, #8a877d); }

.cw-send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent, #ff5b2e);
  color: var(--accent-ink, #1a0a04);
  transition: opacity 150ms;
}
.cw-send:disabled { opacity: 0.4; cursor: not-allowed; }

.cw-spin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: cw-rotate 0.7s linear infinite;
}
@keyframes cw-rotate {
  to { transform: rotate(360deg); }
}

/* honeypot - убран из потока и от глаз/скринридеров */
.cw-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 480px) {
  .cw-root { right: 16px; bottom: 16px; }
  .cw-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
  }
}
