/* Основные стили виджета */
.agromarket-chat-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  box-sizing: border-box;
  z-index: 9999;
}

/* Кнопка открытия чата */
.chat-button {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #52B151 0%, #45a043 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(82, 177, 81, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.3s ease;
  z-index: 10000;
}

.chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(82, 177, 81, 0.4);
}

.chat-button-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #FF9800;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

/* Позиционирование */
.position-bottom-right .chat-button {
  bottom: 20px;
  right: 20px;
}

.position-bottom-left .chat-button {
  bottom: 20px;
  left: 20px;
}

/* Окно чата */
.chat-window {
  position: fixed;
  width: 400px;
  height: 600px;
  max-height: 90vh;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10001;
}

.position-bottom-right .chat-window {
  bottom: 90px;
  right: 20px;
}

.position-bottom-left .chat-window {
  bottom: 90px;
  left: 20px;
}

/* Заголовок чата */
.chat-header {
  background: linear-gradient(135deg, #52B151 0%, #45a043 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(82, 177, 81, 0.2);
}

.chat-header-info h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.chat-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #8BC34A;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-clear,
.chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: all 0.2s;
  border-radius: 6px;
}

.chat-clear:hover,
.chat-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Область сообщений */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #52B151;
}

/* Сообщения */
.message {
  margin-bottom: 16px;
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.message.bot {
  justify-content: flex-start;
}

.message-content {
  max-width: 75%;
  display: flex;
  flex-direction: column;
}

/* Для сообщений с товарами - на всю ширину */
.message.bot .message-content:has(.message-products),
.message.bot .message-content:has(.message-articles),
.message.bot .message-content:has(.message-actions-list) {
  max-width: 100%;
}

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

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #52B151 0%, #45a043 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 8px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(82, 177, 81, 0.3);
}

.message-bubble {
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  word-wrap: break-word;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, #52B151 0%, #45a043 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.bot .message-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  border: 1px solid #e8f5e9;
}

.message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  padding: 0 4px;
}

/* Индикатор печати */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #52B151;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

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

/* Карточки товаров - на всю ширину */
.message-products {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.product-card {
  border: 1px solid #e8f5e9;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  gap: 14px;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.product-card:hover {
  box-shadow: 0 4px 12px rgba(82, 177, 81, 0.15);
  transform: translateY(-2px);
  border-color: #52B151;
}

.product-card img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 2px solid #f0f0f0;
}

.product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.product-info h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-price {
  font-size: 18px;
  font-weight: bold;
  color: #52B151;
}

.btn-add-cart {
  background: linear-gradient(135deg, #52B151 0%, #45a043 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(82, 177, 81, 0.2);
  align-self: flex-start;
}

.btn-add-cart:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(82, 177, 81, 0.3);
}

.btn-add-cart:active {
  transform: translateY(0);
}

/* Карточки статей */
.message-articles {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.article-card {
  border: 1px solid #e8f5e9;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  gap: 14px;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.article-card:hover {
  box-shadow: 0 4px 12px rgba(82, 177, 81, 0.15);
  border-color: #52B151;
  transform: translateY(-2px);
}

.article-card img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.article-info {
  flex: 1;
  min-width: 0;
}

.article-info h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.article-date {
  font-size: 12px;
  color: #999;
}

/* Карточки акций */
.message-actions-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.action-card {
  border: 2px solid #FF9800;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  gap: 14px;
  background: #FFF8E1;
  position: relative;
  box-shadow: 0 2px 6px rgba(255, 152, 0, 0.15);
}

.action-card:hover {
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.25);
  transform: translateY(-2px);
}

.action-card img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.action-info {
  flex: 1;
  min-width: 0;
}

.action-info h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.action-badge {
  display: inline-block;
  background: #FF9800;
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Ссылки */
.message-links {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.link-button {
  display: inline-block;
  padding: 10px 16px;
  background: #e8f5e9;
  color: #45a043;
  text-decoration: none;
  border-radius: 8px;
  text-align: center;
  transition: all 0.2s;
  font-weight: 500;
  border: 1px solid #c8e6c9;
}

.link-button:hover {
  background: #52B151;
  color: white;
  border-color: #52B151;
  transform: translateY(-1px);
}

/* Поле ввода */
.chat-input-container {
  padding: 16px;
  background: white;
  border-top: 1px solid #e8f5e9;
  display: flex;
  gap: 8px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e8f5e9;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.chat-input:focus {
  border-color: #52B151;
  box-shadow: 0 0 0 3px rgba(82, 177, 81, 0.1);
}

.chat-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #52B151 0%, #45a043 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(82, 177, 81, 0.3);
}

.chat-send:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(82, 177, 81, 0.4);
}

.chat-send:active:not(:disabled) {
  transform: scale(0.98);
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
@media (max-width: 600px) {
  .position-bottom-right .chat-button {
    bottom: 70px;
  }
  
  .position-bottom-left .chat-button {
    bottom: 70px;
  }
}

/* Адаптивность */
@media (max-width: 480px) {
  .chat-window {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .position-bottom-right .chat-window,
  .position-bottom-left .chat-window {
    bottom: 0;
    left: 0;
    right: 0;
  }

  .position-bottom-right .chat-button,
  .position-bottom-left .chat-button {
    bottom: 10px;
    right: 10px;
    left: auto;
  }

  .product-card img,
  .article-card img,
  .action-card img {
    width: 70px;
    height: 70px;
  }

  .product-info h4,
  .article-info h4,
  .action-info h4 {
    font-size: 13px;
  }
}

/* Форма ввода данных пользователя */
.user-info-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
}

.user-info-header {
  padding: 30px 24px 20px;
  text-align: center;
  background: linear-gradient(135deg, #52B151 0%, #45a043 100%);
  color: white;
}

.user-info-header h3 {
  margin: 0 0 10px 0;
  font-size: 22px;
  font-weight: 600;
}

.user-info-header p {
  margin: 0;
  font-size: 14px;
  opacity: 0.95;
}

.user-info-body {
  flex: 1;
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.form-input {
  padding: 14px 16px;
  border: 2px solid #e8f5e9;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.form-input:focus {
  border-color: #52B151;
  box-shadow: 0 0 0 3px rgba(82, 177, 81, 0.1);
}

.form-input::placeholder {
  color: #999;
}

.form-actions {
  margin-top: auto;
  padding-top: 10px;
}

.btn-submit {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, #52B151 0%, #45a043 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(82, 177, 81, 0.3);
}

.btn-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(82, 177, 81, 0.4);
}

.btn-submit:active:not(:disabled) {
  transform: translateY(0);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.user-greeting {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

@media (max-width: 480px) {
  .user-info-header {
    padding: 24px 20px 16px;
  }

  .user-info-header h3 {
    font-size: 20px;
  }

  .user-info-body {
    padding: 24px 20px;
  }
}
