
:root {
  --primary-color: #4F46E5;
  --primary-dark: #4338CA;
  --primary-light: #6366F1;
  --success-color: #10B981;
  --error-color: #EF4444;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --bg-light: #F9FAFB;
  --border-color: #E5E7EB;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

/* Chatbot Button */
#lw-chatbot-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

#lw-chatbot-button:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-xl);
}

#lw-chatbot-button svg {
  width: 28px;
  height: 28px;
  color: white;
  transition: transform 0.3s ease;
}

#lw-chatbot-button.active svg {
  transform: rotate(180deg);
}

@keyframes pulse-ring {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(79, 70, 229, 0);
  }
}

/* Chatbot Window */
#lw-chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  z-index: 999998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#lw-chatbot-window.open {
  display: flex;
}

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

/* Header */
#lw-chatbot-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}

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

#lw-chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--primary-color);
  font-size: 18px;
  flex-shrink: 0;
}

#lw-chatbot-header-text {
  flex: 1;
  min-width: 0;
}

#lw-chatbot-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#lw-chatbot-header-text p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#lw-chatbot-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

#lw-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
#lw-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-light);
  scroll-behavior: smooth;
}

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

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

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

#lw-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Welcome Message */
.lw-welcome-message {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-secondary);
}

.lw-welcome-message h4 {
  margin: 0 0 8px;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
}

.lw-welcome-message p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
}

.lw-quick-questions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 280px;
  margin: 0 auto;
}

.lw-quick-question-btn {
  background: white;
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: all 0.2s;
  text-align: left;
}

.lw-quick-question-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Message Bubbles */
.lw-message {
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

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

.lw-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
}

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

.lw-message.user .lw-message-avatar {
  background: var(--text-secondary);
  color: white;
}

.lw-message.assistant .lw-message-avatar {
  background: var(--primary-color);
  color: white;
}

.lw-message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  /* white-space: pre-wrap; */
}

.lw-message.user .lw-message-content {
  background: var(--primary-color);
  color: white;
  border-bottom-right-radius: 4px;
}

.lw-message.assistant .lw-message-content {
  background: white;
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.lw-message-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 0 16px;
}

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

/* Streaming Content */
.lw-streaming-content {
  position: relative;
}

.lw-cursor {
  display: inline-block;
  color: var(--primary-color);
  animation: blink 1s step-end infinite;
  margin-left: 2px;
  font-weight: 300;
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* Typing Indicator */
.lw-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
}

.lw-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing 1.4s infinite;
}

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

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

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

/* Input Area */
#lw-chatbot-input-area {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

#lw-chatbot-input {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.4;
}

#lw-chatbot-input:focus {
  border-color: var(--primary-color);
}

#lw-chatbot-input::placeholder {
  color: var(--text-secondary);
}

#lw-chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#lw-chatbot-send:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(1.05);
}

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

#lw-chatbot-send svg {
  width: 20px;
  height: 20px;
}

/* Powered By */
#lw-chatbot-footer {
  padding: 8px 20px;
  background: var(--bg-light);
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
}

#lw-chatbot-footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

#lw-chatbot-footer a:hover {
  text-decoration: underline;
}

/* Error Message */
.lw-error-message {
  background: #FEE2E2;
  color: #991B1B;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  #lw-chatbot-button {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  #lw-chatbot-window {
    bottom: 88px;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: none;
    height: 550px;
  }

  #lw-chatbot-header {
    padding: 16px;
  }

  #lw-chatbot-messages {
    padding: 16px;
  }

  .lw-message-content {
    max-width: 85%;
  }

  .lw-quick-questions {
    max-width: 100%;
  }
}

/* Tablet */
@media (max-width: 768px) and (min-width: 481px) {
  #lw-chatbot-window {
    width: 380px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
  
  .lw-cursor {
    animation: none;
    opacity: 1;
  }
}

/* Focus states for accessibility */
#lw-chatbot-button:focus,
#lw-chatbot-close:focus,
#lw-chatbot-send:focus,
.lw-quick-question-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

#lw-chatbot-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}