/* chatbot.css - TAVA AI Style */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --bg: #ffffff;
  --text: #111827;
  --bubble-user: #f3f4f6;
  --bubble-assistant: #f3f4f6;
  --border: #e5e7eb;
  --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-border: 1px solid rgba(229, 229, 229, 0.8);
}

body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* Floating Toggle Button */
#chatbot-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 9999px;
  background: linear-gradient(to right, #3b82f6, #2563eb);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3), 0 4px 6px -2px rgba(59, 130, 246, 0.3);
  transition: all 0.3s;
}

#chatbot-toggle:hover {
  box-shadow: 0 20px 25px -5px rgba(59, 130, 246, 0.4), 0 10px 10px -5px rgba(59, 130, 246, 0.4);
  transform: scale(1.05);
}

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

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

@media (min-width: 768px) {
  #chatbot-toggle {
    bottom: 24px;
    right: 24px;
  }
}

/* Chat Modal */
#chatbot-popup {
  position: fixed;
  z-index: 50;
  transition: all 0.3s ease-out;
  inset: 16px;
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: var(--shadow-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 384px;
  max-height: 512px;
}

#chatbot-popup.open {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

#chatbot-popup.expanded {
  width: 80vw !important;
  max-width: none !important;
  height: 80vh !important;
  max-height: none !important;
}

@media (min-width: 768px) {
  #chatbot-popup {
    inset: auto;
    bottom: 24px;
    right: 24px;
    width: 384px;
    height: 512px;
  }
}

/* Header */
#chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(to right, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#chatbot-header-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

#chatbot-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

#chatbot-header-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chatbot-header-icon svg {
  width: 16px;
  height: 16px;
}

#chatbot-header-text {
  font-weight: 600;
  font-size: 14px;
}

#chatbot-header-subtext {
  font-size: 12px;
  opacity: 0.8;
}

#expand-btn {
  padding: 6px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

#expand-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

#expand-btn svg {
  width: 16px;
  height: 16px;
}

#close-btn {
  padding: 6px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

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

#close-btn svg {
  width: 16px;
  height: 16px;
}

/* Messages Area */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.message {
  max-width: 85%;
  animation: fadeIn 0.3s ease-in;
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message div {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 16px;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
  max-width: 100%;
}

.message.user div {
  background: #3a40ef;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.message.assistant div {
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 4px;
}

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

.typing {
  display: flex;
  align-items: center;
  gap: 6px;
  font-style: italic;
  color: #666;
  padding: 10px 16px;
  background: #f3f4f6;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  max-width: 85%;
  align-self: flex-start;
}

.typing::after {
  content: '';
  width: 6px;
  height: 6px;
  background: #666;
  border-radius: 50%;
  animation: blink 1.2s infinite;
}

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

/* Input Area */
#chatbot-input-area {
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  background: white;
}

#chatbot-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 8px 16px;
  margin-bottom: 8px;
}

#chatbot-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: #374151;
}

#chatbot-input::placeholder {
  color: #9ca3af;
}

#chatbot-input:disabled {
  background: transparent;
  cursor: not-allowed;
}

#chatbot-send, #chatbot-stop {
  padding: 8px;
  background: #e5e7eb;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: #9ca3af;
}

#chatbot-send:hover:not(:disabled),
#chatbot-stop:hover:not(:disabled) {
  background: #d1d5db;
}

#chatbot-send:active,
#chatbot-stop:active {
  transform: scale(0.95);
}

#chatbot-send:disabled,
#chatbot-stop:disabled {
  background: #e5e7eb;
  cursor: not-allowed;
  opacity: 0.5;
}

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

#chatbot-stop {
  background: #e74c3c;
  color: white;
  display: none;
}

#chatbot-disclaimer {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
}

/* Markdown */
.markdown-body { font-size: 14px; }
.markdown-body :is(h1,h2,h3) { margin: 0.6em 0 0.3em; font-weight: 600; }
.markdown-body :is(ul,ol) { padding-left: 20px; margin: 0.5em 0; }
.markdown-body code { background: #e5e7eb; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.markdown-body pre { background: #2d2d2d; color: #f8f8f2; padding: 12px; border-radius: 8px; overflow-x: auto; margin: 0.5em 0; }
.markdown-body a { color: var(--primary); text-decoration: underline; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 0.5em 0; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 8px; text-align: left; }
.markdown-body th { background: #f5f5f5; }

@media (max-width: 480px) {
  #chatbot-popup {
    width: 100%;
    max-width: 350px;
    height: 600px;
  }

  #chatbot-toggle {
    bottom: 16px;
    right: 16px;
  }
}
