/* ============================================
   AIDDI · Chatbot Widget Styles
   ============================================ */

/* Кнопка открытия чата */
.chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(244, 63, 94, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(244, 63, 94, 0.5);
}

.chat-launcher svg {
  width: 28px;
  height: 28px;
}

/* Бейдж с уведомлением */
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--indigo);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Панель чата */
.chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.15);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  border: 1px solid var(--border);
}

.chat-panel.open {
  display: flex;
  animation: chatSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Шапка чата */
.chat-head {
  padding: 1rem 1.2rem;
  background: var(--dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-shrink: 0;
}

.chat-head-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--coral);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-head-avatar svg {
  width: 24px;
  height: 24px;
}

.chat-head-info b {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: var(--font-heading);
}

.chat-head-info span {
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
}

.chat-head-info span::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 6px;
}

.chat-close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Тело чата (сообщения) */
.chat-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.2rem;
  background: var(--bg-alt);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  scroll-behavior: smooth;
}

/* Скроллбар для чата */
.chat-body::-webkit-scrollbar {
  width: 6px;
}
.chat-body::-webkit-scrollbar-track {
  background: transparent;
}
.chat-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.chat-msg {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-line; /* Сохраняет переносы строк из JS */
}

.chat-msg.bot {
  background: #fff;
  color: var(--text);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-msg.user {
  background: var(--coral);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Кнопки-опции в чате */
.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.2rem;
  align-self: flex-start;
}

.chat-option {
  background: #fff;
  border: 1px solid var(--border);
  padding: 0.45rem 0.9rem;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-option:hover {
  border-color: var(--coral);
  color: var(--coral);
  background: #fef2f2;
  transform: translateY(-1px);
}

/* Область ввода */
.chat-input {
  padding: 0.8rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  background: #fff;
  flex-shrink: 0;
}

.chat-input input {
  flex-grow: 1;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input input:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.1);
}

.chat-input input::placeholder {
  color: var(--text-light);
}

.chat-input button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.chat-input button:hover {
  background: var(--coral-dark);
}

.chat-input button:active {
  transform: scale(0.95);
}

.chat-input button:disabled {
  background: var(--border);
  color: var(--text-light);
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   АДАПТИВНОСТЬ ЧАТ-БОТА
   ============================================ */

@media (max-width: 480px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  
  .chat-launcher {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }
}