/* public/css/chat.css — виджет ИИ-ассистента в правой колонке */

.chat-widget {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: calc(100vh - 120px);
  max-height: 720px;
  min-height: 480px;
  box-shadow: var(--shadow);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(79,140,255,.12), rgba(139,92,246,.12));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-avatar {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,140,255,.35);
}
.chat-avatar svg { width: 20px; height: 20px; }
.chat-header-text { min-width: 0; }
.chat-title { font-size: 14px; font-weight: 750; color: var(--text); line-height: 1.2; }
.chat-subtitle {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2);
  display: inline-block;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.chat-msg { display: flex; max-width: 100%; }
.chat-msg.bot { justify-content: flex-start; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.error .chat-bubble { border-color: #ef4444; color: #fecaca; }

.chat-bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-msg.bot .chat-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: #d6dae2;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

/* ---------- Содержимое ответа бота ---------- */
.chat-bubble a { color: var(--accent); text-decoration: underline; }
.chat-bubble strong { color: var(--text); font-weight: 700; }
.chat-bubble code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}
.chat-bubble ul {
  margin: 6px 0 6px 18px;
  padding: 0;
}
.chat-bubble ul li {
  margin-bottom: 4px;
  line-height: 1.45;
}
.chat-bubble ul li:last-child { margin-bottom: 0; }

/* индикатор печати */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  flex-shrink: 0;
}
.chat-suggestions .chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.chat-suggestions .chip:hover { border-color: var(--accent); color: var(--accent); }

.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-input textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
}
.chat-input textarea:focus { border-color: var(--accent); }
.chat-input button {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.chat-input button:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,140,255,.4); }
.chat-input button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.chat-input button svg { width: 17px; height: 17px; }

.chat-disclaimer {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 0 14px 10px;
  line-height: 1.4;
  flex-shrink: 0;
}

@media (max-width: 1100px) {
  .chat-widget { height: 560px; min-height: 0; }
}