/* ==========================================================================
   Premium AI Chatbot Widget Stylesheet
   ========================================================================== */

/* Design Tokens & Theme Support */
:root {
  --cb-primary: var(--primary, #6366f1);
  --cb-primary-rgb: 16, 185, 129;
  --cb-secondary: var(--secondary, #06b6d4);
  --cb-accent: var(--accent, #6366f1);
  --cb-bg: var(--background, #ffffff);
  --cb-text: var(--text, #1f2937);
  --cb-text-muted: #6b7280;
  --cb-border: var(--border, #f3f4f6);
  --cb-input-bg: #f9fafb;
  
  /* Glassmorphism Variables */
  --cb-glass-bg: rgba(255, 255, 255, 0.85);
  --cb-glass-blur: 16px;
  --cb-card-shadow: 0 20px 50px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.02);
  --cb-radius: 24px;
  --cb-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --cb-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Base Wrapper Reset to prevent site-wide inheritance conflicts */
.cb-chatbot-root {
  font-family: var(--cb-font);
  color: var(--cb-text);
  box-sizing: border-box;
}
.cb-chatbot-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Floating Action Button (FAB) */
.cb-chatbot-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%);
  box-shadow: 0 10px 25px rgba(var(--cb-primary-rgb), 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 10000;
  transition: var(--cb-transition);
  border: none;
  outline: none;
}

.cb-chatbot-fab:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 15px 30px rgba(var(--cb-primary-rgb), 0.45);
}

.cb-chatbot-fab:active {
  transform: translateY(-2px) scale(0.98);
}

.cb-chatbot-fab i {
  color: #ffffff;
  font-size: 24px;
  transition: var(--cb-transition);
}

.cb-chatbot-fab.active i {
  transform: rotate(90deg);
}

/* Pulse Ring Animation around FAB */
.cb-chatbot-fab::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--cb-primary);
  opacity: 0.6;
  pointer-events: none;
  animation: cb-pulse-ring 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes cb-pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(0.95); opacity: 0; }
}

/* Notification Badge */
.cb-chatbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: var(--cb-accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
  border: 2px solid var(--cb-bg);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transform: scale(0);
  transition: var(--cb-transition);
}

.cb-chatbot-badge.visible {
  transform: scale(1);
}

/* Chatbox Window Container */
.cb-chatbot-card {
  position: fixed;
  bottom: 110px;
  right: 30px;
  width: 400px;
  height: 620px;
  background: var(--cb-glass-bg);
  backdrop-filter: blur(var(--cb-glass-blur));
  -webkit-backdrop-filter: blur(var(--cb-glass-blur));
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-card-shadow);
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transform: translateY(40px) scale(0.95);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cb-chatbot-card.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header UI */
.cb-chatbot-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cb-chatbot-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cb-chatbot-avatar-container {
  position: relative;
  width: 42px;
  height: 42px;
}

.cb-chatbot-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.cb-chatbot-status-dot {
  width: 10px;
  height: 10px;
  background-color: var(--cb-primary);
  border: 2px solid #1f2937;
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  right: 0;
  animation: cb-status-pulse 2s infinite;
}

@keyframes cb-status-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.cb-chatbot-header-info h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.cb-chatbot-header-info span {
  font-size: 11px;
  opacity: 0.75;
  display: block;
}

.cb-chatbot-header-actions {
  display: flex;
  gap: 8px;
}

.cb-chatbot-hdr-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  opacity: 0.7;
  transition: var(--cb-transition);
}

.cb-chatbot-hdr-btn:hover {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.1);
}

/* Chat Body (Scroll Logs) */
.cb-chatbot-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  background-color: rgba(249, 250, 251, 0.5);
}

/* Welcome Screen */
.cb-chatbot-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 0 20px 0;
  animation: cb-fade-in 0.4s ease forwards;
}

.cb-chatbot-welcome-logo {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  color: #ffffff;
  margin-bottom: 16px;
  box-shadow: 0 10px 20px rgba(var(--cb-primary-rgb), 0.2);
}

.cb-chatbot-welcome h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--cb-text);
}

.cb-chatbot-welcome p {
  font-size: 13.5px;
  color: var(--cb-text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
  max-width: 90%;
}

/* Quick Action Cards Grid */
.cb-chatbot-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

.cb-chatbot-quick-card {
  background: #ffffff;
  border: 1px solid var(--cb-border);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: var(--cb-transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01);
}

.cb-chatbot-quick-card:hover {
  transform: translateY(-3px);
  border-color: var(--cb-primary);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.04);
}

.cb-chatbot-quick-card i {
  font-size: 20px;
  color: var(--cb-primary);
}

.cb-chatbot-quick-card span {
  font-size: 13px;
  font-weight: 600;
  color: var(--cb-text);
}

.cb-chatbot-quick-card p {
  font-size: 11px;
  color: var(--cb-text-muted);
  margin: 0;
  line-height: 1.3;
}

/* Individual Message Styles */
.cb-chatbot-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: cb-message-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes cb-message-pop {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.cb-chatbot-msg.bot {
  align-self: flex-start;
}

.cb-chatbot-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cb-chatbot-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.cb-chatbot-msg-bubble-wrapper {
  display: flex;
  flex-direction: column;
}

.cb-chatbot-msg-bubble {
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  border-radius: 18px;
  word-break: break-word;
}

.cb-chatbot-msg.bot .cb-chatbot-msg-bubble {
  background-color: #ffffff;
  color: var(--cb-text);
  border-top-left-radius: 4px;
  border: 1px solid var(--cb-border);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.cb-chatbot-msg.user .cb-chatbot-msg-bubble {
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-secondary) 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 10px rgba(var(--cb-primary-rgb), 0.15);
}

.cb-chatbot-msg-time {
  font-size: 10px;
  color: var(--cb-text-muted);
  margin-top: 4px;
  margin-left: 4px;
}

.cb-chatbot-msg.user .cb-chatbot-msg-time {
  align-self: flex-end;
  margin-right: 4px;
  margin-left: 0;
}

/* Quick Suggestion Option Buttons under message bubbles */
.cb-chatbot-options-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  max-width: 100%;
}

.cb-chatbot-opt-btn {
  background-color: #ffffff;
  color: var(--cb-primary);
  border: 1px solid rgba(var(--cb-primary-rgb), 0.3);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--cb-transition);
  outline: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.cb-chatbot-opt-btn:hover {
  background-color: var(--cb-primary);
  color: #ffffff;
  border-color: var(--cb-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(var(--cb-primary-rgb), 0.15);
}

/* Date Separator */
.cb-chatbot-date-separator {
  align-self: center;
  font-size: 11px;
  color: var(--cb-text-muted);
  background-color: var(--cb-border);
  padding: 4px 12px;
  border-radius: 12px;
  margin: 10px 0;
  font-weight: 500;
}

/* Animated Typing Indicator */
.cb-chatbot-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background-color: #ffffff;
  border-radius: 18px;
  border-top-left-radius: 4px;
  border: 1px solid var(--cb-border);
  align-self: flex-start;
  margin-left: 42px;
  margin-bottom: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
  display: none;
}

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

.cb-chatbot-dot {
  width: 6px;
  height: 6px;
  background-color: var(--cb-text-muted);
  border-radius: 50%;
  animation: cb-bounce 1.4s infinite ease-in-out both;
}

.cb-chatbot-dot:nth-child(1) { animation-delay: -0.32s; }
.cb-chatbot-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Footer UI & Input Area */
.cb-chatbot-footer {
  padding: 16px 20px;
  background-color: #ffffff;
  border-top: 1px solid var(--cb-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cb-chatbot-input-container {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background-color: var(--cb-input-bg);
  border: 1px solid var(--cb-border);
  border-radius: 18px;
  padding: 8px 12px;
  transition: var(--cb-transition);
}

.cb-chatbot-input-container:focus-within {
  border-color: var(--cb-primary);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(var(--cb-primary-rgb), 0.1);
}

.cb-chatbot-textarea {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--cb-text);
  max-height: 100px;
  min-height: 20px;
  line-height: 1.5;
  padding-top: 2px;
}

/* Action Control Icons */
.cb-chatbot-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.cb-chatbot-control-group {
  display: flex;
  gap: 4px;
}

.cb-chatbot-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--cb-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--cb-transition);
  font-size: 15px;
}

.cb-chatbot-ctrl-btn:hover {
  color: var(--cb-primary);
  background-color: var(--cb-border);
}

.cb-chatbot-send-btn {
  background-color: var(--cb-primary);
  color: #ffffff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--cb-transition);
  box-shadow: 0 4px 10px rgba(var(--cb-primary-rgb), 0.2);
}

.cb-chatbot-send-btn:hover {
  background-color: var(--cb-secondary);
  transform: scale(1.05);
}

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

/* Animations helpers */
@keyframes cb-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive Configurations */
@media (max-width: 500px) {
  .cb-chatbot-fab {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }
  .cb-chatbot-card {
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    height: 80vh;
    border-radius: 20px;
  }
}
