/* Star Invasion Astronaut Chatbot - Modern Design */

:root {
  /* Modern Color Palette */
  --primary: #6366f1;
  --primary-hover: #5b21b6;
  --secondary: #f59e0b;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --accent: #06b6d4;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  
  /* Glass morphism */
  --glass-bg: rgba(15, 23, 42, 0.85);
  --glass-border: rgba(255, 255, 255, 0.1);
  --backdrop-blur: blur(20px);
  
  /* Spacing & Sizing */
  --chatbot-width: 400px;
  --chatbot-height: 600px;
  --avatar-size: 60px;
  --border-radius: 20px;
  --border-radius-small: 12px;
  
  /* Shadows */
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 50px rgba(99, 102, 241, 0.3);
}

/* Container */
.star-invasion-chatbot-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
}

/* Avatar Button */
.chatbot-avatar {
  width: var(--avatar-size);
  height: var(--avatar-size);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-glow);
  overflow: hidden;
}

.chatbot-avatar::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: conic-gradient(from 0deg, var(--primary), var(--secondary), var(--accent), var(--primary));
  border-radius: 50%;
  z-index: -1;
  animation: rotate 4s linear infinite;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chatbot-avatar:hover::before {
  opacity: 1;
}

.chatbot-avatar:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 25px 50px rgba(99, 102, 241, 0.4);
}

.chatbot-avatar:active {
  transform: translateY(-2px) scale(1.02);
}

.chatbot-avatar svg {
  width: 58px;
  height: 58px;
  fill: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Chat Window */
.chatbot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: var(--chatbot-width);
  height: var(--chatbot-height);
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.9);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chatbot-window.visible {
  display: flex;
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Header */
.chatbot-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}

.chatbot-title {
  font-size: 16px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-title::before {
  content: "🚀";
  font-size: 20px;
}

/* Header buttons container */
.header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chatbot-close {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 14px;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Remove minimize button - not needed */
.chatbot-minimize {
  display: none;
}

/* Chat Body */
.chatbot-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chatbot-messages {
  flex: 1;
  padding: 20px;
  overflow-y: scroll !important;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--background);
  scroll-behavior: smooth;
  height: calc(100vh - 300px);
  max-height: 400px;
}

.chatbot-messages {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.chatbot-messages::-webkit-scrollbar {
  display: none; /* WebKit */
}

/* Message Bubbles */
.message {
  max-width: 85%;
  animation: messageSlide 0.3s ease;
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.25);
}

.message.assistant .message-content {
  background: var(--surface);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--surface-light);
}

.message.assistant.system-message .message-content {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--surface-light);
  font-style: italic;
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

.message.assistant .message-timestamp {
  text-align: left;
}

/* Footer/Input Area */
.chatbot-footer {
  background: var(--surface);
  border-top: 1px solid var(--surface-light);
  padding: 16px 20px;
}

.input-container {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chatbot-input-field {
  flex: 1;
  background: var(--background);
  border: 1px solid var(--surface-light);
  border-radius: var(--border-radius-small);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  transition: all 0.2s ease;
  min-height: 18px;
  max-height: 100px;
  line-height: 1.4;
  pointer-events: auto;
}

.chatbot-input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.chatbot-input-field::placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.chatbot-send-button {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  border-radius: var(--border-radius-small);
  padding: 0;
  color: white;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.chatbot-send-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.chatbot-send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.chatbot-send-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Hide helper text */
.input-help {
  display: none;
}

.char-counter {
  display: none;
}

.help-text {
  display: none;
}

/* Loading Indicator */
.loading-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  margin: 0 20px 16px 20px;
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  max-width: 200px;
  border: 1px solid var(--surface-light);
}

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
}

.loading-dots {
  display: flex;
  gap: 6px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: loadingBounce 1.4s infinite ease-in-out;
}

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

/* Avatar States */
.chatbot-avatar.thinking {
  animation: pulse 2s infinite;
}

.chatbot-avatar.talking {
  animation: bounce 0.8s infinite;
}

.chatbot-avatar.error {
  background: linear-gradient(135deg, var(--error), #dc2626);
}

/* Welcome Message */
.welcome-message {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--border-radius-small);
  border: 1px solid var(--surface-light);
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .star-invasion-chatbot-container {
    bottom: 20px;
    right: 20px;
    left: 20px;
  }
  
  .chatbot-window {
    width: 100%;
    height: 70vh;
    bottom: 80px;
    left: 0;
    right: 0;
  }
  
  .chatbot-header {
    padding: 20px;
  }
  
  .chatbot-messages {
    padding: 20px;
  }
  
  .chatbot-input-container {
    padding: 20px;
  }
}

/* Animations */
@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

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

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

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles */
.chatbot-avatar:focus,
.chatbot-close:focus,
.chatbot-input-field:focus,
.chatbot-send-button:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}