/* ==========================================================================
   FORMA AI — Чат-виджет
   Минимализм, монохром, чистая типографика.
   Стили спроектированы так, чтобы не конфликтовать со стилями сайта-носителя:
   всё под префиксом .forma-chat-*
   ========================================================================== */

.forma-chat-bubble {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #0a0a0a;
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(10, 10, 10, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
}

.forma-chat-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(10, 10, 10, 0.28);
}

.forma-chat-bubble svg {
  width: 26px;
  height: 26px;
}

.forma-chat-bubble--pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(10, 10, 10, 0.18);
  animation: forma-chat-pulse 2.4s ease-out infinite;
}

@keyframes forma-chat-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  70%  { transform: scale(1.6); opacity: 0;   }
  100% { transform: scale(1.6); opacity: 0;   }
}

.forma-chat-bubble-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ffffff;
  color: #0a0a0a;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #0a0a0a;
}

/* ---------- Окно чата ---------- */
.forma-chat-window {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 130px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(10, 10, 10, 0.18), 0 2px 8px rgba(10, 10, 10, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  color: #0a0a0a;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.forma-chat-window--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Шапка ---------- */
.forma-chat-header {
  background: #0a0a0a;
  color: #ffffff;
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  flex-shrink: 0;
}

.forma-chat-header-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #ffffff;
  color: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

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

.forma-chat-header-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.forma-chat-header-subtitle {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.forma-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

.forma-chat-close {
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
}

.forma-chat-close:hover { opacity: 1; }

.forma-chat-close svg { width: 18px; height: 18px; }

/* ---------- Сообщения ---------- */
.forma-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 6px;
  background: #ffffff;
  scroll-behavior: smooth;
}

.forma-chat-messages::-webkit-scrollbar { width: 6px; }
.forma-chat-messages::-webkit-scrollbar-track { background: transparent; }
.forma-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(10, 10, 10, 0.12);
  border-radius: 3px;
}

.forma-chat-msg {
  display: flex;
  margin-bottom: 14px;
  animation: forma-chat-msg-in 0.32s ease;
}

@keyframes forma-chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.forma-chat-msg--bot { justify-content: flex-start; }
.forma-chat-msg--user { justify-content: flex-end; }

.forma-chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #0a0a0a;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 10px;
  margin-top: 2px;
}

.forma-chat-msg--user .forma-chat-avatar { display: none; }

.forma-chat-bubble-msg {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.forma-chat-msg--bot .forma-chat-bubble-msg {
  background: #f4f4f4;
  color: #0a0a0a;
  border-top-left-radius: 4px;
}

.forma-chat-msg--user .forma-chat-bubble-msg {
  background: #0a0a0a;
  color: #ffffff;
  border-top-right-radius: 4px;
}

/* ---------- Быстрые реплики ---------- */
.forma-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 18px 12px;
  background: #ffffff;
}

.forma-chat-quick-btn {
  background: #ffffff;
  border: 1px solid #0a0a0a;
  color: #0a0a0a;
  padding: 7px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

.forma-chat-quick-btn:hover {
  background: #0a0a0a;
  color: #ffffff;
}

/* ---------- Поле вводода ---------- */
.forma-chat-input-wrap {
  padding: 10px 14px 14px;
  background: #ffffff;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.forma-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f4f4;
  border-radius: 12px;
  padding: 4px 4px 4px 14px;
  transition: box-shadow 0.18s;
}

.forma-chat-input-row:focus-within {
  background: #ececec;
  box-shadow: 0 0 0 2px rgba(10, 10, 10, 0.08);
}

.forma-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 13.5px;
  color: #0a0a0a;
  padding: 9px 0;
  resize: none;
  max-height: 90px;
  line-height: 1.4;
}

.forma-chat-input::placeholder {
  color: #999;
}

.forma-chat-send {
  width: 34px;
  height: 34px;
  border: none;
  background: #0a0a0a;
  color: #ffffff;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.18s, transform 0.18s;
}

.forma-chat-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.forma-chat-send:not(:disabled):hover {
  transform: scale(1.05);
}

.forma-chat-send svg { width: 16px; height: 16px; }

/* ---------- Печатает индикатор ---------- */
.forma-chat-typing {
  display: flex;
  gap: 4px;
  padding: 11px 14px;
  background: #f4f4f4;
  border-radius: 14px;
  border-top-left-radius: 4px;
  width: fit-content;
  margin-left: 38px;
}

.forma-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0a0a0a;
  opacity: 0.4;
  animation: forma-chat-typing 1.4s infinite;
}

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

@keyframes forma-chat-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* ---------- Подпись ---------- */
.forma-chat-footer {
  padding: 8px 18px 10px;
  background: #ffffff;
  border-top: 1px solid #f0f0f0;
  font-size: 10.5px;
  color: #999;
  text-align: center;
  flex-shrink: 0;
}

.forma-chat-footer a {
  color: #0a0a0a;
  text-decoration: none;
  font-weight: 500;
}

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 480px) {
  .forma-chat-bubble {
    right: 16px;
    bottom: 16px;
    width: 54px;
    height: 54px;
  }

  .forma-chat-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .forma-chat-window--open {
    /* Полноэкранный режим на мобиле */
  }
}

/* ---------- Состояния для inline-форм ---------- */
.forma-chat-form-hint {
  font-size: 12px;
  color: #666;
  padding: 8px 14px 4px;
  background: #fafafa;
  border-left: 2px solid #0a0a0a;
  margin: 8px 0 12px 38px;
  border-radius: 0 8px 8px 0;
}
