/**
 * Chatbot Styles - El Maderista
 * Floating chatbot powered by Cloudflare Workers AI
 */

/* ============================================
   CSS Variables - Customize your colors here
   ============================================ */
:root {
  /* Primary brand colors */
  --chatbot-primary: #8B4513; /* Saddle Brown - wood color */
  --chatbot-primary-dark: #5D2E0C;
  --chatbot-primary-light: #A0522D;
  
  /* UI Colors */
  --chatbot-bg: #ffffff;
  --chatbot-text: #333333;
  --chatbot-text-light: #666666;
  --chatbot-border: #e0e0e0;
  --chatbot-shadow: rgba(0, 0, 0, 0.15);
  
  /* Message colors */
  --chatbot-user-bg: #8B4513;
  --chatbot-user-text: #ffffff;
  --chatbot-bot-bg: #f5f5f5;
  --chatbot-bot-text: #333333;
  
  /* Sizing */
  --chatbot-width: 380px;
  --chatbot-height: 550px;
  --chatbot-button-size: 60px;
  --chatbot-spacing: 20px;
}

/* ============================================
   Chatbot Wrapper & Toggle Button
   ============================================ */
.elmaderista-chatbot-wrapper {
  position: fixed;
  bottom: 135px;
  right: 35px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.chatbot-toggle {
  width: var(--chatbot-button-size);
  height: var(--chatbot-button-size);
  border-radius: 50%;
  background: var(--chatbot-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px var(--chatbot-shadow);
  transition: all 0.3s ease;
}

.chatbot-toggle:hover {
  background: var(--chatbot-primary-dark);
  transform: scale(1.05);
}

.chatbot-toggle.chatbot-toggle-active {
  background: var(--chatbot-primary-dark);
}

/* ============================================
   Invite Bubble
   ============================================ */
.chatbot-invite {
  background: var(--chatbot-bg);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--chatbot-shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 280px;
  cursor: pointer;
  animation: slideIn 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chatbot-invite span {
  font-size: 14px;
  color: var(--chatbot-text);
  line-height: 1.4;
}

.chatbot-invite-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--chatbot-text-light);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.chatbot-invite-close:hover {
  color: var(--chatbot-text);
}

.chatbot-invite-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

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

/* ============================================
   Chatbot Container
   ============================================ */
.chatbot-container {
  position: fixed;
  bottom: calc(var(--chatbot-button-size) + var(--chatbot-spacing) + 15px);
  right: var(--chatbot-spacing);
  width: var(--chatbot-width);
  height: var(--chatbot-height);
  background: var(--chatbot-bg);
  border-radius: 16px;
  box-shadow: 0 8px 32px var(--chatbot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  animation: fadeInUp 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chatbot-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

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

/* ============================================
   Chatbot Header
   ============================================ */
.chatbot-header {
  background: var(--chatbot-primary);
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.chatbot-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-avatar svg {
  width: 24px;
  height: 24px;
}

.chatbot-header-text {
  display: flex;
  flex-direction: column;
}

.chatbot-title {
  font-weight: 600;
  font-size: 15px;
}

.chatbot-status {
  font-size: 12px;
  opacity: 0.9;
}

.chatbot-header-actions {
  display: flex;
  gap: 8px;
}

.chatbot-header-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   Chat Messages Area
   ============================================ */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

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

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

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

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

/* Message Bubbles */
.chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
}

.chat-message-user {
  background: var(--chatbot-user-bg);
  color: var(--chatbot-user-text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-message-bot {
  background: var(--chatbot-bot-bg);
  color: var(--chatbot-bot-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* ============================================
   Markdown Styles in Bot Messages
   ============================================ */
.chat-message-bot strong {
  color: var(--chatbot-primary-dark);
  font-weight: 600;
}

.chat-message-bot em {
  font-style: italic;
}

.chat-message-bot a,
.chat-message-bot .chat-link {
  color: var(--chatbot-primary);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.chat-message-bot a:hover,
.chat-message-bot .chat-link:hover {
  border-bottom-color: var(--chatbot-primary);
}

.chat-message-bot .chat-heading {
  display: block;
  color: var(--chatbot-primary-dark);
  font-weight: 600;
  font-size: 14px;
  margin: 8px 0 4px 0;
}

.chat-message-bot .chat-list {
  margin: 8px 0;
  padding-left: 20px;
  list-style-type: none;
}

.chat-message-bot .chat-list li {
  position: relative;
  margin: 4px 0;
  padding-left: 8px;
}

.chat-message-bot .chat-list li::before {
  content: "•";
  color: var(--chatbot-primary);
  font-weight: bold;
  position: absolute;
  left: -12px;
}

/* ============================================
   Typing Indicator
   ============================================ */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--chatbot-primary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   Input Area
   ============================================ */
.chatbot-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--chatbot-border);
}

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

.chatbot-input {
  flex: 1;
  border: 1px solid var(--chatbot-border);
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

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

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

.chatbot-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.chatbot-send-btn:hover {
  background: var(--chatbot-primary-dark);
}

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

.chatbot-send-btn:disabled {
  background: var(--chatbot-border);
  cursor: not-allowed;
}

/* ============================================
   Footer
   ============================================ */
.chatbot-footer {
  padding: 10px 16px;
  background: #f9f9f9;
  border-top: 1px solid var(--chatbot-border);
  text-align: center;
}

.chatbot-disclaimer {
  font-size: 11px;
  color: var(--chatbot-text-light);
  margin: 0 0 4px 0;
}

.chatbot-branding {
  font-size: 11px;
  color: var(--chatbot-text-light);
  margin: 0;
}

.chatbot-branding a {
  color: var(--chatbot-primary);
  text-decoration: none;
}

.chatbot-branding a:hover {
  text-decoration: underline;
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 480px) {
  :root {
    --chatbot-width: calc(100vw - 30px);
    --chatbot-height: 70vh;
    --chatbot-button-size: 56px;
    --chatbot-spacing: 15px;
  }
  
  .chatbot-container {
    bottom: calc(var(--chatbot-button-size) + var(--chatbot-spacing) + 10px);
  }
  
  .chatbot-invite {
    max-width: 240px;
  }
  
  .chatbot-invite span {
    font-size: 13px;
  }
}

/* ============================================
   Animation for new messages
   ============================================ */
.chat-message {
  animation: messageSlideIn 0.2s ease;
}

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