/* ============================================
   Cleanroom.com AI Chatbot Widget
   ============================================ */

/* Chat Toggle Button */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #09213a;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(9, 33, 58, 0.35);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(9, 33, 58, 0.45);
}

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: white;
  transition: opacity 0.2s ease;
}

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

.chatbot-toggle.active .icon-chat {
  display: none;
}

.chatbot-toggle.active .icon-close {
  display: block;
}

/* Unread badge */
.chatbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #0EA5E9;
  border-radius: 50%;
  border: 2px solid white;
  display: none;
}

.chatbot-badge.visible {
  display: block;
  animation: chatbot-pulse 2s infinite;
}

@keyframes chatbot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Chat Panel */
.chatbot-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 400px;
  max-height: 600px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.chatbot-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.chatbot-header {
  background: #09213a;
  color: white;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chatbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chatbot-header-text {
  flex: 1;
  min-width: 0;
}

.chatbot-header-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.chatbot-header-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chatbot-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}

.chatbot-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  display: flex;
}

.chatbot-close:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.chatbot-close svg {
  width: 20px;
  height: 20px;
}

/* Messages Area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 300px;
  max-height: 380px;
  scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

/* Message Bubbles */
.chatbot-msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: chatbot-fadeIn 0.3s ease;
}

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

.chatbot-msg.bot {
  align-self: flex-start;
}

.chatbot-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

.chatbot-msg.bot .chatbot-msg-avatar {
  background: #f0f7ff;
}

.chatbot-msg.bot .chatbot-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chatbot-msg.user .chatbot-msg-avatar {
  background: #0EA5E9;
}

.chatbot-msg.user .chatbot-msg-avatar svg {
  width: 16px;
  height: 16px;
  fill: white;
}

.chatbot-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}

.chatbot-msg.bot .chatbot-msg-bubble {
  background: #f3f4f6;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.chatbot-msg.user .chatbot-msg-bubble {
  background: #09213a;
  color: white;
  border-bottom-right-radius: 4px;
}

/* Markdown in bot messages */
.chatbot-msg.bot .chatbot-msg-bubble a {
  color: #0EA5E9;
  text-decoration: none;
  font-weight: 500;
}

.chatbot-msg.bot .chatbot-msg-bubble a:hover {
  text-decoration: underline;
}

.chatbot-msg.bot .chatbot-msg-bubble strong {
  font-weight: 600;
}

.chatbot-msg.bot .chatbot-msg-bubble p {
  margin: 0 0 8px 0;
}

.chatbot-msg.bot .chatbot-msg-bubble p:last-child {
  margin-bottom: 0;
}

.chatbot-msg.bot .chatbot-msg-bubble ul,
.chatbot-msg.bot .chatbot-msg-bubble ol {
  margin: 4px 0 8px 0;
  padding-left: 18px;
}

.chatbot-msg.bot .chatbot-msg-bubble li {
  margin-bottom: 4px;
}

/* Typing Indicator */
.chatbot-typing {
  display: none;
  align-self: flex-start;
  padding: 12px 18px;
  background: #f3f4f6;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  gap: 4px;
  align-items: center;
}

.chatbot-typing.visible {
  display: flex;
}

.chatbot-typing-dot {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: chatbot-bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes chatbot-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Quick Actions */
.chatbot-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.chatbot-quick-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 8px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  background: white;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.chatbot-quick-btn:hover {
  background: #f0f7ff;
  border-color: #0EA5E9;
  color: #09213a;
}

.chatbot-quick-btn svg {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 4px;
}

/* Input Area */
.chatbot-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: white;
}

.chatbot-input {
  flex: 1;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  color: #1f2937;
  outline: none;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s, background 0.15s;
}

.chatbot-input:focus {
  border-color: #0EA5E9;
  background: white;
}

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

.chatbot-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: #09213a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.chatbot-send:hover {
  background: #0c2d4f;
}

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

.chatbot-send:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

.chatbot-send svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* Powered by */
.chatbot-footer {
  text-align: center;
  padding: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.6875rem;
  color: #9ca3af;
  background: #fafafa;
  border-top: 1px solid #f3f4f6;
}

.chatbot-footer-link {
  color: #6b7280;
  text-decoration: none;
}

.chatbot-footer-link:hover {
  color: #0EA5E9;
  text-decoration: underline;
}

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 480px) {
  .chatbot-toggle {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }

  .chatbot-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .chatbot-messages {
    max-height: none;
    flex: 1;
  }

  .chatbot-panel.open ~ .chatbot-toggle {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-panel,
  .chatbot-msg,
  .chatbot-toggle,
  .chatbot-send,
  .chatbot-quick-btn,
  .chatbot-badge.visible,
  .chatbot-typing-dot {
    animation: none !important;
    transition: none !important;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .chatbot-panel {
    width: 360px;
    right: 16px;
    bottom: 80px;
  }

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