/**
 * My Baking Creations - AI Chatbot Widget Styles
 * Matches brand aesthetics from style.css
 */

/* ============================================
   CSS Variables (inherited from main site)
   ============================================ */
:root {
  --chatbot-pink: #EC268F;
  --chatbot-pink-dark: #D11F7E;
  --chatbot-yellow: #FFC532;
  --chatbot-brown: #C36239;
  --chatbot-dark-brown: #622D2B;
  --chatbot-cream: #e6d5c3;
  --chatbot-white: #FFFFFF;
  --chatbot-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  --chatbot-shadow-hover: 0 6px 30px rgba(0, 0, 0, 0.35);
}

/* ============================================
   Floating Chat Button
   ============================================ */
#chatbot-toggle {
  position: fixed;
  bottom: 100px;
  right: 30px;
  transform: none;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--chatbot-pink);
  border: none;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  animation: chatPulse 2s infinite;
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(236, 38, 143, 0.4); }
  50% { box-shadow: 0 4px 30px rgba(236, 38, 143, 0.7), 0 0 20px rgba(236, 38, 143, 0.4); }
}

#chatbot-toggle:hover {
  background: var(--chatbot-pink-dark);
  transform: scale(1.1);
  box-shadow: var(--chatbot-shadow-hover);
  animation: none;
}

#chatbot-toggle:focus {
  outline: 3px solid var(--chatbot-yellow);
  outline-offset: 2px;
}

#chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: var(--chatbot-white);
  transition: transform 0.3s ease;
}

#chatbot-toggle.open svg.chat-icon {
  display: none;
}

#chatbot-toggle.open svg.close-icon {
  display: block;
}

#chatbot-toggle svg.close-icon {
  display: none;
}

/* Notification badge */
#chatbot-toggle .notification-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  background: var(--chatbot-yellow);
  border-radius: 50%;
  border: 2px solid var(--chatbot-white);
  animation: pulse 2s infinite;
}

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

/* ============================================
   Chat Window
   ============================================ */
#chatbot-window {
  position: fixed;
  bottom: 180px;
  right: 30px;
  width: 380px;
  height: 500px;
  background: var(--chatbot-cream);
  border: 3px solid var(--chatbot-dark-brown);
  border-radius: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
}

#chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

/* ============================================
   Chat Header
   ============================================ */
#chatbot-header {
  background: var(--chatbot-pink);
  color: var(--chatbot-white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

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

#chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chatbot-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

#chatbot-header-text h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

#chatbot-header-text span {
  font-size: 12px;
  opacity: 0.9;
}

#chatbot-close {
  background: none;
  border: none;
  color: var(--chatbot-white);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

#chatbot-close:hover {
  opacity: 1;
}

/* ============================================
   Messages Area
   ============================================ */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

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

/* Message bubbles */
.chatbot-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  animation: messageSlide 0.3s ease;
}

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

.chatbot-message.bot {
  background: var(--chatbot-white);
  color: var(--chatbot-dark-brown);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

/* Typing indicator */
.chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 16px 20px;
  background: var(--chatbot-white);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-typing span {
  width: 8px;
  height: 8px;
  background: var(--chatbot-brown);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

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

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

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

/* Phone number display */
.chatbot-phone-card {
  background: var(--chatbot-yellow);
  color: var(--chatbot-dark-brown);
  padding: 16px;
  border-radius: 12px;
  text-align: center;
  margin-top: 8px;
}

.chatbot-phone-card a {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--chatbot-dark-brown);
  text-decoration: none;
  margin-top: 4px;
}

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

/* ============================================
   Input Area
   ============================================ */
#chatbot-input-area {
  padding: 16px;
  background: var(--chatbot-white);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

#chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--chatbot-cream);
  border-radius: 25px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

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

#chatbot-input::placeholder {
  color: #999;
}

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

#chatbot-send:hover {
  background: var(--chatbot-pink-dark);
  transform: scale(1.05);
}

#chatbot-send:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

#chatbot-send svg {
  width: 20px;
  height: 20px;
  fill: var(--chatbot-white);
}

/* ============================================
   Welcome Message
   ============================================ */
.chatbot-welcome {
  text-align: center;
  padding: 20px;
}

.chatbot-welcome h3 {
  color: var(--chatbot-dark-brown);
  margin: 0 0 8px 0;
  font-size: 18px;
}

.chatbot-welcome p {
  color: var(--chatbot-brown);
  margin: 0;
  font-size: 14px;
}

/* Quick reply buttons */
.chatbot-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.chatbot-quick-reply {
  background: var(--chatbot-white);
  border: 2px solid var(--chatbot-pink);
  color: var(--chatbot-pink);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chatbot-quick-reply:hover {
  background: var(--chatbot-pink);
  color: var(--chatbot-white);
}

/* ============================================
   Mobile Responsiveness
   ============================================ */
@media (max-width: 768px) {
  /* Move button to left side to avoid social sidebar conflict */
  #chatbot-toggle {
    bottom: 20px;
    left: 20px;
    right: auto;
    top: auto;
    transform: none;
    width: 60px;
    height: 60px;
  }

  #chatbot-window {
    bottom: 90px;
    left: 20px;
    right: 20px;
    top: auto;
    transform: none;
    width: auto;
    max-width: 400px;
  }

  #chatbot-window.open {
    transform: none;
  }
}

@media (max-width: 480px) {
  #chatbot-toggle {
    width: 54px;
    height: 54px;
    bottom: 15px;
    left: 15px;
  }

  #chatbot-toggle svg {
    width: 24px;
    height: 24px;
  }

  /* Full screen chat on mobile */
  #chatbot-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    border: none;
  }

  #chatbot-header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  #chatbot-messages {
    padding: 16px;
  }

  #chatbot-input-area {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .chatbot-message {
    max-width: 90%;
  }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  #chatbot-toggle,
  #chatbot-window,
  .chatbot-message,
  .chatbot-typing span {
    animation: none;
    transition: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #chatbot-window {
    border-width: 4px;
  }

  .chatbot-message.bot {
    border: 2px solid var(--chatbot-dark-brown);
  }

  .chatbot-message.user {
    border: 2px solid var(--chatbot-white);
  }
}
