/* ===== Кнопка открытия чата ===== */
.chatbot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  z-index: 1999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: #ffffff;
}

.chatbot-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.chatbot-fab:active {
  transform: scale(0.95);
}

.chatbot-fab svg {
  width: 28px;
  height: 28px;
}

/* ===== Чат-бот виджет ===== */
.chatbot-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.chatbot-overlay.is-open {
  display: flex;
}

.chatbot-window {
  width: min(420px, 100%);
  height: min(600px, 90vh);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideUp 0.3s ease-out;
}

@keyframes chatSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Шапка */
.chatbot-header {
  background: linear-gradient(135deg, #007510, #00a015);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-header__info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2) url('../styles/ai-chatbot.png') center/100%;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.chatbot-header__text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chatbot-header__text p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.chatbot-header__close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: grid;
  place-items: center;
  transition: background 0.2s;
}

.chatbot-header__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Предупреждение под шапкой */
.chatbot-notice {
  padding: 10px 20px;
  background: #fff8e1;
  border-bottom: 1px solid #f0e0b0;
  font-size: 12px;
  line-height: 1.4;
  color: #555;
}

.chatbot-notice a,
.chatbot-notice__contact {
  color: #007510;
  text-decoration: underline;
}

.chatbot-notice__contact {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
}

/* Сообщения */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chatbot-message {
  display: flex;
  gap: 10px;
  max-width: 80%;
  animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-message__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #007510;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.chatbot-message:not(.chatbot-message--user) .chatbot-message__avatar {
  background: #0088cc url('../styles/ai-chatbot.png') center/100%;
}

.chatbot-message--user .chatbot-message__avatar {
  background: #0088cc;
}

.chatbot-message__bubble {
  background: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  word-wrap: break-word;
  line-height: 1.5;
  color: #333;
}

.chatbot-message--user .chatbot-message__bubble {
  background: #0088cc;
  color: #fff;
}

.chatbot-message__time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* Индикатор печатает */
.chatbot-typing {
  display: none;
  align-items: center;
  gap: 10px;
  max-width: 80%;
}

.chatbot-typing.is-visible {
  display: flex;
}

.chatbot-typing__bubble {
  background: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  display: flex;
  gap: 4px;
}

.chatbot-typing__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: typingDot 1.4s infinite;
}

.chatbot-typing__dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing__dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Форма ввода */
.chatbot-input {
  padding: 16px 20px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 10px;
}

.chatbot-input__field {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.chatbot-input__field:focus {
  border-color: #007510;
}

.chatbot-input__send {
  width: 40px;
  height: 40px;
  border: none;
  background: #007510;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chatbot-input__send:hover {
  background: #00a015;
}

.chatbot-input__send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Мобильная адаптация */
@media (max-width: 480px) {
  .chatbot-window {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .chatbot-overlay {
    padding: 0;
  }
}

/* Форма контакта */
.chatbot-contact-form {
  padding: 20px;
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  display: none;
}

.chatbot-contact-form.is-visible {
  display: block;
}

.chatbot-contact-form__title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.chatbot-contact-form__field {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.chatbot-contact-form__field:focus {
  border-color: #007510;
}

.chatbot-contact-form__consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 1.4;
  color: #666;
}

.chatbot-contact-form__consent input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}

.chatbot-contact-form__consent a {
  color: #007510;
  text-decoration: underline;
}

.chatbot-contact-form__submit {
  width: 100%;
  padding: 12px;
  border: none;
  background: #007510;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
}

.chatbot-contact-form__submit:hover {
  background: #00a015;
}

.chatbot-contact-form__submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.chatbot-contact-form__error {
  color: #d32f2f;
  font-size: 12px;
  margin-top: 8px;
  display: none;
}

.chatbot-contact-form__error.is-visible {
  display: block;
}

.chatbot-contact-form__back {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: none;
  background: none;
  color: #007510;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.chatbot-contact-form__back:hover {
  text-decoration: underline;
}
