
/* 🚀 ПРЕДОТВРАЩЕНИЕ CLS ДЛЯ ЧАТА */
.chat-button {
  /* Предотвращаем CLS */
  transform: translateZ(0);
  will-change: transform;
  /* Скрываем до полной инициализации */
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-button.initialized {
  opacity: 1;
}

.chat-widget {
  /* Предотвращаем CLS */
  transform: translateZ(0);
  will-change: transform, opacity;
}

/* Мобильная оптимизация */
@media (max-width: 768px) {
  .chat-button {
    transform: translateZ(0) scale(0.9);
  }
  
  .chat-widget {
    transform: translateZ(0);
  }
}
/* AI Chat Widget для GipixCRM */
:root {
  --primary-color: #1976d2;
  --accent-color: #ffc107;
  --text-dark: #333;
  --text-muted: #6c757d;
  --border-light: #dee2e6;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.2);
  --border-radius: 12px;
}

/* Кнопка чата */
.chat-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #1565c0 100%);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: all 0.3s ease;
  animation: pulse 2s infinite;
}

.chat-button:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 40px rgba(25,118,210,0.4);
}

.chat-button.active {
  background: var(--accent-color);
  color: var(--text-dark);
  animation: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 8px 32px rgba(25,118,210,0.4); }
}

/* Виджет чата */
.chat-widget {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  height: 520px;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--border-light);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.chat-widget.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Заголовок чата */
.chat-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, #1565c0 100%);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.chat-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="2" fill="rgba(255,255,255,0.1)"/></svg>');
  animation: float 20s infinite linear;
}

.chat-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

@keyframes float {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  position: relative;
  z-index: 2;
  border: 3px solid rgba(255,255,255,0.8);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  overflow: hidden;
  background: white;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-avatar .fallback-icon {
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--primary-color);
}

.chat-info {
  flex: 1;
  position: relative;
  z-index: 2;
}

.chat-name {
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.chat-status {
  font-size: 0.85rem;
  opacity: 0.9;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

.chat-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}

.chat-close:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

/* Область сообщений */
.chat-messages {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  background: linear-gradient(145deg, #f8f9fa 0%, #ffffff 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

/* Сообщения */
.message {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  animation: messageSlide 0.4s ease-out;
}

@keyframes messageSlide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 2px solid white;
}

.message.bot .message-avatar {
  background: white;
  overflow: hidden;
}

.message.bot .message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.message.bot .message-avatar .fallback-icon {
  background: linear-gradient(135deg, var(--primary-color), #1565c0);
  color: white;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.message.user .message-avatar {
  background: var(--accent-color);
  color: var(--text-dark);
}

.message-content {
  background: white;
  padding: 0.875rem 1.125rem;
  border-radius: 18px;
  max-width: 75%;
  box-shadow: var(--shadow-sm);
  position: relative;
  border: 1px solid var(--border-light);
  backdrop-filter: blur(10px);
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--primary-color) 0%, #1565c0 100%);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(25,118,210,0.2);
}

.message-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.message.user .message-time {
  color: rgba(255,255,255,0.8);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: scale(1); opacity: 0.5; }
  30% { transform: scale(1.2); opacity: 1; }
}

/* Форма ввода */
.chat-input {
  padding: 1rem 1.25rem;
  background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.input-group {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chat-input-field {
  flex: 1;
  border: 1px solid var(--border-light);
  border-radius: 22px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s ease;
  background: white;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  font-family: inherit;
  line-height: 1.4;
}

.chat-input-field:focus {
  border-color: var(--primary-color);
  background: white;
  box-shadow: 0 0 0 3px rgba(25,118,210,0.1);
}

.chat-input-field::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  background: var(--primary-color);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 1rem;
  flex-shrink: 0;
  margin-bottom: 0;
}

.chat-send-btn:hover:not(:disabled) {
  background: #1565c0;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(25,118,210,0.3);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--text-muted);
}

/* Quick replies */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
  max-height: 100px;
  overflow-y: auto;
  padding: 0.25rem;
  opacity: 1;
  transform: translateY(0);
  transition: all 0.3s ease;
}

.quick-replies::-webkit-scrollbar {
  width: 3px;
}

.quick-replies::-webkit-scrollbar-track {
  background: transparent;
}

.quick-replies::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.quick-reply {
  background: rgba(25,118,210,0.08);
  border: 1px solid rgba(25,118,210,0.2);
  color: var(--primary-color);
  padding: 0.4rem 0.75rem;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  line-height: 1.2;
  min-height: 28px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  animation: slideInUp 0.4s ease-out forwards;
  opacity: 0;
  transform: translateY(10px);
}

@keyframes slideInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quick-reply:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(25,118,210,0.2);
}

/* Welcome message */
.welcome-message {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.8);
  border-radius: 16px;
  margin: 1rem 0;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.5);
}

.welcome-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--primary-color), #1565c0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-text {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

/* Мобильная адаптация */
@media (max-width: 768px) {
  .chat-widget {
    width: calc(100vw - 40px);
    height: calc(100vh - 140px);
    bottom: 90px;
    right: 20px;
    left: 20px;
  }
  
  .chat-button {
    bottom: 20px;
    right: 20px;
    width: 55px;
    height: 55px;
    font-size: 1.3rem;
  }

  .quick-replies {
    max-height: 80px;
  }

  .quick-reply {
    font-size: 0.7rem;
    padding: 0.35rem 0.6rem;
    min-height: 26px;
  }
}

@media (max-width: 480px) {
  .chat-widget {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    bottom: 80px;
    right: 10px;
    left: 10px;
  }
  
  .chat-button {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    bottom: 15px;
    right: 15px;
  }
}

/* Анимации и эффекты */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.bounce {
  animation: bounce 0.6s ease;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

/* Уведомление о новом сообщении */
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: #f44336;
  color: white;
  border-radius: 50%;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s infinite;
} 