/* AI Chat Widget Styles */
.mkb-chat-widget {
  position: fixed;
  bottom: 184px; /* Above the toggle button */
  right: 32px;
  width: 350px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 200px);
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  font-family: 'Inter', sans-serif;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.mkb-chat-widget.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.mkb-chat-header {
  background: linear-gradient(135deg, #0a1f3d, #1DA1F2);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.mkb-chat-avatar {
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.mkb-chat-title {
  font-weight: 700;
  font-size: 16px;
  margin: 0;
}

.mkb-chat-status {
  font-size: 12px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mkb-chat-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
}

.mkb-chat-close,
.mkb-chat-clear {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mkb-chat-close:hover,
.mkb-chat-clear:hover {
  opacity: 1;
}

/* Body */
.mkb-chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mkb-chat-body::-webkit-scrollbar {
  width: 6px;
}

.mkb-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.mkb-chat-body::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}

/* Messages */
.mkb-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  animation: mkbFadeIn 0.3s ease-out;
  word-wrap: break-word;
  white-space: pre-wrap; /* Render newlines properly */
  flex-shrink: 0; /* Prevent the flex container from squishing tall messages */
}

.mkb-message p {
  margin: 0 0 8px 0;
}
.mkb-message p:last-child {
  margin: 0;
}

.mkb-message.bot {
  background: white;
  color: #334155;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02);
  border: 1px solid rgba(0,0,0,0.03);
}

.mkb-message.user {
  background: #1DA1F2;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 5px rgba(29, 161, 242, 0.2);
}

/* Input Area */
.mkb-chat-footer {
  padding: 16px;
  background: white;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
}

.mkb-chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  outline: none;
  font-size: 14px;
  transition: border-color 0.2s;
  font-family: inherit;
}

.mkb-chat-input:focus {
  border-color: #1DA1F2;
}

.mkb-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #1DA1F2;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.mkb-chat-send:hover {
  background: #0ea5e9;
  transform: scale(1.05);
}

.mkb-chat-send:active {
  transform: scale(0.95);
}

.mkb-chat-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Floating Toggle Button */
.mkb-chat-toggle {
  position: fixed;
  bottom: 112px; /* 32px (WA bottom) + 64px (WA height) + 16px (gap) */
  right: 32px; /* matches right-8 from tailwind */
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a1f3d, #1DA1F2);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(29, 161, 242, 0.3);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.mkb-chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(29, 161, 242, 0.4);
}

.mkb-chat-toggle:active {
  transform: scale(0.95);
}

/* Typing indicator */
.mkb-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
  border: 1px solid rgba(0,0,0,0.03);
  display: none;
}

.mkb-typing.active {
  display: flex;
}

.mkb-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: mkbTyping 1.4s infinite ease-in-out both;
}

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

@keyframes mkbTyping {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

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

/* Mobile adjustments */
@media (max-width: 640px) {
  .mkb-chat-widget {
    left: 16px;
    right: 16px;
    bottom: 184px;
    width: auto;
    max-width: none;
    height: 400px;
  }
}
