:root {
  --cb-primary: #1e3a8a;
  --cb-primary-light: #2563eb;
  --cb-accent: #f59e0b;
  --cb-success: #10b981;
  --cb-bg: #ffffff;
  --cb-surface: #f8fafc;
  --cb-text: #0f172a;
  --cb-muted: #64748b;
  --cb-border: #e2e8f0;
  --cb-radius-xl: 24px;
  --cb-radius-lg: 16px;
  --cb-radius-md: 12px;
  --cb-shadow-xl: 0 25px 50px -12px rgba(15, 23, 42, 0.15);
  --cb-shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1);
  --cb-shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
}

.chatbot-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary-light) 0%, var(--cb-primary) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: var(--cb-shadow-xl);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 10;
}

.chatbot-toggle:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 30px 60px -15px rgba(15, 23, 42, 0.25);
}

.chatbot-toggle:active {
  transform: scale(0.98);
}

.chatbot-toggle i {
  font-size: 24px;
}

.chat-notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(118, 75, 162, 0.4);
  animation: pulse-badge 2s ease-in-out infinite;
  display: none;
}

@keyframes pulse-badge {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.9;
  }
}

.chatbot-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  height: 560px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--cb-radius-xl);
  box-shadow: var(--cb-shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.chatbot-panel:not([style*="display:none"]) {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chatbot-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--cb-primary-light) 0%, var(--cb-primary) 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.chatbot-logo-container {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-logo-icon {
  height: 28px;
  width: auto;
}

.chatbot-header-text {
  flex: 1;
  min-width: 0;
}

.chatbot-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.chatbot-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.3;
  margin-top: 2px;
}

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatbot-header-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.05);
}

.chatbot-header-btn:active {
  transform: scale(0.95);
}

.chatbot-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--cb-border);
  border-radius: 999px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}

.chat-message {
   max-width: 85%;
   padding: 12px 16px;
   border-radius: var(--cb-radius-lg);
   font-size: 14px;
   line-height: 1.5;
   word-wrap: break-word;
   white-space: pre-wrap;
}

.chat-message.ai {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.06) 0%, rgba(37, 99, 235, 0.06) 100%);
  border: 1px solid rgba(30, 58, 138, 0.1);
  color: var(--cb-text);
  border-bottom-left-radius: 4px;
}

.chat-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--cb-primary-light) 0%, var(--cb-primary) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chatbot-input-row {
  padding: 16px 20px;
  background: #fff;
  border-top: 1px solid var(--cb-border);
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chatbot-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--cb-border);
  background: var(--cb-surface);
  color: var(--cb-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chatbot-icon-btn:hover {
  background: #e2e8f0;
  color: var(--cb-text);
  border-color: #cbd5e1;
}

.chatbot-icon-btn.active {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.1) 0%, rgba(37, 99, 235, 0.1) 100%);
  color: var(--cb-primary-light);
  border-color: rgba(37, 99, 235, 0.3);
}

.chatbot-icon-btn.listening {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border-color: #ef4444;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

#chat-input {
  flex: 1;
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius-lg);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  background: var(--cb-surface);
  color: var(--cb-text);
  max-height: 100px;
  min-height: 40px;
  transition: all 0.2s ease;
}

#chat-input:focus {
  border-color: var(--cb-primary-light);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

#chat-input::placeholder {
  color: var(--cb-muted);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--cb-primary-light) 0%, var(--cb-primary) 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px -6px rgba(37, 99, 235, 0.4);
}

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

/* Fullscreen mode */
.chatbot-widget.chat-fullscreen {
  right: 0;
  bottom: 0;
  left: 0;
  top: 0;
}

.chatbot-widget.chat-fullscreen .chatbot-toggle {
  display: none;
}

.chatbot-widget.chat-fullscreen .chatbot-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .chatbot-widget {
    right: 16px;
    bottom: 16px;
  }

  .chatbot-panel {
    width: calc(100vw - 32px);
    right: 0;
    bottom: 80px;
    max-height: 70vh;
  }

  .chatbot-toggle {
    width: 56px;
    height: 56px;
  }
}
