/* chat-style.css */

/* Импорт шрифта */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap');

/* Иконка чата (глобальная) */
#chat-icon {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 70px;
  height: 70px;
  background-color: #9f7bf4;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 30px;
  cursor: pointer;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 2147483647; /* поверх всего */
  pointer-events: auto;
}

/* Полупрозрачный фон (глобальный) */
#chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 2147483646;
}

/* Виджет чата */
#chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  height: 600px;
  background-color: #fafafa;
  border-radius: 16px;
  box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.3);
  display: none; /* скрыт по умолчанию */
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 2147483647;
  /* Типографика по умолчанию внутри виджета */
  font-family: "Manrope", serif;
}

/* наследуем шрифт для всех основных тегов внутри виджета */
#chat-widget p,
#chat-widget h1,
#chat-widget h2,
#chat-widget h3,
#chat-widget h4,
#chat-widget button,
#chat-widget strong,
#chat-widget .f-btn,
#chat-widget .f-input,
#chat-widget .form-control,
#chat-widget .html-content,
#chat-widget a,
#chat-widget span {
  font-family: "Manrope", serif;
}

/* Заголовок чата */
#chat-widget #chat-header {
  background-color: #9f7bf4;
  color: white;
  padding: 15px;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  font-size: 16px;
  display: flex;
  justify-content: flex-start; /* Исправлено с left на flex-start */
  align-items: center;
  text-align: left; /* Выравнивание текста */
  font-weight: bold;
}

/* Дополнительно для текста заголовка */
#chat-widget #chat-header strong {
  display: block;
  width: 100%;
  text-align: left;
  margin-left: 8px; /* Если есть иконка */
}

/* Если в шапке есть кнопки (например, закрытие) */
#chat-widget #chat-header button {
  margin-left: auto; /* Выталкивает кнопку вправо */
  background-color: transparent;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
}

/* Картинка ассистента */
#chat-widget #chat-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
  object-fit: cover;
}

/* Сообщения в чате */
#chat-widget #chat-messages {
  flex-grow: 1;
  padding: 10px;
  overflow-y: auto;
  font-size: 14px;
  background-color: #fff;
}

/* Поле ввода */
#chat-widget #chat-input {
  position: relative;
  padding: 5px 10px;
  background-color: #fff;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
}

#chat-widget #chat-input input {
  flex-grow: 1;
  height: 35px;
  border: none;
  border-radius: 5px;
  padding: 5px 40px 5px 10px;
  font-size: 16px;
  outline: none;
  background-color: #F4F3F4;
}

/* Кнопка отправки */
#chat-widget #send-button {
  position: absolute;
  right: 15px;
  width: 40px;
  height: 40px;
  background-color: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease;
}

#chat-widget #send-button:hover {
  transform: scale(1.1);
}

#chat-widget #send-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}



/* Группа кнопок CTA */
#chat-widget #quick-questions {
  border-top: 1px #F4F3F4 solid;
  padding-top: 5px !important;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 16px;
  background: #fff;
}

#chat-widget #quick-questions button {
  order: 1;
  padding: 14px;
  margin: 0;
  background: #4CEF8A;
  border: none;
  color: #000;
  border-radius: 5px;
}

#chat-widget #quick-questions button:nth-child(3) {
  order: 2;
  grid-column: span 2;
  background: #9F7BF4;
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 5px;
}

/* Стили для сообщений ассента */
#chat-widget .message {
  background-color: #E2D7FC;
  padding: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
  border-radius: 5px;
  font-weight: normal !important;
}

/* Стилизация Markdown */
#chat-widget .markdown-content h1 {
  font-size: 20px;
  font-weight: bold;
  margin: 5px 0;
}
#chat-widget .markdown-content h2 {
  font-size: 18px;
  font-weight: bold;
  margin: 5px 0;
}
#chat-widget .markdown-content h3 {
  font-size: 16px;
  font-weight: bold;
  margin: 5px 0;
}
#chat-widget .markdown-content p {
  margin: 5px 0;
}
#chat-widget .markdown-content strong {
  font-weight: bold;
}
#chat-widget .markdown-content em {
  font-style: italic;
}
#chat-widget .markdown-content ul {
  padding-left: 20px;
}
#chat-widget .markdown-content li {
  margin-bottom: 5px;
}
#chat-widget .markdown-content blockquote {
  border-left: 4px solid #9f7bf4;
  padding-left: 10px;
  color: #666;
  margin: 5px 0;
}
#chat-widget .markdown-content pre {
  background: #f4f4f4;
  padding: 10px;
  border-radius: 5px;
  overflow-x: auto;
}

/* Стили для состояния отключенного ввода */
#chat-widget.disabled #chat-input input {
  background-color: #fdd;
  cursor: not-allowed;
}

#chat-widget.disabled #send-button {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Адаптив для планшетов (до 768px) */
@media (max-width: 768px) {
  #chat-widget {
    width: 85%;
    height: 50vh;
    bottom: 10px;
    right: 10px;
  }
  #chat-widget #chat-header {
    padding: 10px;
    font-size: 14px;
  }
  #chat-widget #chat-input input {
    font-size: 14px;
    padding: 8px;
  }
  #chat-widget #send-button {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }
  #chat-widget #quick-questions button {
    padding: 8px 10px;
    font-size: 12px;
  }
}

/* Адаптив для мобильных устройств (до 480px) */
@media (max-width: 480px) {
  #chat-widget {
    width: 90%;
    height: 85vh;
    bottom: 10px;
    right: 10px;
    border-radius: 8px;
  }
  #chat-widget #chat-header {
    padding: 8px;
    font-size: 14px;
  }
  #chat-widget #chat-input {
    padding: 5px;
  }
  #chat-widget #chat-input input {
    height: 32px;
    font-size: 14px;
    padding: 5px 35px 5px 8px;
  }
  #chat-widget #send-button {
    width: 30px;
    height: 30px;
    right: 10px;
  }
  #chat-widget #quick-questions {
    padding: 8px;
    gap: 8px;
  }
  #chat-widget #quick-questions button {
    padding: 8px 12px;
    font-size: 12px;
  }
  #chat-widget #chat-messages {
    padding: 8px;
    font-size: 13px;
  }
  #chat-icon {
    width: 50px;
    height: 50px;
    font-size: 24px;
    bottom: 15px;
    right: 15px;
  }
}

/* Адаптив для мобильных устройств в ландшафтном режиме (до 480px) */
@media (max-width: 480px) and (orientation: landscape) {
  #chat-widget {
    width: 95%;
    height: 95%;
    bottom: 5px;
    right: 5px;
    border-radius: 8px;
  }
  #chat-widget #chat-header {
    padding: 8px;
    font-size: 13px;
  }
  #chat-widget #chat-messages {
    flex-grow: 1;
    max-height: none;
    padding: 8px;
    font-size: 13px;
  }
  #chat-widget #quick-questions {
    padding: 6px 8px;
    gap: 6px;
    display: flex;
    justify-content: space-between;
  }
  #chat-widget #quick-questions button {
    padding: 6px 10px;
    font-size: 11px;
    flex: 1;
    min-width: 0;
  }
  #chat-widget #chat-input {
    padding: 4px 8px;
  }
  #chat-widget #chat-input input {
    height: 30px;
    padding: 5px 30px 5px 8px;
    font-size: 13px;
  }
  #chat-widget #send-button {
    width: 28px;
    height: 28px;
    right: 8px;
  }
}

/* Адаптив для планшетов в ландшафтном режиме (до 1024px) */
@media (max-width: 1024px) and (orientation: landscape) {
  #chat-widget {
    width: 95%; /* Растягиваем почти на весь экран */
    height: 90%; /* Чуть меньше 95%, чтобы оставить место сверху */
    bottom: 5px;
    right: 5px;
    border-radius: 8px;
  }
  #chat-widget #chat-header {
    padding: 10px;
    font-size: 14px;
  }
  #chat-widget #chat-messages {
    flex-grow: 1; /* Занимает всё доступное пространство */
    max-height: none; /* Убираем ограничение */
    padding: 10px;
    font-size: 14px;
  }
  #chat-widget #quick-questions {
    padding: 8px 10px;
    gap: 8px;
    display: flex;
    justify-content: space-between;
  }
  #chat-widget #quick-questions button {
    padding: 8px 12px; /* Чуть больше, чем на смартфонах, для удобства */
    font-size: 12px;
    flex: 1;
    min-width: 0;
  }
  #chat-widget #chat-input {
    padding: 5px 10px;
    border-radius: 0 0 16px 16px;
  }
  #chat-widget #chat-input input {
    height: 32px;
    padding: 5px 35px 5px 10px;
    font-size: 14px;
  }
  #chat-widget #send-button {
    width: 30px;
    height: 30px;
    right: 10px;
  }
}
