/* Chatbot Styles */
.chatbot-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Animated Popup */
.chatbot-popup {
  position: absolute;
  bottom: 70px;
  right: 0;
  background: white;
  color: #333;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  animation: popupBounce 0.6s ease-out, popupFloat 3s ease-in-out 0.6s infinite;
  white-space: nowrap;
  z-index: 9998;
}

.chatbot-popup.hidden {
  display: none;
}

.chatbot-popup-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-popup-emoji {
  font-size: 20px;
  animation: wave 1s ease-in-out infinite;
}

.chatbot-popup-text {
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chatbot-popup-arrow {
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: white;
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes popupBounce {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
  50% {
    transform: translateY(-5px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes wave {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(20deg);
  }
  75% {
    transform: rotate(-20deg);
  }
}

.chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  color: white;
  transition: transform 0.3s ease;
}

.chatbot-toggle.active svg {
  transform: rotate(180deg);
}

.chatbot-robot-icon {
  font-size: 32px;
  line-height: 1;
  transition: transform 0.3s ease;
  z-index: 1;
}

.chatbot-toggle.active .chatbot-robot-icon {
  transform: scale(1.1) rotate(10deg);
}

.chatbot-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.chatbot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: min(500px, 90vw);
  height: min(700px, 85vh);
  background: var(--bg-primary, #1e1e1e);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 1px solid var(--border-color, #333);
}

.chatbot-window.active {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.chatbot-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.chatbot-header-info {
  flex: 1;
}

.chatbot-header-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.chatbot-header-subtitle {
  font-size: 12px;
  opacity: 0.9;
  margin: 2px 0 0 0;
}

/* Mode Selector */
.chatbot-mode-selector {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary, #252526);
  border-bottom: 1px solid var(--border-color, #333);
}

.mode-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 2px solid var(--border-color, #444);
  border-radius: 8px;
  background: var(--bg-tertiary, #2d2d30);
  color: var(--text-secondary, #999);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 13px;
  font-weight: 600;
}

.mode-option:hover {
  border-color: #667eea;
  background: var(--bg-hover, #3e3e42);
  color: var(--text-primary, #e0e0e0);
}

.mode-option.active {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
  color: #667eea;
}

.mode-option svg {
  width: 18px;
  height: 18px;
}

.mode-option span {
  white-space: nowrap;
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-secondary, #252526);
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--border-color, #444);
  border-radius: 3px;
}

.chatbot-message {
  display: flex;
  gap: 10px;
  animation: messageSlideIn 0.3s ease;
}

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

.chatbot-message.user {
  flex-direction: row-reverse;
}

.chatbot-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.chatbot-message.assistant .chatbot-message-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.chatbot-message.user .chatbot-message-avatar {
  background: var(--accent-color, #4da3ff);
  color: white;
}

.chatbot-message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
}

.chatbot-message.assistant .chatbot-message-content {
  background: var(--bg-tertiary, #2d2d30);
  color: var(--text-primary, #e0e0e0);
  border-bottom-left-radius: 4px;
}

.chatbot-message.user .chatbot-message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.chatbot-message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chatbot-message-action {
  background: none;
  border: none;
  color: var(--text-secondary, #999);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-message-action:hover {
  color: var(--text-primary, #e0e0e0);
  background: var(--bg-tertiary, #2d2d30);
}

.chatbot-message-action svg {
  width: 16px;
  height: 16px;
}

.chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.chatbot-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary, #999);
  animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.chatbot-input-container {
  padding: 16px;
  background: var(--bg-primary, #1e1e1e);
  border-top: 1px solid var(--border-color, #333);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  position: relative;
}

.chatbot-input-container.voice-mode .chatbot-voice-btn,
.chatbot-input-container.voice-mode .chatbot-input-wrapper,
.chatbot-input-container.voice-mode .chatbot-send-btn {
  display: none;
}

.chatbot-input-container:not(.voice-mode) .chatbot-ptt-btn {
  display: none;
}

.chatbot-input-wrapper {
  flex: 1;
  position: relative;
}

.chatbot-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color, #444);
  border-radius: 24px;
  background: var(--bg-secondary, #252526);
  color: var(--text-primary, #e0e0e0);
  font-size: 14px;
  resize: none;
  max-height: 120px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.chatbot-input:focus {
  outline: none;
  border-color: #667eea;
}

.chatbot-input::placeholder {
  color: var(--text-secondary, #999);
}

.chatbot-voice-btn,
.chatbot-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-voice-btn {
  background: var(--bg-tertiary, #2d2d30);
  color: var(--text-primary, #e0e0e0);
}

.chatbot-voice-btn:hover {
  background: var(--bg-hover, #3e3e42);
}

.chatbot-voice-btn.recording {
  background: #ef4444;
  color: white;
  animation: recordingPulse 1s infinite;
}

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

.chatbot-send-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-voice-btn svg,
.chatbot-send-btn svg {
  width: 20px;
  height: 20px;
}

/* Push-to-Talk Button */
.chatbot-ptt-btn {
  width: 100%;
  height: 80px;
  border-radius: 16px;
  border: 2px solid var(--border-color, #444);
  background: var(--bg-tertiary, #2d2d30);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.chatbot-ptt-btn:hover {
  background: var(--bg-hover, #3e3e42);
  border-color: #667eea;
}

.chatbot-ptt-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  transform: scale(0.98);
}

.chatbot-ptt-btn svg {
  width: 28px;
  height: 28px;
  color: var(--text-primary, #e0e0e0);
  transition: all 0.2s;
}

.chatbot-ptt-btn.active svg {
  color: white;
  animation: pttPulse 1s ease-in-out infinite;
}

.ptt-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
  transition: all 0.2s;
}

.chatbot-ptt-btn.active .ptt-text {
  color: white;
}

.ptt-ripple {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: rgba(102, 126, 234, 0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.chatbot-ptt-btn.active .ptt-ripple {
  opacity: 1;
  animation: pttRipple 1.5s ease-out infinite;
}

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

@keyframes pttRipple {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

/* Stop Speaking Button */
.chatbot-stop-speaking {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border: none;
  border-radius: 24px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 1000;
}

.chatbot-stop-speaking.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

.chatbot-stop-speaking:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

.chatbot-stop-speaking:active {
  transform: translateX(-50%) translateY(0);
}

.chatbot-stop-speaking svg {
  width: 18px;
  height: 18px;
}

.chatbot-stop-speaking span {
  white-space: nowrap;
}

.chatbot-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary, #999);
}

.chatbot-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.chatbot-welcome-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
  margin-bottom: 8px;
}

.chatbot-welcome-text {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.chatbot-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

.chatbot-suggestion {
  padding: 12px 16px;
  background: var(--bg-tertiary, #2d2d30);
  border: 1px solid var(--border-color, #444);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: var(--text-primary, #e0e0e0);
  text-align: left;
}

.chatbot-suggestion:hover {
  background: var(--bg-hover, #3e3e42);
  border-color: #667eea;
  transform: translateX(4px);
}

.chatbot-error {
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #ef4444;
  font-size: 13px;
  margin: 8px 0;
}

/* Markdown Styling in Messages */
.chatbot-message-content h1,
.chatbot-message-content h2,
.chatbot-message-content h3,
.chatbot-message-content h4,
.chatbot-message-content h5,
.chatbot-message-content h6 {
  margin: 0.8em 0 0.4em 0;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary, #e0e0e0);
}

.chatbot-message-content h1 { font-size: 1.5em; }
.chatbot-message-content h2 { font-size: 1.3em; }
.chatbot-message-content h3 { font-size: 1.15em; }
.chatbot-message-content h4 { font-size: 1.05em; }
.chatbot-message-content h5 { font-size: 1em; }
.chatbot-message-content h6 { font-size: 0.95em; }

.chatbot-message-content h1:first-child,
.chatbot-message-content h2:first-child,
.chatbot-message-content h3:first-child,
.chatbot-message-content h4:first-child,
.chatbot-message-content h5:first-child,
.chatbot-message-content h6:first-child {
  margin-top: 0;
}

.chatbot-message-content p {
  margin: 0.5em 0;
  line-height: 1.6;
}

.chatbot-message-content p:first-child {
  margin-top: 0;
}

.chatbot-message-content p:last-child {
  margin-bottom: 0;
}

.chatbot-message-content ul,
.chatbot-message-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.chatbot-message-content li {
  margin: 0.3em 0;
  line-height: 1.5;
}

.chatbot-message-content code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
  color: #f8f8f2;
}

.chatbot-message-content pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.8em 0;
  border-left: 3px solid #667eea;
}

.chatbot-message-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.5;
  display: block;
}

.chatbot-message-content blockquote {
  border-left: 3px solid #667eea;
  padding-left: 12px;
  margin: 0.8em 0;
  color: var(--text-secondary, #999);
  font-style: italic;
}

.chatbot-message-content a {
  color: #667eea;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.chatbot-message-content a:hover {
  border-bottom-color: #667eea;
}

.chatbot-message-content strong {
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
}

.chatbot-message-content em {
  font-style: italic;
}

.chatbot-message-content hr {
  border: none;
  border-top: 1px solid var(--border-color, #444);
  margin: 1em 0;
}

.chatbot-message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
  font-size: 0.9em;
}

.chatbot-message-content th,
.chatbot-message-content td {
  border: 1px solid var(--border-color, #444);
  padding: 6px 10px;
  text-align: left;
}

.chatbot-message-content th {
  background: rgba(0, 0, 0, 0.3);
  font-weight: 600;
}

.chatbot-message-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 0.5em 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .chatbot-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    bottom: 70px;
    right: 10px;
  }
  
  .chatbot-toggle {
    width: 56px;
    height: 56px;
    bottom: 10px;
    right: 10px;
  }
  
  .chatbot-popup {
    bottom: 65px;
  }
  
  .mode-option span {
    font-size: 12px;
  }
  
  .mode-option {
    padding: 8px 12px;
  }
}

@media (max-width: 480px) {
  .mode-option span {
    display: none;
  }
  
  .mode-option {
    padding: 10px;
  }
  
  .mode-option svg {
    width: 20px;
    height: 20px;
  }
}
