.chatbot-widget {
  position: fixed;
  bottom: var(--spacing-lg, 24px);
  right: var(--spacing-lg, 24px);
  z-index: 9999;
  font-family: inherit;
}

.chatbot-toggle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.4), 0 0 80px rgba(245, 158, 11, 0.2), var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: visible;
  animation: floatBounce 3s ease-in-out infinite, glowPulse 3s ease-in-out infinite;
}

@keyframes floatBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-10px) scale(1.05); }
  50% { transform: translateY(-18px) scale(1.08); }
  75% { transform: translateY(-10px) scale(1.05); }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 40px rgba(245, 158, 11, 0.4), 0 0 80px rgba(245, 158, 11, 0.2), var(--shadow-lg); }
  50% { box-shadow: 0 0 60px rgba(245, 158, 11, 0.7), 0 0 100px rgba(245, 158, 11, 0.4), 0 0 140px rgba(245, 158, 11, 0.2); }
}

.chatbot-toggle:hover {
  animation: none;
  transform: scale(1.2) rotate(10deg);
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 0 80px rgba(245, 158, 11, 0.9), 0 0 120px rgba(245, 158, 11, 0.6), 0 0 160px rgba(245, 158, 11, 0.3);
}

.chatbot-toggle svg {
  width: 34px;
  height: 34px;
  fill: var(--text-inverse);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  position: relative;
  z-index: 1;
  animation: iconWiggle 5s ease-in-out infinite;
}

@keyframes iconWiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  10% { transform: rotate(-15deg) scale(1.15); }
  20% { transform: rotate(15deg) scale(1.15); }
  30% { transform: rotate(-12deg) scale(1.12); }
  40% { transform: rotate(0deg) scale(1); }
}

.chatbot-toggle:hover svg {
  animation: iconBounceHover 0.5s ease-in-out infinite;
}

@keyframes iconBounceHover {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.3) rotate(15deg); }
}

.chatbot-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid var(--primary);
  transform: translate(-50%, -50%);
  animation: ripple 2.5s ease-out infinite;
  opacity: 0;
}

@keyframes ripple {
  0% { width: 100%; height: 100%; opacity: 0.8; border-width: 3px; }
  100% { width: 200%; height: 200%; opacity: 0; border-width: 0; }
}

.chatbot-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #ef4444, #f87171);
  color: var(--text-inverse);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  animation: badgePulse 2s infinite;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.6);
  border: 3px solid var(--bg-primary);
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7), 0 4px 12px rgba(239, 68, 68, 0.6); }
  50% { transform: scale(1.25); box-shadow: 0 0 0 12px rgba(239, 68, 68, 0), 0 4px 12px rgba(239, 68, 68, 0.6); }
}

.chatbot-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 420px;
  height: 650px;
  background: var(--bg-primary);
  border-radius: 24px;
  box-shadow: var(--shadow-xl), 0 0 100px rgba(245, 158, 11, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(20px) saturate(180%);
  transform-origin: bottom right;
}

.chatbot-container.resizing {
  transition: none !important;
  user-select: none;
}

.chatbot-container.active {
  display: flex;
  animation: slideUpScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUpScale {
  from { opacity: 0; transform: translateY(30px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chatbot-header {
  background: var(--gradient-primary);
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.chatbot-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
  opacity: 0.5;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.chatbot-avatar {
  width: 48px;
  height: 48px;
  background: var(--bg-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--primary);
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 255, 255, 0.3);
  animation: avatarPulse 3s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 255, 255, 0.3); }
  50% { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 0 0 5px rgba(255, 255, 255, 0.5); }
}

.chatbot-header-text h3 {
  margin: 0;
  color: var(--text-inverse);
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: -0.3px;
}

.chatbot-header-text span {
  color: var(--text-inverse);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.status-dot {
  width: 9px;
  height: 9px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  animation: statusBlink 2s infinite;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

@keyframes statusBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

.chatbot-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--text-inverse);
  cursor: pointer;
  padding: 8px;
  border-radius: 12px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(10px);
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(180deg, var(--bg-secondary), var(--bg-primary));
}

.chatbot-messages::-webkit-scrollbar {
  width: 8px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary), var(--primary-light));
  border-radius: 20px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

.message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.message.client {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.message-content {
  max-width: 70%;
  padding: 14px 18px;
  border-radius: 20px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.message.client .message-content {
  background: var(--gradient-primary);
  color: var(--text-inverse);
  border-bottom-right-radius: 6px;
}

.message.bot .message-content {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 6px;
}

.message-text {
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

.message-text a {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-all;
  font-weight: 500;
}

.message-text a:hover {
  color: var(--primary-dark);
  text-decoration: none;
}

.message.client .message-text a {
  color: var(--text-inverse);
}

.message-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
  opacity: 0.7;
}

.message.client .message-time {
  color: rgba(255, 255, 255, 0.9);
  opacity: 1;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.typing-dots {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.typing-dots span {
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

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

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

.chatbot-input {
  padding: 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--bg-primary);
  border-radius: 28px;
  padding: 6px 6px 6px 22px;
  border: 2px solid var(--border-color);
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12), var(--shadow-md);
  transform: translateY(-2px);
}

#chatbot-message {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  padding: 10px 0;
  font-family: inherit;
}

#chatbot-message::placeholder {
  color: var(--text-tertiary);
}

.chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.chatbot-send:hover:not(:disabled) {
  transform: scale(1.15) rotate(15deg);
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.5);
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.chatbot-send:active:not(:disabled) {
  transform: scale(0.95);
}

.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-send svg {
  width: 22px;
  height: 22px;
  fill: var(--text-inverse);
}

.error-message {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.05));
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 14px;
  border-radius: 16px;
  margin: 12px;
  font-size: 14px;
  text-align: center;
  font-weight: 500;
}

.welcome-message {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
}

.welcome-message h4 {
  color: var(--primary);
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 700;
}

.chatbot-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 14px;
  cursor: ns-resize;
  z-index: 20;
  background: transparent;
}

.chatbot-resize-handle::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  transition: background 0.3s;
}

.chatbot-resize-handle:hover::before {
  background: rgba(255, 255, 255, 0.6);
}

.chatbot-widget *:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .chatbot-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    border-radius: 0;
    z-index: 9999;
  }

  .chatbot-toggle {
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    z-index: 9998;
  }

  .chatbot-widget {
    bottom: 20px;
    right: 20px;
  }

  .chatbot-resize-handle {
    display: none;
  }
}