/* ========================================
   CHATBOT MODERN DESIGN
   ======================================== */

:root {
  --chatbot-primary: #2578ed;
  --chatbot-primary-dark: #133dd3;
  --chatbot-secondary: #061bd4;
  --chatbot-success: #48bb78;
  --chatbot-white: #ffffff;
  --chatbot-gray-50: #f9fafb;
  --chatbot-gray-100: #f3f4f6;
  --chatbot-gray-200: #e5e7eb;
  --chatbot-gray-300: #d1d5db;
  --chatbot-gray-400: #9ca3af;
  --chatbot-gray-500: #6b7280;
  --chatbot-gray-600: #4b5563;
  --chatbot-gray-700: #374151;
  --chatbot-gray-800: #1f2937;
  --chatbot-gray-900: #111827;
  --chatbot-gradient: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
  --chatbot-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --chatbot-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --chatbot-border-radius: 16px;
  --chatbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   CHATBOT TRIGGER BUTTON
   ======================================== */

.chatbot-trigger {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  cursor: pointer;
  transition: var(--chatbot-transition);
}

.chatbot-trigger:hover {
  transform: translateY(-2px);
}

.chatbot-icon {
  position: relative;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #eab566 0%, #e0470a 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chatbot-white);
  font-size: 1.5rem;
  box-shadow: var(--chatbot-shadow);
  transition: var(--chatbot-transition);
  overflow: hidden;
}

.chatbot-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
  border-radius: 50%;
}

.chatbot-icon:hover {
  transform: scale(1.05);
  box-shadow: var(--chatbot-shadow-lg);
}

.chatbot-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, #eab566 0%, #e0470a 100%);
  opacity: 0.3;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.1); opacity: 0.1; }
  100% { transform: scale(1.2); opacity: 0; }
}

.chatbot-tooltip {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 0.5rem;
  background: var(--chatbot-gray-800);
  color: var(--chatbot-white);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: var(--chatbot-transition);
  box-shadow: var(--chatbot-shadow);
}

.chatbot-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 1rem;
  border: 4px solid transparent;
  border-top-color: var(--chatbot-gray-800);
}

.chatbot-trigger:hover .chatbot-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ========================================
   CHAT CONTAINER
   ======================================== */

.chat-container {
  position: fixed;
  bottom: 70px;
  right: 2rem;
  width: 400px;
  max-height: calc(100vh - 150px);
  min-height: 450px;
  background: var(--chatbot-white);
  border-radius: var(--chatbot-border-radius);
  box-shadow: var(--chatbot-shadow-lg);
  z-index: 9999;
  display: none;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: var(--chatbot-transition);
  overflow: hidden;
  border: 1px solid var(--chatbot-gray-200);
}

.chat-container.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ========================================
   CHAT HEADER
   ======================================== */

.chat-header {
  background: var(--chatbot-gradient);
  color: var(--chatbot-white);
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.chat-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  z-index: 1;
}

.bot-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  backdrop-filter: blur(10px);
}

.chat-title h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  opacity: 0.9;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--chatbot-success);
  border-radius: 50%;
  animation: blink 2s infinite;
}

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

.close-chat {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--chatbot-white);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--chatbot-transition);
  position: relative;
  z-index: 1;
}

.close-chat:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

/* ========================================
   CHAT MESSAGES
   ======================================== */

.chat-messages-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--chatbot-gray-50);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  max-height: calc(95vh - 300px);
}

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

.chat-messages::-webkit-scrollbar-track {
  background: var(--chatbot-gray-100);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-gray-300);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-gray-400);
}

/* Bot Message */
.bot-message-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideInLeft 0.4s ease-out;
}

.bot-avatar-small {
  width: 32px;
  height: 32px;
  background: var(--chatbot-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chatbot-white);
  font-size: 0.875rem;
  flex-shrink: 0;
  margin-top: 0.25rem;
}

.bot-message {
  flex: 1;
  max-width: calc(100% - 48px);
}

.message-content {
  background: var(--chatbot-white);
  padding: 1rem 1.25rem;
  border-radius: 1rem 1rem 1rem 0.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--chatbot-gray-200);
  position: relative;
}

.message-content p {
  margin: 0;
  line-height: 1.5;
  color: var(--chatbot-gray-700);
}

.message-meta {
  margin-top: 0.5rem;
  display: flex;
  justify-content: flex-end;
}

.message-time {
  font-size: 0.75rem;
  color: var(--chatbot-gray-400);
}

/* User Message */
.user-message-wrapper {
  display: flex;
  justify-content: flex-end;
  animation: slideInRight 0.4s ease-out;
}

.user-message {
  max-width: 80%;
}

.user-message .message-content {
  background: var(--chatbot-gradient);
  color: var(--chatbot-white);
  border-radius: 1rem 1rem 0.25rem 1rem;
  border: none;
}

.user-message .message-content p {
  color: var(--chatbot-white);
}

.user-message .message-time {
  color: rgba(255, 255, 255, 0.7);
}

/* ========================================
   QUICK SUGGESTIONS
   ======================================== */

.quick-suggestions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--chatbot-gray-200);
}

.suggestions-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--chatbot-gray-600);
  margin: 0 0 0.75rem 0;
}

.suggestions-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.suggestion-btn {
  background: var(--chatbot-white);
  border: 1px solid var(--chatbot-gray-300);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: var(--chatbot-transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  font-size: 0.875rem;
  color: var(--chatbot-gray-700);
}

.suggestion-btn:hover {
  background: var(--chatbot-primary);
  border-color: var(--chatbot-primary);
  color: var(--chatbot-white);
  transform: translateX(4px);
}

.suggestion-btn i {
  font-size: 0.75rem;
  opacity: 0.6;
  transition: var(--chatbot-transition);
}

.suggestion-btn:hover i {
  opacity: 1;
  transform: translateX(2px);
}

/* ========================================
   TYPING INDICATOR
   ======================================== */

.typing-indicator {
  display: none;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0 1.5rem 1rem;
  animation: slideInLeft 0.3s ease-out;
}

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

.typing-bubble {
  background: var(--chatbot-white);
  padding: 1rem 1.25rem;
  border-radius: 1rem 1rem 1rem 0.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--chatbot-gray-200);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots .dot {
  width: 8px;
  height: 8px;
  background: var(--chatbot-primary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

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

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

.typing-text {
  font-size: 0.875rem;
  color: var(--chatbot-gray-500);
  font-style: italic;
}

/* ========================================
   CHAT INPUT
   ======================================== */

.chat-input-wrapper {
  background: var(--chatbot-white);
  border-top: 1px solid var(--chatbot-gray-200);
}

.chat-input {
  padding: 1.25rem;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: var(--chatbot-gray-100);
  border-radius: 1.5rem;
  padding: 0.5rem;
  border: 2px solid transparent;
  transition: var(--chatbot-transition);
}

.input-container:focus-within {
  border-color: var(--chatbot-primary);
  background: var(--chatbot-white);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  outline: none;
  resize: none;
  color: var(--chatbot-gray-700);
}

.chat-input input::placeholder {
  color: var(--chatbot-gray-400);
}

.send-button {
  background: var(--chatbot-gradient);
  border: none;
  color: var(--chatbot-white);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--chatbot-transition);
  flex-shrink: 0;
}

.send-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

/* ========================================
   STATUS MESSAGE
   ======================================== */

.status-message {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--chatbot-gray-800);
  color: var(--chatbot-white);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  opacity: 0;
  visibility: hidden;
  transition: var(--chatbot-transition);
}

.status-message.show {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .chatbot-trigger {
    bottom: 1.5rem;
    right: 1.5rem;
  }
  
  .chatbot-icon {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
  }
  
  .chatbot-tooltip {
    display: none;
  }
  
  .chat-container {
    width: calc(100vw - 2rem);
    max-width: 100vw;
    right: 1rem;
    bottom: 80px;
    max-height: calc(100vh - 100px);
  }
  
  .chat-messages {
    padding: 1rem;
  }
  
  .chat-input {
    padding: 1rem;
  }
  
  .suggestion-btn {
    padding: 1rem;
    font-size: 0.875rem;
  }
  
  .message-content {
    padding: 0.875rem 1rem;
  }
}

@media (max-width: 768px) {
  .chat-container {
    width: calc(100vw - 2rem);
    max-width: 100vw;
    right: 1rem;
    bottom: 80px;
    max-height: calc(100vh - 120px);
    min-height: 280px;
  }
  
  .chat-messages {
    padding: 1rem;
    max-height: calc(100vh - 250px);
  }
}

@media (max-width: 480px) {
  .chat-container {
    width: 100vw;
    max-height: 90vh;
    right: 0;
    bottom: 0;
    border-radius: 0;
    position: fixed;
    top: 0;
    left: 0;
  }
  
  .chat-header {
    padding: 1rem;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  }
  
  .chat-messages {
    max-height: calc(90vh - 160px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: auto;
  }
  
  .chat-input-wrapper {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}