/* --- Стили для ИИ-виджета --- */
#ai-chat-widget {
  position: fixed; bottom: 20px; right: 20px; width: 350px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); border-radius: 12px;
  background: #fff; display: none; flex-direction: column; z-index: 9999;
  overflow: hidden; border: 1px solid #e0e0e0;
}
#ai-chat-header {
  background: #007bff; /* или ваш градиент */
  color: #fff; 
  padding: 15px;
  font-weight: bold; 
  cursor: pointer; 
  display: flex; 
  justify-content: space-between;
  align-items: center; /* <-- Добавляем это, чтобы выровнять элементы по вертикали */
}
#ai-chat-body { padding: 15px; display: flex; flex-direction: column; height: 350px; }
/* Контейнер с сообщениями */
#ai-chat-log { 
  flex: 1; 
  overflow-y: auto; 
  margin-bottom: 10px; 
  font-size: 14px; 
  line-height: 1.4; 
  padding-right: 10px; /* Чуть больше отступа, чтобы текст не прилипал */
  
  /* Скрываем стандартный скроллбар для Firefox */
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

/* Тонкий и аккуратный скроллбар для Chrome/Edge/Safari */
#ai-chat-log::-webkit-scrollbar {
  width: 6px; /* Ширина скроллбара */
}

#ai-chat-log::-webkit-scrollbar-track {
  background: transparent; /* Прозрачный фон дорожки */
  margin: 4px 0; /* Отступы сверху и снизу, чтобы он не прилипал к краям */
}

#ai-chat-log::-webkit-scrollbar-thumb {
  background: #d1d1d1; /* Цвет ползунка */
  border-radius: 10px; /* Закругление */
}

#ai-chat-log::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8; /* Цвет при наведении */
}
.ai-msg-user { text-align: right; margin-bottom: 10px; }
.ai-msg-user span { background: #e3f2fd; padding: 8px 12px; border-radius: 12px 12px 0 12px; display: inline-block; color: #000; }
.ai-msg-bot { text-align: left; margin-bottom: 10px; }
.ai-msg-bot span { background: #f1f1f1; padding: 8px 12px; border-radius: 12px 12px 12px 0; display: inline-block; color: #333; }
#ai-chat-input-wrapper { 
    display: flex; 
    border-top: 1px solid #eee; 
    padding-top: 10px; 
}

#ai-chat-input { 
    flex: 1; 
    padding: 8px 12px !important; /* Уменьшаем отступы и добавляем !important */
    border: 1px solid #ccc !important; 
    border-radius: 6px !important; 
    outline: none !important; 
    font-size: 14px !important; 
    height: 40px !important; /* Фиксируем высоту */
    box-sizing: border-box !important; 
}

#ai-chat-send { 
    padding: 0 15px !important; /* Убираем вертикальные отступы, оставляем горизонтальные */
    margin-left: 8px !important; 
    background: #007bff !important; 
    color: #fff !important; 
    border: none !important; 
    border-radius: 6px !important; 
    cursor: pointer !important; 
    font-weight: bold !important; 
    height: 40px !important; /* Фиксируем высоту такую же, как у инпута */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
}

#ai-chat-send:disabled { 
    background: #ccc !important; 
    cursor: not-allowed !important; 
}
#ai-chat-toggle {
  position: fixed; 
  bottom: 20px; 
  right: 20px; 
  width: 64px; 
  height: 64px;
  background: linear-gradient(135deg, #007bff, #00d2ff); /* Градиент вместо плоского цвета */
  color: #fff; 
  border-radius: 50%; 
  display: flex;
  justify-content: center; 
  align-items: center; 
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4); /* Синяя тень */
  z-index: 10000;
  transition: transform 0.2s ease;
}

#ai-chat-toggle:hover {
  transform: scale(1.05); /* Легкое увеличение при наведении */
}

/* Анимация пульсации (как у Алисы или Siri) */
#ai-chat-toggle::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
  z-index: -1;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Всплывающая подсказка */
#ai-chat-toggle::after {
  content: "ИИ-Помощник";
  position: absolute;
  right: 80px;
  background: #333;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#ai-chat-toggle:hover::after {
  opacity: 1;
}

/* Адаптация для мобильных устройств */
@media (max-width: 480px) {
  #ai-chat-widget {
    width: calc(100% - 30px) !important; /* Ширина экрана минус отступы */
    left: 15px !important;               /* Отступ слева */
    right: 15px !important;              /* Отступ справа */
    bottom: 70px !important;             /* Поднимаем выше кнопки, чтобы не перекрывать */
    border-radius: 12px !important;
  }
  
  #ai-chat-toggle {
    width: 55px !important;             /* Чуть уменьшаем кнопку на мобильных */
    height: 55px !important;
  }
  
  /* Убедимся, что история чата не перекрывается */
  #ai-chat-log {
    padding-right: 10px !important;
  }
}

/* Сброс стилей для кнопок оценки внутри виджета */
#ai-chat-widget button[onclick^="rateAnswer"] {
    background: none !important;
    border: none !important;
    margin: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    line-height: 1 !important; /* Чтобы эмодзи не прыгали по высоте */
    height: auto !important;
    width: auto !important;
}