/* AI Chatbot Styles - Claude.ai Inspired */

:root {
  --chat-bg: #f9f9f8;
  --chat-message-bg: #ffffff;
  --chat-user-bg: #e8e7e5;
  --chat-text: #2c2c2c;
  --chat-text-secondary: #666;
  --chat-border: #e5e5e4;
  --chat-accent: #cd7f32; /* Claude's warm bronze */
}

/* Modal Overlay */
#ai-chatbot-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

#ai-chatbot-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal Window */
#ai-chatbot-modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.4s ease-out;
}

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

/* Modal Header - Claude Style */
#chatbot-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--chat-message-bg);
  color: var(--chat-text);
  border-bottom: 1px solid var(--chat-border);
}

#chatbot-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  color: var(--chat-text);
}

.chatbot-subtitle {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: var(--chat-text-secondary);
  font-weight: 400;
}

#chatbot-modal-close {
  background: transparent;
  border: none;
  color: var(--chat-text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 20px;
}

#chatbot-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--chat-text);
}

/* Messages Container */
#chatbot-modal-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message Bubbles */
.bot-message,
.user-message {
  display: flex;
  animation: messageSlideIn 0.3s ease-out;
}

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

.bot-message {
  justify-content: flex-start;
}

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

.message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 15px;
  word-wrap: break-word;
}

.bot-message .message-content {
  background: var(--chat-message-bg);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.user-message .message-content {
  background: var(--chat-user-bg);
  color: var(--chat-text);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 16px;
  background: var(--chat-message-bg);
  border-radius: 12px;
  width: fit-content;
  border: 1px solid var(--chat-border);
}

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

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

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

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

/* Input Area */
#chatbot-modal-input-area {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  background: var(--chat-message-bg);
  border-top: 1px solid var(--chat-border);
}

#chatbot-modal-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  background: var(--chat-bg);
  color: var(--chat-text);
}

#chatbot-modal-input:focus {
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

#chatbot-modal-send {
  background: var(--chat-text);
  border: none;
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
  font-size: 16px;
}

#chatbot-modal-send:hover {
  transform: translateY(-1px);
  background: #1a1a1a;
}

#chatbot-modal-send:active {
  transform: translateY(0);
}

#chatbot-modal-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Floating Widget */
#ai-chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  animation: fadeIn 0.3s ease-out;
}

#ai-chatbot-widget.hidden {
  display: none;
}

#chatbot-widget-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--chat-accent);
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(205, 127, 50, 0.3);
  transition: transform 0.3s, box-shadow 0.3s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chatbot-widget-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 30px rgba(205, 127, 50, 0.4);
  background: #b8722e;
}

#chatbot-widget-button:active {
  transform: scale(1.05);
}

/* Scrollbar Styling */
#chatbot-modal-messages::-webkit-scrollbar {
  width: 8px;
}

#chatbot-modal-messages::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 4px;
}

#chatbot-modal-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
  transition: background 0.2s;
}

#chatbot-modal-messages::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  #ai-chatbot-modal {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-width: 100%;
    border-radius: 0;
  }

  #chatbot-modal-header {
    padding: 20px;
  }

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

  #chatbot-modal-input-area {
    padding: 16px;
  }

  .message-content {
    max-width: 85%;
    font-size: 14px;
  }

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

  #chatbot-widget-button {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
}

/* Accessibility - Focus States */
#chatbot-modal-input:focus-visible,
#chatbot-modal-send:focus-visible,
#chatbot-modal-close:focus-visible,
#chatbot-widget-button:focus-visible {
  outline: 2px solid rgba(44, 44, 44, 0.3);
  outline-offset: 2px;
}

/* Error State */
.error-message {
  background: #fee;
  color: #c33;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #fcc;
  font-size: 14px;
  text-align: center;
}

/* Link Styling in Messages */
.message-content a {
  color: var(--chat-accent);
  text-decoration: underline;
  transition: opacity 0.2s;
}

.message-content a:hover {
  opacity: 0.7;
}

.user-message .message-content a {
  color: var(--chat-text);
  font-weight: 500;
}

/* Adjust scroll-up button to not overlap with chat widget */
#scrollUp {
  bottom: 15px;
  right: 110px !important; /* Move left to avoid chat button */
}

/* Hide scroll-up button when chatbot modal is open */
body:has(#ai-chatbot-overlay:not(.hidden)) #scrollUp {
  display: none !important;
}

/* Fallback for browsers without :has() support */
@supports not (selector(:has(*))) {
  #ai-chatbot-overlay:not(.hidden) ~ * #scrollUp {
    display: none !important;
  }
}
