/**
 * Chatbot MCP - Beautiful Modal Design
 * Matches Next.js ChatBotModal styling
 */

* {
  box-sizing: border-box;
}

/* Main Widget Container */
#chatbot-mcp-widget {
  position: fixed;
  width: 90%;
  max-width: 500px;
  height: 85vh;
  max-height: 700px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  opacity: 0;
  transform: translateY(100px) scale(0.8);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  overflow: hidden;
}

#chatbot-mcp-widget.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Position classes */
#chatbot-mcp-widget.chatbot-mcp-bottom-right {
  bottom: 100px;
  right: 16px;
}

#chatbot-mcp-widget.chatbot-mcp-bottom-left {
  bottom: 100px;
  left: 16px;
}

#chatbot-mcp-widget.chatbot-mcp-top-right {
  top: 20px;
  right: 16px;
}

#chatbot-mcp-widget.chatbot-mcp-top-left {
  top: 20px;
  left: 16px;
}

/* Mobile fix - prevent modal from going above screen */
@media (max-width: 1900px) {
  #chatbot-mcp-widget {
    max-height: calc(100vh - 180px);
  }
}

/* Header - Solid Dark Blue */
.chatbot-mcp-header {
  background: var(--chatbot-mcp-color, #173a52);
  padding: 16px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chatbot-mcp-header h3 {
  margin: 0;
  color: #ffffff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.chatbot-mcp-minimize {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0.85;
  margin-left: auto;
  line-height: 1;
}

.chatbot-mcp-minimize:hover {
  opacity: 1;
}

/* Welcome Section */
.chatbot-mcp-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px 20px;
  background: #ffffff;
  text-align: center;
}

.chatbot-mcp-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chatbot-mcp-color, #173a52);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.chatbot-mcp-avatar svg {
  width: 32px;
  height: 32px;
  color: #ffffff;
}

.chatbot-mcp-welcome-title {
  margin: 0 0 12px 0;
  color: #333333;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.chatbot-mcp-welcome-body {
  margin: 0;
  color: #666666;
  font-size: 14px;
  line-height: 1.5;
  max-width: 90%;
}

/* Questions Container */
.chatbot-mcp-questions-container {
  width: 100%;
  margin-top: 16px;
}

.chatbot-mcp-questions-wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

/* Question Widget Button */
.chatbot-mcp-question-btn {
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--chatbot-mcp-color, #173a52);
  border-radius: 8px;
  color: var(--chatbot-mcp-color, #173a52);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s ease;
  font-family: inherit;
  display: inline-block;
  width: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-mcp-question-btn:hover {
  background: rgba(var(--chatbot-mcp-color-rgb), 0.08);
  color: var(--chatbot-mcp-color, #173a52);
  box-shadow: 0 4px 12px rgba(var(--chatbot-mcp-color-rgb), 0.15);
  border-color: var(--chatbot-mcp-color, #173a52);
}

.chatbot-mcp-question-btn:active {
  transform: scale(0.96);
}

/* Messages Container */
.chatbot-mcp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  min-height: 0;
  overscroll-behavior: contain;
}

.chatbot-mcp-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-mcp-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-mcp-messages::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 3px;
}

.chatbot-mcp-messages::-webkit-scrollbar-thumb:hover {
  background: #bfbfbf;
}

/* Message Styling */
.chatbot-mcp-message {
  display: flex;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-mcp-message-user {
  justify-content: flex-end;
  flex-direction: column;
  align-items: flex-end;
}

.chatbot-mcp-message-assistant {
  justify-content: flex-start;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}

#chatbot-mcp-loading {
  align-items: flex-start;
}

.chatbot-mcp-message-loading {
  justify-content: flex-start;
  flex-direction: column;
  align-items: flex-start;
}

.chatbot-mcp-message-content {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chatbot-mcp-message-user .chatbot-mcp-message-content {
  background: var(--chatbot-mcp-color, #173a52);
  color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(23, 58, 82, 0.15);
  max-width: 100%;
  margin-right: 0;
  margin-left: auto;
  white-space: normal;
}

.chatbot-mcp-message-assistant .chatbot-mcp-message-content {
  background: #f5f5f5;
  color: #000000;
  border: none;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  white-space: normal;
}

.chatbot-mcp-message-loading .chatbot-mcp-message-content {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}

/* Message Icon */
.chatbot-mcp-message-icon {
  width: 28px;
  height: 28px;
  background: var(--chatbot-mcp-color, #173a52);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
  margin-top: 2px;
}

.chatbot-mcp-message-icon svg {
  width: 16px;
  height: 16px;
  color: #ffffff;
}

/* Loading Indicator - Icon next to Bubble */
#chatbot-mcp-loading {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.chatbot-mcp-loading-icon {
  width: 40px;
  height: 40px;
  background: var(--chatbot-mcp-color, #173a52);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  margin-right: 0;
}

.chatbot-mcp-loading-icon svg {
  width: 24px;
  height: 24px;
  color: #ffffff;
  display: block;
}

.chatbot-mcp-message-content {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#chatbot-mcp-loading .chatbot-mcp-message-content {
  background: #f5f5f5;
  color: #000000;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-mcp-loading-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: var(--chatbot-mcp-color, #173a52);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
}

.chatbot-mcp-loading-avatar svg {
  width: 16px;
  height: 16px;
  color: #ffffff;
  display: block;
}

.chatbot-mcp-loading-bubble {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 12px 16px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-mcp-thinking-status {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-mcp-thinking-status svg {
  color: var(--chatbot-mcp-color, #173a52);
  width: 12px;
  height: 12px;
}

.chatbot-mcp-typing-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chatbot-mcp-typing-dots .typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chatbot-mcp-color, #173a52);
  animation: typing 1.4s infinite;
}

.chatbot-mcp-typing-dots .typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.chatbot-mcp-typing-dots .typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-mcp-typing-dots .typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* Legacy typing dot styles for backwards compatibility */

/* Message content wrapper for assistant messages */
.chatbot-mcp-message-assistant > div {
  display: block;
}

/* Timestamp */
.chatbot-mcp-message-timestamp {
  font-size: 11px;
  color: #999999;
  margin-top: 2px;
  margin-left: 0;
  padding-left: 0;
}

.chatbot-mcp-message-user .chatbot-mcp-message-timestamp {
  text-align: right;
  padding-right: 0;
}

.chatbot-mcp-message-assistant .chatbot-mcp-message-timestamp {
  text-align: left;
  margin-left: 0;
}

/* AI Warning Section */
.chatbot-mcp-ai-warning {
  padding: 3px 12px;
  background-color: #fef3c7;
  border-radius: 0px;
  margin: 0;
  z-index: 10;
  width: 100%;
  box-sizing: border-box;
}

.chatbot-mcp-ai-warning span {
  font-size: 11px;
  color: #92400e;
  text-align: left;
  display: block;
}

/* Markdown Content */
.chatbot-mcp-message-content a {
  color: var(--chatbot-mcp-color, #173a52);
  text-decoration: underline;
  cursor: pointer;
}

.chatbot-mcp-message-user .chatbot-mcp-message-content a {
  color: #ffffff;
  text-decoration: underline;
}

/* Bold formatting */
.chatbot-mcp-message-content strong {
  font-weight: 700;
  color: currentColor;
}

/* Italic formatting */
.chatbot-mcp-message-content em {
  font-style: italic;
  color: currentColor;
}

/* Code formatting */
.chatbot-mcp-message-content code {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  color: currentColor;
}

.chatbot-mcp-message-user .chatbot-mcp-message-content code {
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.chatbot-mcp-message-assistant .chatbot-mcp-message-content code {
  background-color: #f5f5f5;
  color: #101828;
}

/* Loading Indicator */
.chatbot-mcp-message-loading-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-mcp-loading-status {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Typing Dots */
.typing-indicator {
  display: flex;
  gap: 6px;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chatbot-mcp-color, #173a52);
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0% {
    opacity: 0.4;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-8px);
  }
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Input Area */
.chatbot-mcp-input-area {
  padding: 12px 16px 14px 16px;
  background: #ffffff;
  flex-shrink: 0;
}

#chatbot-mcp-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  margin: 8px 16px 8px 16px;
}

#chatbot-mcp-input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 80px;
  background: transparent;
  color: #000000;
}

#chatbot-mcp-input::placeholder {
  color: #aaaaaa;
}

#chatbot-mcp-input:focus {
  background: transparent;
}

/* Input Footer with Send Button */
.chatbot-mcp-input-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 12px;
  background: #ffffff;
}

/* Send Button */
.chatbot-mcp-send {
  background: none;
  border: none;
  color: var(--chatbot-mcp-color, #173a52);
  cursor: pointer;
  padding: 0 12px;
  font-size: 16px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.chatbot-mcp-send:hover:not(:disabled) {
  opacity: 1;
  transform: scale(1.1);
}

.chatbot-mcp-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chatbot-mcp-send svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

/* Toggle Button */
.chatbot-mcp-toggle {
  position: fixed;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--chatbot-mcp-color, #173a52);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9998;
  opacity: 1;
  transform: scale(1);
}

.chatbot-mcp-toggle:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  transform: scale(1.08);
}

.chatbot-mcp-toggle:active {
  transform: scale(0.96);
}

.chatbot-mcp-toggle.hidden {
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
  display: none;
}

.chatbot-mcp-toggle svg {
  width: 28px;
  height: 28px;
}

/* Position toggle button */
.chatbot-mcp-toggle.chatbot-mcp-bottom-right {
  bottom: 32px;
  right: 32px;
}

.chatbot-mcp-toggle.chatbot-mcp-bottom-left {
  bottom: 32px;
  left: 32px;
}

.chatbot-mcp-toggle.chatbot-mcp-top-right {
  top: 32px;
  right: 32px;
}

.chatbot-mcp-toggle.chatbot-mcp-top-left {
  top: 32px;
  left: 32px;
}

@media (max-width: 600px) {
  .chatbot-mcp-toggle {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .chatbot-mcp-toggle.chatbot-mcp-bottom-right,
  .chatbot-mcp-toggle.chatbot-mcp-bottom-left,
  .chatbot-mcp-toggle.chatbot-mcp-top-right,
  .chatbot-mcp-toggle.chatbot-mcp-top-left {
    bottom: 20px;
    right: 20px;
    top: auto;
    left: auto;
  }
}

@keyframes typing {
  0% {
    opacity: 0.4;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-8px);
  }
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  #chatbot-mcp-toggle {
    width: 48px;
    height: 48px;
    bottom: 20px;
    right: 10px;
  }

  #chatbot-mcp-toggle.chatbot-mcp-bottom-right,
  #chatbot-mcp-toggle.chatbot-mcp-bottom-left,
  #chatbot-mcp-toggle.chatbot-mcp-top-right,
  #chatbot-mcp-toggle.chatbot-mcp-top-left {
    bottom: 20px !important;
    right: 10px !important;
    top: auto !important;
    left: auto !important;
  }
}

/* Scrollbar styling */
.chatbot-mcp-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-mcp-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.chatbot-mcp-messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.chatbot-mcp-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}
