/* ==========================================================================
   IMOU Chat Widget — стили (светлая тема)
   Чистая светлая панель с ярким янтарно-оранжевым акцентом
   oklch(0.746 0.173 57.3) — используется как основной CTA-цвет
   (кнопка отправки, лаунчер, ссылки), плюс два производных тона:
   accent-strong (темнее, для текста/иконок с достаточным контрастом
   на светлом фоне) и accent-dim (ещё темнее, фон пузыря сообщений
   пользователя с белым текстом).
   ========================================================================== */

:root {
  --imou-bg: #ffffff;
  --imou-surface: #f7f7f8;
  --imou-surface-2: #eef0f2;
  --imou-border: #e3e5e9;
  --imou-text: #1a1d21;
  --imou-text-muted: #6b7280;
  --imou-accent: oklch(0.746 0.173 57.3);
  --imou-accent-strong: oklch(0.62 0.173 57.3);
  --imou-accent-dim: oklch(0.5 0.173 57.3);
  --imou-rec: #ef4444;
  --imou-radius: 16px;
  --imou-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --imou-font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
}

.imou-chat-root {
  font-family: var(--imou-font);
  --z: 999999;
}

/* ---------- Кнопка-лаунчер ---------- */
.imou-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--imou-surface);
  border: 1px solid var(--imou-border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: var(--z);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.imou-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px oklch(0.746 0.173 57.3 / 0.35);
}

.imou-launcher svg {
  width: 26px;
  height: 26px;
  stroke: var(--imou-accent-strong);
}

.imou-launcher .imou-launcher-ring {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--imou-accent);
  opacity: 0.4;
  animation: imou-ring-pulse 2.4s ease-out infinite;
}

@keyframes imou-ring-pulse {
  0%   { transform: scale(0.9); opacity: 0.5; }
  100% { transform: scale(1.35); opacity: 0; }
}

.imou-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--imou-rec);
  border: 2px solid var(--imou-bg);
}

/* ---------- Панель чата ---------- */
.imou-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--imou-bg);
  border: 1px solid var(--imou-border);
  border-radius: var(--imou-radius);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.imou-panel.imou-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Шапка ---------- */
.imou-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--imou-surface);
  border-bottom: 1px solid var(--imou-border);
  flex-shrink: 0;
}

.imou-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--imou-surface-2);
  border: 1px solid var(--imou-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.imou-header-avatar svg {
  width: 18px;
  height: 18px;
  stroke: var(--imou-accent-strong);
}

.imou-header-info {
  flex: 1;
  min-width: 0;
}

.imou-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--imou-text);
  line-height: 1.3;
}

.imou-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--imou-text-muted);
  margin-top: 1px;
}

.imou-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--imou-rec);
  animation: imou-blink 1.6s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes imou-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

.imou-close-btn,
.imou-clear-btn,
.imou-lead-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--imou-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.imou-close-btn:hover {
  background: var(--imou-surface-2);
  color: var(--imou-text);
}

.imou-clear-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--imou-rec);
}

.imou-lead-btn:hover {
  background: oklch(0.746 0.173 57.3 / 0.14);
  color: var(--imou-accent-strong);
}

.imou-close-btn svg,
.imou-clear-btn svg,
.imou-lead-btn svg {
  width: 15px;
  height: 15px;
}

/* ---------- Лента сообщений ---------- */
.imou-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(circle at 100% 0%, oklch(0.746 0.173 57.3 / 0.07), transparent 40%),
    var(--imou-bg);
}

.imou-messages::-webkit-scrollbar { width: 6px; }
.imou-messages::-webkit-scrollbar-thumb {
  background: var(--imou-border);
  border-radius: 3px;
}

.imou-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}

.imou-msg strong { color: inherit; font-weight: 600; }

.imou-msg a {
  color: var(--imou-accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.imou-msg-user {
  align-self: flex-end;
  background: var(--imou-accent-dim);
  color: #fff8f2;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

/* Плашки цены/наличия внутри ответа бота (моно-шрифт как OSD) */
.imou-msg code {
  font-family: var(--imou-font-mono);
  background: oklch(0.746 0.173 57.3 / 0.14);
  color: var(--imou-accent-strong);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

/* ---------- Форма сбора контактов лида ---------- */
.imou-lead-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 92%;
  width: 92%;
}

.imou-lead-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--imou-text);
  margin-bottom: 2px;
}

.imou-lead-error {
  font-size: 12px;
  color: var(--imou-rec);
}

.imou-lead-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--imou-border);
  background: var(--imou-bg);
  color: var(--imou-text);
  font-family: var(--imou-font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.imou-lead-input:focus {
  border-color: var(--imou-accent-strong);
  box-shadow: 0 0 0 3px oklch(0.746 0.173 57.3 / 0.18);
}

.imou-lead-input::placeholder {
  color: var(--imou-text-muted);
}

.imou-lead-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.imou-lead-dismiss,
.imou-lead-submit {
  font-size: 12.5px;
  padding: 7px 13px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.imou-lead-dismiss {
  background: transparent;
  color: var(--imou-text-muted);
}

.imou-lead-dismiss:hover {
  color: var(--imou-text);
}

.imou-lead-submit {
  background: var(--imou-accent);
  color: var(--imou-text);
  font-weight: 500;
}

.imou-lead-submit:hover { opacity: 0.88; }

.imou-lead-dismiss:disabled,
.imou-lead-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Индикатор "печатает" ---------- */
.imou-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--imou-surface);
  border: 1px solid var(--imou-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.imou-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--imou-text-muted);
  animation: imou-bounce 1.1s ease-in-out infinite;
}

.imou-typing span:nth-child(2) { animation-delay: 0.15s; }
.imou-typing span:nth-child(3) { animation-delay: 0.3s; }

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

/* ---------- Быстрые кнопки-подсказки ---------- */
.imou-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

/* display:flex выше перебивает атрибут hidden — без этого подсказки
   и сообщение об ошибке в форме не скрывались. */
.imou-chat-root [hidden] {
  display: none !important;
}

.imou-suggestion-chip {
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--imou-border);
  background: var(--imou-surface);
  color: var(--imou-text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.imou-suggestion-chip:hover {
  border-color: var(--imou-accent-strong);
  color: var(--imou-accent-strong);
}

/* ---------- Поле ввода ---------- */
.imou-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--imou-border);
  background: var(--imou-surface);
  flex-shrink: 0;
}

.imou-input {
  flex: 1;
  resize: none;
  max-height: 100px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--imou-border);
  background: var(--imou-bg);
  color: var(--imou-text);
  font-family: var(--imou-font);
  font-size: 13.5px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.imou-input:focus {
  border-color: var(--imou-accent-strong);
  box-shadow: 0 0 0 3px oklch(0.746 0.173 57.3 / 0.18);
}

.imou-input::placeholder {
  color: var(--imou-text-muted);
}

.imou-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--imou-accent);
  color: var(--imou-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.imou-send-btn:hover { opacity: 0.88; }
.imou-send-btn:active { transform: scale(0.94); }

.imou-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.imou-send-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 480px) {
  .imou-panel {
    right: 12px;
    left: 12px;
    bottom: 88px;
    width: auto;
    height: calc(100vh - 120px);
  }
  .imou-launcher {
    right: 16px;
    bottom: 16px;
  }
}

/* ---------- Уважаем reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .imou-launcher-ring,
  .imou-live-dot,
  .imou-typing span {
    animation: none !important;
  }
  .imou-panel {
    transition: none !important;
  }
}
