/**
 * Kondee AI Chatbot - CSS Styling
 * Modern, responsive chat UI with smooth animations
 */

/* ============================================
   CHATBOT CONTAINER & GENERAL STYLES
   ============================================ */

#kondee-chatbot {
  font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --primary-color: #3498db;
  --secondary-color: #2c3e50;
  --accent-color: #e74c3c;
  --light-bg: #f8f9fa;
  --border-color: #ecf0f1;
  --text-color: #2c3e50;
  --user-bg: #3498db;
  --bot-bg: #ecf0f1;
  --user-text: #ffffff;
  --bot-text: #2c3e50;
}

/* ============================================
   CHATBOT BUTTON (FLOATING)
   ============================================ */

.chatbot-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  font-size: 1.8rem;
  color: white;
  transition: all 0.3s ease;
  z-index: 9998;
}

.chatbot-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chatbot-button:active {
  transform: scale(0.95);
}

.notification-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #e74c3c;
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

/* ============================================
   CHAT WINDOW
   ============================================ */

.chat-window {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 420px;
  height: 600px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 5px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  animation: slideIn 0.3s ease-out;
  overflow: hidden;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Responsive: Mobile view */
@media (max-width: 768px) {
  .chat-window {
    width: calc(100% - 20px);
    height: calc(100vh - 100px);
    bottom: 0;
    right: 10px;
    border-radius: 15px 15px 0 0;
  }

  .chatbot-button {
    bottom: 20px;
    right: 20px;
  }
}

/* ============================================
   CHAT HEADER
   ============================================ */

.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 70px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.1rem;
}

.chat-header-title i {
  font-size: 1.3rem;
}

.status-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: #27ae60;
  border-radius: 50%;
  margin-left: auto;
  animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7);
  }
  50% {
    opacity: 0.8;
    box-shadow: 0 0 0 8px rgba(39, 174, 96, 0);
  }
}

.close-chat-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 5px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-chat-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   MESSAGES CONTAINER
   ============================================ */

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Custom scrollbar */
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: #3498db;
  border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: #2980b9;
}

/* ============================================
   MESSAGES
   ============================================ */

.message {
  display: flex;
  gap: 12px;
  animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* User Message */
.message.user-message {
  justify-content: flex-end;
  flex-direction: row-reverse;
}

.message.user-message .message-content {
  background: var(--user-bg);
  color: var(--user-text);
  border-radius: 18px 18px 4px 18px;
  max-width: 80%;
  word-wrap: break-word;
}

/* Bot Message */
.message.bot-message {
  justify-content: flex-start;
}

.message.bot-message .message-content {
  background: var(--bot-bg);
  color: var(--bot-text);
  border-radius: 18px 18px 18px 4px;
  max-width: 80%;
  word-wrap: break-word;
}

.message-content {
  padding: 12px 16px;
  line-height: 1.5;
  font-size: 0.95rem;
}

.message-content p {
  margin: 0;
  white-space: pre-wrap;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.user-avatar {
  background: #3498db;
}

.message-time {
  display: block;
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 4px;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-animation {
  display: flex;
  gap: 4px;
  padding: 8px;
}

.typing-animation span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary-color);
  animation: typing 1.4s infinite;
}

.typing-animation span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-animation span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.5;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-10px);
  }
}

/* ============================================
   INPUT AREA
   ============================================ */

.chat-input-area {
  padding: 15px 20px;
  background: white;
  border-top: 1px solid var(--border-color);
}

.chat-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.message-input {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 25px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all 0.3s ease;
  background: #f8f9fa;
}

.message-input:focus {
  border-color: var(--primary-color);
  background: white;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.message-input::placeholder {
  color: #95a5a6;
}

.send-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.send-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-button:active {
  transform: scale(0.95);
}

/* ============================================
   CHAT FOOTER
   ============================================ */

.chat-footer {
  padding: 10px 20px;
  background: #f8f9fa;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: #95a5a6;
  font-size: 0.8rem;
}

/* ============================================
   UTILITIES
   ============================================ */

/* Smooth transitions */
* {
  transition: color 0.2s ease, background-color 0.2s ease;
}

/* Remove default browser styles */
button {
  cursor: pointer;
  font-family: inherit;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .chatbot-button,
  .chat-window,
  .message,
  .typing-animation span {
    animation: none !important;
    transition: none !important;
  }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
  #kondee-chatbot {
    --light-bg: #1a1a1a;
    --text-color: #e0e0e0;
    --bot-bg: #2a2a2a;
    --bot-text: #e0e0e0;
  }

  .messages-container {
    background: #1a1a1a;
  }

  .chat-input-area {
    background: #1a1a1a;
    border-top-color: #333;
  }

  .message-input {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #333;
  }

  .message-input::placeholder {
    color: #666;
  }

  .chat-footer {
    background: #2a2a2a;
    border-top-color: #333;
  }
}
