/* AI Chatbot Widget - Premium Design */
:root {
  --primary-color: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #6366F1;
  --secondary-color: #F8FAFC;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-light: #94A3B8;
  --border-color: #E2E8F0;
  --success-color: #10B981;
  --background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15);
  --message-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Reset and base styles for widget */
#ai-chatbot-widget {
  box-sizing: border-box;
}

#ai-chatbot-widget *,
#ai-chatbot-widget *::before,
#ai-chatbot-widget *::after {
  box-sizing: inherit;
}

/* Reset only for specific elements that need it */
#ai-chatbot-widget button,
#ai-chatbot-widget h1,
#ai-chatbot-widget h2,
#ai-chatbot-widget h3,
#ai-chatbot-widget h4,
#ai-chatbot-widget h5,
#ai-chatbot-widget h6 {
  margin: 0;
  padding: 0;
}

/* Widget container */
#ai-chatbot-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}

/* Chat button - Premium floating action button */
.chatbot-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.3), 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.chatbot-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chatbot-button:hover::before {
  opacity: 1;
}

.chatbot-button:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 32px rgba(79, 70, 229, 0.4), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chatbot-button:active {
  transform: scale(1.02);
}

.chatbot-button svg {
  width: 32px;
  height: 32px;
  fill: white;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.chatbot-button.active svg.chat-icon {
  transform: rotate(90deg) scale(0);
}

.chatbot-button svg.close-icon {
  position: absolute;
  transform: rotate(-90deg) scale(0);
}

.chatbot-button.active svg.close-icon {
  transform: rotate(0) scale(1);
}

/* Notification badge */
.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  border: 2px solid white;
  display: none;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.chatbot-badge.show {
  display: flex;
}

/* Chat window - Premium card design */
.chatbot-window {
  position: absolute;
  bottom: 90px;
  right: 0;
  width: 420px;
  height: 680px;
  background: white;
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18), 0 8px 24px rgba(0, 0, 0, 0.12);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92) translateY(20px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(10px);
}

.chatbot-window.open {
  display: flex;
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Header - Premium gradient with glass effect */
.chatbot-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  padding: 24px 28px;
  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, rgba(255, 255, 255, 0.15) 0%, transparent 100%);
  pointer-events: none;
}

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

.chatbot-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease;
}

.chatbot-avatar:hover {
  transform: scale(1.05);
}

.chatbot-header-text h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 3px;
  letter-spacing: -0.3px;
}

.chatbot-header-text p {
  font-size: 13px;
  opacity: 0.95;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-header-text p::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  display: inline-block;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.chatbot-minimize {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

.chatbot-minimize:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

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

.chatbot-minimize svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* Messages container - Premium scrollable area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: linear-gradient(180deg, #F8FAFC 0%, #FFFFFF 100%);
}

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

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.2);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.3);
  background-clip: padding-box;
}

/* Message styles - Premium cards */
.message {
  display: flex;
  gap: 14px;
  animation: messageSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin-bottom: 8px;
}

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

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  border: 2px solid white;
}

.message.bot {
  margin-right: 32px;
}

.message.user {
  margin-left: 32px;
  flex-direction: row-reverse;
}

.message.bot .message-avatar {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%);
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

.message-bubble {
  padding: 16px 18px !important;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
  transition: all 0.3s ease;
}

.message.bot .message-bubble {
  background: white;
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(226, 232, 240, 0.6);
}

.message.bot .message-bubble:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3), 0 2px 6px rgba(79, 70, 229, 0.2);
}

.message.user .message-bubble:hover {
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4), 0 3px 8px rgba(79, 70, 229, 0.25);
  transform: translateY(-1px);
}

.message-time {
  font-size: 12px;
  color: var(--text-light);
  padding: 0 6px;
  font-weight: 500;
}

.message.user .message-time {
  text-align: right;
}

/* Typing indicator - Premium animation */
.typing-indicator {
  display: none;
  gap: 12px;
}

.typing-indicator.show {
  display: flex;
}

.typing-bubble {
  background: white;
  padding: 18px 22px;
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(226, 232, 240, 0.6);
  display: flex;
  gap: 6px;
  align-items: center;
}

.typing-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  animation: typingBounce 1.4s infinite ease-in-out;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

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

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

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

/* Input area - Premium design */
.chatbot-input-area {
  padding: 24px 28px 32px 28px;
  background: white;
  border-top: 1px solid rgba(226, 232, 240, 0.8);
  backdrop-filter: blur(10px);
}

.chatbot-input-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chatbot-input {
  flex: 1;
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  transition: all 0.3s ease;
  background: #F8FAFC;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 0 !important;
  margin-left: 0 !important;
}

.chatbot-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: white;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.08);
}

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

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

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

.chatbot-input::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.2);
  border-radius: 3px;
}

/* Send button - Premium gradient button */
.chatbot-send-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3), 0 2px 6px rgba(79, 70, 229, 0.2);
  position: relative;
  overflow: hidden;
}

.chatbot-send-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chatbot-send-button:hover:not(:disabled)::before {
  opacity: 1;
}

.chatbot-send-button:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-color) 100%);
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4), 0 4px 10px rgba(79, 70, 229, 0.25);
}

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

.chatbot-send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.15);
}

.chatbot-send-button svg {
  width: 20px;
  height: 20px;
  fill: white;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.chatbot-send-button:hover:not(:disabled) svg {
  transform: translateX(2px);
}

/* Welcome message - Premium design */
.welcome-message {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-secondary);
  animation: fadeIn 0.6s ease-out;
}

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

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

.welcome-message p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Error message - Premium alert */
.error-message {
  background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
  border: 1px solid #FCA5A5;
  color: #991B1B;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
  animation: slideDown 0.3s ease-out;
}

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

.error-message::before {
  content: '⚠️';
  font-size: 18px;
}

/* Mobile responsive - Premium mobile experience */
@media (max-width: 480px) {
  #ai-chatbot-widget {
    bottom: 16px;
    right: 16px;
  }

  .chatbot-button {
    width: 60px;
    height: 60px;
  }

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

  /* Reduce chat window size */
  .chatbot-window {
    width: 95vw !important;
    max-width: 95vw !important;
    height: 65vh !important;
    max-height: 65vh !important;
    bottom: 80px !important;
    right: 2.5vw !important;
  }

  /* Reduce header padding */
  .chatbot-header {
    padding: 16px 18px;
  }

  .chatbot-avatar {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .chatbot-header-text h3 {
    font-size: 15px;
  }

  .chatbot-header-text p {
    font-size: 12px;
  }

  /* Reduce message padding */
  .chatbot-messages {
    padding: 16px 18px;
    gap: 16px;
  }

  .message {
    gap: 10px;
    margin-bottom: 6px;
  }

  .message.bot {
    margin-right: 20px;
  }

  .message.user {
    margin-left: 20px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .message-bubble {
    padding: 12px 14px !important;
    font-size: 14px;
    line-height: 1.5;
  }

  .message-time {
    font-size: 11px;
  }

  /* Smaller input area */
  .chatbot-input-area {
    padding: 16px 18px 20px 18px;
  }

  .chatbot-input-container {
    gap: 10px;
    margin: 0;
  }

  .chatbot-input {
    padding: 12px 16px;
    font-size: 14px;
    max-height: 80px;
    border-radius: 14px;
  }

  .chatbot-send-button {
    width: 42px;
    height: 42px;
  }

  .chatbot-send-button svg {
    width: 18px;
    height: 18px;
  }

  /* Reduce welcome message padding */
  .welcome-message {
    padding: 24px 18px;
  }

  .welcome-message h4 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .welcome-message p {
    font-size: 14px;
  }

  /* Reduce typing indicator size */
  .typing-bubble {
    padding: 14px 18px;
  }

  .typing-dot {
    width: 8px;
    height: 8px;
  }
}

/* Smooth animations */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Premium hover effects for interactive elements */
.chatbot-window * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Glassmorphism effect for premium feel */
@supports (backdrop-filter: blur(10px)) {
  .chatbot-window {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
  }
}
