/* Chatbot Styles - Isolated and self-contained */
.chatbot-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chat Button */
.chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #D4AF37;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.chat-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chat-button svg {
  width: 28px;
  height: 28px;
  fill: #0A1E30;
}

.unread-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  background-color: #ff4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

.unread-dot.active {
  display: block;
}

/* Chat Window */
.chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  height: 550px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

.chat-window.open {
  display: flex;
  animation: slideUp 0.3s ease;
}

.chat-window.maximized {
  width: 90vw;
  height: 90vh;
  bottom: 5vh;
  right: 5vw;
}

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

/* Chat Header */
.chat-header {
  background: #0A1E30;
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-title-dot {
  width: 10px;
  height: 10px;
  background: #4CAF50;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}

.chat-title-text {
  font-size: 16px;
  font-weight: 600;
}

.chat-controls {
  display: flex;
  gap: 8px;
}

.chat-controls button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-controls button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-controls svg {
  width: 18px;
  height: 18px;
}

.chat-close {
  font-size: 24px;
  line-height: 1;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
}

.message {
  margin-bottom: 16px;
  display: flex;
  animation: fadeIn 0.3s ease;
}

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

.message-user {
  justify-content: flex-end;
}

.message-bot {
  justify-content: flex-start;
}

.message-user > div,
.message-bot > div {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.5;
}

.message-user > div {
  background: #D4AF37;
  color: #0A1E30;
}

.message-bot > div {
  background: white;
  color: #0A1E30;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-bot a,
.message-user a {
  color: #0A1E30;
  font-weight: 600;
  text-decoration: underline;
}

.message-bot pre,
.message-user pre {
  background: #0A1E30;
  color: #f5f5f5;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 13px;
}

.message-bot code,
.message-user code {
  background: rgba(10, 30, 48, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 13px;
}

.message-bot pre code,
.message-user pre code {
  background: transparent;
  padding: 0;
}

.message-bot ul,
.message-bot ol,
.message-user ul,
.message-user ol {
  margin: 8px 0 8px 20px;
  padding: 0;
}

.message-bot li,
.message-user li {
  margin-bottom: 4px;
}

.gold-text {
  color: #D4AF37;
  font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: fit-content;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #ccc;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

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

/* Chat Input */
.chat-input {
  padding: 16px;
  background: white;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input input[type="text"] {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input input[type="text"]:focus {
  border-color: #D4AF37;
}

.chat-input button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-input button:hover {
  background: #f0f0f0;
}

.chat-input svg {
  width: 20px;
  height: 20px;
  fill: #666;
}

.send-button {
  background: #D4AF37 !important;
}

.send-button:hover {
  background: #c19f32 !important;
}

.send-button svg {
  fill: #0A1E30 !important;
}

/* Usage Info */
.usage-info {
  position: absolute;
  bottom: 60px;
  left: 16px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.usage-tokens {
  display: flex;
  gap: 8px;
}

.tokens-up {
  color: #4CAF50;
}

.tokens-down {
  color: #2196F3;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-window {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
  
  .chat-window.maximized {
    width: 100vw;
    height: 100vh;
  }
  
  .chat-button {
    bottom: 10px;
    right: 10px;
  }
}
