/* chat.css */
/* Стилі для вбудованого чату на сторінці */
.chat-window {
  width: 100%;
  max-width: 1500px;
  height: 50%;
  max-height: 700px;
  background-color: #000;
  box-shadow: 0 5px 20px rgba(213, 121, 248, 0.4);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 auto;
  border: 1px solid #D579F8;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Секція чату з відступом від хедера */
.s-prompt-engineering {
  padding: 20% 0 60px 0; /* Збільшуємо верхній відступ, щоб уникнути накладання з хедером */
  background-color: #0a0a0a;
  position: relative;
  margin-top: 20px; /* Додатковий відступ зверху */
}

.s-prompt-engineering:before {
  content: '';
  position: absolute;
  top: -50px;
  left: 0;
  right: 0;
  height: 50px;
  background: linear-gradient(to bottom, rgba(0,0,0,0), #0a0a0a);
  pointer-events: none;
}

.s-prompt-engineering .s-content_h2 {
  text-align: center;
  color: #D579F8;
  margin-bottom: 30px;
  font-size: 36px;
  font-weight: bold;
  text-transform: uppercase;
}

/* Заголовок чату */
.chat-header {
  background-color: #000;
  color: #D579F8;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  border-bottom: 1px solid #333;
}

.chat-header h2 {
  margin: 0;
  font-size: 24px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Приховуємо кнопку закриття */
.chat-close {
  display: none;
}

/* Перемикач мови */
.language-switcher {
  display: flex;
  align-items: center;
  margin-right: 10px;
}

.lang-btn {
  background: transparent;
  color: #999;
  border: none;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  border-radius: 4px;
}

.lang-btn:hover {
  color: #D579F8;
}

.lang-btn.active {
  color: #D579F8;
  font-weight: bold;
}

.lang-divider {
  color: #555;
  margin: 0 5px;
}

/* Тіло чату */
.chat-body {
  height: 350px;
  padding: 15px;
  overflow-y: auto;
  background-color: #111;
  color: #fff;
  flex: 1;
}

/* Стилі для контейнера повідомлення */
.message-container {
  position: relative;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}

.message-container.user {
  align-items: flex-end;
}

.message-container.bot {
  align-items: flex-start;
}

/* Стилі повідомлень */
.message {
  padding: 10px 15px;
  border-radius: 18px;
  max-width: 80%;
  word-wrap: break-word;
  white-space: pre-wrap; /* Зберігаємо переноси рядків */
  user-select: text; /* Дозволяємо виділення тексту */
  position: relative; /* Для позиціонування кнопки копіювання */
  transition: all 0.2s ease;
}

.message-user {
  background-color: #D579F8;
  color: #000;
  border-bottom-right-radius: 4px;
}

.message-bot {
  background-color: #333;
  color: #fff;
  border-bottom-left-radius: 4px;
}

/* Кнопка копіювання повідомлення */
.copy-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.8);
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.message-container:hover .copy-button {
  opacity: 1;
}

.message-container.user .copy-button {
  color: rgba(0, 0, 0, 0.7);
  background-color: rgba(255, 255, 255, 0.3);
}

.copy-button:hover {
  background-color: rgba(213, 121, 248, 0.5);
  color: #fff;
}

.copy-button .copy-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
}

.copy-button .copy-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Анімація підтвердження копіювання */
@keyframes copySuccess {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.copy-success {
  animation: copySuccess 0.3s ease;
  background-color: rgba(40, 167, 69, 0.5) !important;
}

/* Індикатор завантаження */
.message-loading {
  background-color: #333;
  min-width: 70px;
  padding: 12px 15px;
}

.loading-dots {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 3px;
  background-color: #D579F8;
  border-radius: 50%;
  animation: dotFade 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes dotFade {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Нижня частина (форма вводу) */
.chat-footer {
  display: flex;
  flex-direction: column;
  border-top: 1px solid #333;
  background-color: #000;
  position: relative;
  padding-bottom: 30px; /* Додаємо простір для кнопки внизу */
}

/* Стилі для textarea */
.chat-textarea {
  width: 100%;
  padding: 15px;
  border: none;
  outline: none;
  background-color: #000;
  color: #fff;
  resize: none; /* Прибираємо можливість змінювати розмір вручну */
  min-height: 50px; /* Мінімальна висота */
  max-height: 300px; /* Максимальна висота для 10 рядків */
  line-height: 1.5;
  font-family: inherit;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Стилізація скроллбара для textarea */
.chat-textarea::-webkit-scrollbar {
  width: 6px;
}

.chat-textarea::-webkit-scrollbar-track {
  background: #111;
}

.chat-textarea::-webkit-scrollbar-thumb {
  background-color: #D579F8;
  border-radius: 6px;
}

/* Нова стилізація для кнопки відправки */
.chat-send-button {
  position: absolute;
  bottom: 10px;
  right: 15px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #D579F8;
  color: #000;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
}

.chat-send-button:hover {
  background-color: #C268E7;
}

.chat-send-button.disabled {
  background-color: #444;
  cursor: not-allowed;
}

/* Стиль для іконки стрілки */
.send-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  position: relative;
}

.send-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Стилізація плейсхолдера */
.chat-textarea::placeholder {
  color: #666;
}

/* Стилізація скроллбара для чату */
.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-track {
  background: #111;
}

.chat-body::-webkit-scrollbar-thumb {
  background-color: #D579F8;
  border-radius: 6px;
}

/* Підказка про Shift+Enter */
.chat-footer:after {
  content: 'Натисніть Enter для відправки або Shift+Enter для нового рядка';
  position: absolute;
  bottom: 5px;
  left: 15px;
  font-size: 12px;
  color: #666;
  pointer-events: none;
}

/* Фіксація навігаційного меню, щоб чат не накладався */
.menu-top {
  z-index: 1000; /* Переконуємося, що меню завжди над іншими елементами */
}

/* Адаптивність для різних розмірів екрану */
@media (max-width: 768px) {
  .chat-window {
    margin: 20px auto;
    max-width: 95%;
  }

  .chat-body {
    height: 300px;
  }

  .chat-header h2 {
    font-size: 18px;
  }

  .lang-btn {
    font-size: 12px;
    padding: 4px 6px;
  }

  .chat-footer:after {
    font-size: 10px;
    bottom: 15px;
  }

  .s-prompt-engineering {
    padding: 90px 0 40px 0; /* Менший відступ для мобільних пристроїв */
  }
}