:root {
  --primary-blue: #1877f2;
  --primary-blue-hover: #166fe5;
  --bg-chat: #ffffff;
  --text-dark: #1c1e21;
  --text-gray: #65676b;
  --text-light: #90949c;
  --msg-user: #1877f2;
  --msg-bot: #f0f2f5;
  --border-light: #e4e6eb;
  
  /* Premium effects */
  --glow-shadow: 0 10px 25px rgba(24, 119, 242, 0.25);
  --widget-shadow: 0 15px 50px rgba(0, 0, 0, 0.18);
  --glass-bg: rgba(255, 255, 255, 0.98);
}

/* Scoped Chat Widget Reset */
.chat-launcher,
.chat-widget,
.chat-widget * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* Floating Launcher Badge (Circular Bot + Talk to us Pill) */
.chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 2147483647;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: floatBadge 3.5s ease-in-out infinite;
}

@media (max-width: 480px) {
  .chat-launcher {
    bottom: 110px;
  }
}

.chat-launcher-icon-wrapper {
  width: 62px;
  height: 62px;
  min-width: 62px;
  min-height: 62px;
  flex-shrink: 0;
  background: #3b82f6; /* Circular blue background */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.25);
  border: 2px solid #ffffff;
  transition: transform 0.3s ease;
  overflow: hidden;
}

.chat-launcher-icon-wrapper img {
  width: 75%;
  height: 75%;
  object-fit: contain;
}

.chat-launcher-text-pill {
  background: #f59e0b; /* Yellow pill background */
  color: #ffffff;
  padding: 5px 14px;
  border-radius: 30px;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
  transition: all 0.3s ease;
}

.chat-launcher:hover .chat-launcher-icon-wrapper {
  transform: scale(1.08) translateY(-2px);
}

.chat-launcher:hover .chat-launcher-text-pill {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
}

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

/* Chatbot Widget Container - Bottom Right Floating Mini Card */
.chat-widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 580px;
  background: var(--bg-chat);
  border-radius: 20px;
  box-shadow: var(--widget-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  
  /* 3D Entrance Animations from Bottom Right */
  transform-origin: bottom right;
  transform: scale(0);
  opacity: 0;
  visibility: hidden;
  transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-widget.active {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
}

/* Widget Header */
.widget-header {
  background: var(--primary-blue);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

/* Navigation Tabs */
.tabs-container {
  display: flex;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 30px;
  padding: 2px;
  width: 100%;
  max-width: 160px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.tab-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* Close button */
.close-widget-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.close-widget-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Header Title Info */
.header-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title-info {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.header-subtitle {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.online-dot {
  width: 6px;
  height: 6px;
  background-color: #31a24c;
  border-radius: 50%;
  display: inline-block;
}

/* Message Area */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.messages-container::-webkit-scrollbar {
  width: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 2px;
}

/* Messages */
.message-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  animation: messagePop 0.25s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
  opacity: 0;
  transform: translateY(8px);
}

@keyframes messagePop {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-row.user {
  align-items: flex-end;
}

.message-row.bot {
  align-items: flex-start;
}

.sender-label {
  font-size: 0.68rem;
  color: var(--text-light);
  margin-bottom: 2px;
  margin-left: 44px;
}

.message-row.user .sender-label {
  margin-left: 0;
  margin-right: 6px;
}

.bubble-wrapper {
  display: flex;
  gap: 8px;
  max-width: 85%;
}

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

.bot-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.message-bubble img.message-attached-img {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 6px;
  display: block;
}

.message-bubble audio {
  width: 100%;
  max-width: 200px;
  height: 30px;
  margin-bottom: 6px;
  display: block;
}

.message-row.user .message-bubble {
  background: var(--msg-user);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.message-row.bot .message-bubble {
  background: var(--msg-bot);
  color: var(--text-dark);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.01);
}

.status-label {
  font-size: 0.65rem;
  color: var(--text-light);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: flex-end;
  width: 100%;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  align-items: center;
}

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

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

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

/* Input Area Container */
.input-area-container {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* Attachment Preview Bar */
.attachment-preview-bar {
  display: flex;
  gap: 10px;
  padding: 8px 16px 0 16px;
  overflow-x: auto;
}

.attachment-preview-bar:empty {
  display: none;
}

.preview-item {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--msg-bot);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item.audio-preview {
  font-size: 1.3rem;
}

.remove-preview-btn {
  position: absolute;
  top: 1px;
  right: 1px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 8px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Input Footer */
.input-footer {
  padding: 8px 16px 4px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.action-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-gray);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.action-icon-btn:hover {
  background: var(--msg-bot);
  color: var(--primary-blue);
}

.action-icon-btn.recording {
  color: #ef4444;
  animation: pulseRecording 1.5s infinite;
  background: rgba(239, 68, 68, 0.1);
}

@keyframes pulseRecording {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

.action-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.input-box {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.9rem;
  color: var(--text-dark);
  resize: none;
  max-height: 70px;
  padding: 6px 0;
}

.input-box::placeholder {
  color: var(--text-light);
}

.send-btn {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn.active {
  color: var(--primary-blue);
}

.send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Branding Footer */
.branding-footer {
  text-align: center;
  font-size: 0.72rem;
  color: #1877f2;
  padding: 8px 0;
  background: #f0f8ff;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-top: 1px solid rgba(24, 119, 242, 0.08);
  flex-shrink: 0;
}

/* Quick Action Reply Chips Container */
.quick-replies-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  width: 100%;
  animation: messagePop 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

.quick-reply-btn {
  background: #ffffff;
  color: #1877f2;
  border: 1px solid rgba(24, 119, 242, 0.28);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  align-items: center;
  gap: 4px;
}

.quick-reply-btn:hover {
  background: #1877f2;
  color: #ffffff;
  border-color: #1877f2;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(24, 119, 242, 0.2);
}

/* Premium Helpdesk Container Styles */
.helpdesk-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  overflow-y: auto;
}

.helpdesk-header-title {
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border-light);
  background: #f8fafc;
  display: flex;
  align-items: center;
}

.helpdesk-steps {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.helpdesk-step-card {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.helpdesk-step-card:hover {
  border-color: #1877f2;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(24, 119, 242, 0.08);
}

.step-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-right: 14px;
  flex-shrink: 0;
}

.step-icon.blue { background: rgba(24, 119, 242, 0.08); }
.step-icon.green { background: rgba(54, 179, 126, 0.08); }
.step-icon.purple { background: rgba(101, 84, 192, 0.08); }
.step-icon.orange { background: rgba(255, 139, 0, 0.08); }

.step-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-dark);
}

.step-desc {
  font-size: 0.76rem;
  color: var(--text-gray);
  line-height: 1.35;
}

.step-arrow {
  color: #a0aec0;
  font-size: 0.95rem;
  margin-left: 10px;
  transition: transform 0.2s ease;
}

.helpdesk-step-card:hover .step-arrow {
  color: #1877f2;
  transform: translateX(3px);
}

.helpdesk-footer {
  padding: 14px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--border-light);
}

.footer-prompt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.footer-icon {
  font-size: 1.15rem;
}

.footer-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--text-gray);
}

.footer-text strong {
  color: var(--text-dark);
}

/* Media Query: Perfectly Centered responsive window layout for Mobile */
@media (max-width: 600px) {
  .chat-launcher {
    bottom: 110px;
    right: 16px;
  }
  
  .chat-widget {
    top: auto;
    left: auto;
    width: calc(100% - 32px);
    max-width: 400px;
    height: 75vh;
    max-height: 600px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    bottom: 90px;
    right: 16px;
    transform: scale(0);
    transform-origin: bottom right;
  }
  
  .chat-widget.active {
    transform: scale(1);
  }

  .widget-header {
    padding: 14px 16px;
    gap: 6px;
    border-radius: 0;
  }

  .header-title {
    font-size: 1.1rem;
  }

  .tabs-container {
    max-width: 140px;
  }

  .tab-btn {
    padding: 4px 6px;
    font-size: 0.72rem;
  }
  
  .messages-container {
    padding: 16px;
    gap: 16px;
  }

  .message-bubble {
    font-size: 0.88rem;
    padding: 10px 14px;
  }
  
  .input-footer {
    padding: 10px 16px;
  }
  
  .branding-footer {
    padding: 0 0 10px 0;
  }
}
