/* =========================
   Modern Chatbot Widget
   ========================= */

.chatbot-widget {
  position: fixed;
  bottom: 100px;
  left: 20px;
  z-index: 9999;
  direction: rtl;
  font-family: inherit;
}

/* Modern Toggle Button */
.chatbot-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #ffffff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chatbot-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  animation: shineEffect 3s ease-in-out infinite;
}

@keyframes shineEffect {
  0% {
    left: -100%;
  }
  50%, 100% {
    left: 100%;
  }
}

.chatbot-toggle::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 2px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.chatbot-toggle:hover {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 20px 50px rgba(37, 99, 235, 0.4);
}

.chatbot-toggle:hover::after {
  opacity: 1;
}

.chatbot-toggle:active {
  transform: translateY(-2px) scale(1.02);
}

/* Modern Chat Window */
.chatbot-window {
  position: absolute;
  bottom: 85px;
  left: 0;
  width: 420px;
  max-height: 600px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: windowOpen 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.chatbot-window.active {
  display: flex;
}

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

/* Modern Header */
.chatbot-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 1;
}

.chatbot-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);
}

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

.chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.9);
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chatbot-info h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  color: #ffffff;
}

.chatbot-status {
  font-size: 0.8rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.9);
}

.chatbot-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  animation: statusDot 2s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.6);
}

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

.chatbot-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

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

/* Modern Messages Area */
.chatbot-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--color-background);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

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

.chatbot-messages::-webkit-scrollbar-track {
  background: var(--color-border);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: 3px;
}

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

/* Modern Message Styles */
.chatbot-message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: messageSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}

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

.chatbot-message.bot {
  align-self: flex-start;
}

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

.message-content {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.chatbot-message.bot .message-content {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-right-radius: 4px;
}

.chatbot-message.user .message-content {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #ffffff;
  border: none;
  border-bottom-left-radius: 4px;
}

/* Modern Quick Actions */
.chatbot-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  position: relative;
  z-index: 1;
}

.quick-action {
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.quick-action:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* Modern Input Area */
.chatbot-input-area {
  padding: 16px 20px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  position: relative;
  z-index: 1;
}

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

.chatbot-input-wrapper input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--color-background);
  color: var(--color-text);
  outline: none;
  transition: all var(--transition-fast);
}

.chatbot-input-wrapper input::placeholder {
  color: var(--color-text-muted);
}

.chatbot-input-wrapper input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.chatbot-send {
  width: 44px;
  height: 44px;
  border: none;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #ffffff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.chatbot-send:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.chatbot-send:active {
  transform: translateY(0);
}

/* Modern Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  border-bottom-right-radius: 4px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: typingIndicator 1.2s ease-in-out infinite;
}

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

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

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

@keyframes typingIndicator {
  0%, 100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Responsive */
@media (max-width: 480px) {
  .chatbot-widget {
    bottom: 180px;
    left: 10px;
    right: 10px;
  }

  .chatbot-window {
    width: 100%;
    left: 0;
    bottom: 70px;
    max-height: 65vh;
  }

  .chatbot-toggle {
    width: 55px;
    height: 55px;
    font-size: 1.5rem;
  }
}

@media (max-width: 768px) {
  .chatbot-window {
    width: 350px;
  }
}

/* =========================
   Modern Welcome Notification
   ========================= */

.chatbot-notification {
  position: fixed;
  bottom: 100px;
  left: 20px;
  z-index: 9998;
  animation: slideInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  direction: rtl;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.chatbot-notification.fade-out {
  animation: slideOutLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-30px);
  }
}

.notification-content {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  min-width: 320px;
  max-width: 420px;
  overflow: hidden;
}

.notification-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.1), transparent);
  animation: shineEffect 4s ease-in-out infinite;
}

.notification-content:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 50px rgba(37, 99, 235, 0.2);
  border-color: var(--color-primary);
}

.notification-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.notification-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.notification-text {
  flex: 1;
  position: relative;
  z-index: 1;
}

.notification-text p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text);
}

.notification-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 2;
  box-shadow: var(--shadow-sm);
}

.notification-close:hover {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  transform: scale(1.1);
}

/* Responsive for notification */
@media (max-width: 480px) {
  .chatbot-notification {
    bottom: 180px;
    left: 10px;
    right: 10px;
  }

  .notification-content {
    min-width: auto;
    max-width: 100%;
    padding: 14px 16px;
  }

  .notification-avatar {
    width: 38px;
    height: 38px;
  }

  .notification-text p {
    font-size: 0.85rem;
  }
}
