/**
 * Chat Widget Styles
 * Used by public/chat-widget.js
 * 
 * Import in your HTML:
 * <link rel="stylesheet" href="https://your-domain.com/chat-widget.css">
 */

/* Chat Widget Container */
#ai-chatbot-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  box-sizing: border-box;
  position: fixed;
  z-index: 999999;
}

#ai-chatbot-widget * {
  box-sizing: border-box;
}

/* Light Theme */
#ai-chatbot-widget.light {
  background-color: #ffffff;
  color: #333333;
}

#ai-chatbot-widget.light .ai-chatbot-header {
  background-color: #0056b3;
  color: #ffffff;
}

#ai-chatbot-widget.light .ai-chatbot-message.ai-chatbot-user .ai-message-bubble {
  background-color: #0056b3;
  color: #ffffff;
}

#ai-chatbot-widget.light .ai-chatbot-message.ai-chatbot-assistant .ai-message-bubble {
  background-color: #f0f0f0;
  color: #333333;
}

/* Dark Theme */
#ai-chatbot-widget.dark {
  background-color: #1e1e1e;
  color: #ffffff;
}

#ai-chatbot-widget.dark .ai-chatbot-header {
  background-color: #0056b3;
  color: #ffffff;
}

#ai-chatbot-widget.dark .ai-chatbot-message.ai-chatbot-user .ai-message-bubble {
  background-color: #0056b3;
  color: #ffffff;
}

#ai-chatbot-widget.dark .ai-chatbot-message.ai-chatbot-assistant .ai-message-bubble {
  background-color: #333333;
  color: #ffffff;
}

/* Positioning */
#ai-chatbot-widget.bottom-right {
  bottom: 20px;
  right: 20px;
}

#ai-chatbot-widget.bottom-left {
  bottom: 20px;
  left: 20px;
}

#ai-chatbot-widget.top-right {
  top: 20px;
  right: 20px;
}

#ai-chatbot-widget.top-left {
  top: 20px;
  left: 20px;
}

/* Header */
.ai-chatbot-header {
  padding: 16px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
}

.ai-chatbot-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.ai-chatbot-header button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.ai-chatbot-header button:hover {
  opacity: 0.8;
}

/* Messages Container */
.ai-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.ai-chatbot-messages::-webkit-scrollbar-thumb {
  background: #cccccc;
  border-radius: 3px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #999999;
}

/* Message Bubbles */
.ai-chatbot-message {
  display: flex;
  margin-bottom: 8px;
  animation: slideIn 0.3s ease-in-out;
}

.ai-chatbot-message.ai-chatbot-user {
  justify-content: flex-end;
}

.ai-chatbot-message.ai-chatbot-assistant {
  justify-content: flex-start;
}

.ai-message-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  word-wrap: break-word;
  line-height: 1.4;
}

.ai-chatbot-message.ai-chatbot-error .ai-message-bubble {
  background-color: #ff6b6b;
  color: #ffffff;
}

/* Typing Indicator */
.ai-typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  background-color: #f0f0f0;
  border-radius: 8px;
}

.ai-typing-indicator span {
  width: 8px;
  height: 8px;
  background-color: #999999;
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

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

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

/* Input Form */
form {
  padding: 12px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
}

form input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

form input:focus {
  outline: 3px solid #0056b3;
  outline-offset: 2px;
  border-color: #0056b3;
  box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

form button {
  background-color: #0056b3;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

form button:hover:not(:disabled) {
  background-color: #003d82;
}

form button:focus {
  outline: 3px solid #0056b3;
  outline-offset: 2px;
}

form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* Mobile Toggle Button (FAB - Floating Action Button) */
#ai-chatbot-fab {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  z-index: 999998;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#ai-chatbot-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 123, 255, 0.5);
}

#ai-chatbot-fab:active {
  transform: scale(0.95);
}

#ai-chatbot-fab.bottom-right {
  bottom: 20px;
  right: 90px;
}

#ai-chatbot-fab.bottom-left {
  bottom: 20px;
  left: 20px;
}

#ai-chatbot-fab.top-right {
  top: 20px;
  right: 20px;
}

#ai-chatbot-fab.top-left {
  top: 20px;
  left: 20px;
}

/* Responsive - Mobile devices */
@media (max-width: 768px) {
  /* Show FAB button on mobile */
  #ai-chatbot-fab {
    display: flex;
  }

  /* Hide widget by default on mobile, show only when opened */
  #ai-chatbot-widget {
    display: none !important; /* Hidden by default on mobile */
    width: 90vw !important;
    height: 70vh !important;
    max-width: 90vw !important;
    max-height: 70vh !important;
    bottom: 20px !important;
    right: 5vw !important;
    left: auto !important;
    top: auto !important;
  }

  /* Show widget when opened (toggled via JS) */
  #ai-chatbot-widget.open {
    display: flex !important;
  }

  #ai-chatbot-widget.bottom-left {
    left: 5vw !important;
    right: auto !important;
  }

  #ai-chatbot-widget.top-right,
  #ai-chatbot-widget.top-left {
    top: 80px !important;
    bottom: auto !important;
  }

  .ai-message-bubble {
    max-width: 85%;
  }

  form input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}
