/* ===== AI Chatbot Widget - RIGHT Side ===== */
.chatbot-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 998;
}

.chatbot-toggle {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.3s;
  box-shadow: 0 6px 24px rgba(251, 191, 36, 0.35);
  position: relative;
  animation: chatPulse 3s infinite;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
}

.chatbot-toggle.active {
  background: var(--bg-surface2);
  border: 2px solid var(--accent-cyan);
  animation: none;
}

.chatbot-icon {
  font-size: 1.8rem;
}

.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes chatPulse {

  0%,
  100% {
    box-shadow: 0 6px 24px rgba(248, 189, 39, 0.35);
  }

  50% {
    box-shadow: 0 6px 40px rgba(251, 191, 36, 0.6), 0 0 0 12px rgba(251, 191, 36, 0.1);
  }
}

.chatbot-window {
  position: absolute;
  bottom: 75px;
  right: 0;
  width: 380px;
  max-height: 520px;
  border-radius: 20px;
  background: var(--bg-surface1);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: none;
  flex-direction: column;
  animation: scaleIn 0.3s ease;
}

/* Video Container */
#chatbot-video-container {
  border-bottom: 1px solid var(--glass-border);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { height: 0; opacity: 0; }
  to { height: auto; opacity: 1; }
}

#chatbot-remote-video {
  background: #000;
}

/* Screen share button always visible in header */
.chatbot-screen-btn {
  background: none !important;
  border: none !important;
  font-size: 1.2rem;
  cursor: pointer;
  color: #fff;
  transition: transform 0.2s, color 0.2s;
  padding: 4px;
  display: inline-block !important;
}

.chatbot-screen-btn:hover {
  transform: scale(1.15);
  color: var(--accent-cyan, #fbbf24);
}

/* Chatbot call button hover */
.chatbot-call-btn:hover {
  transform: scale(1.15);
  color: var(--accent-cyan, #fbbf24) !important;
}

/* Enlarge button on video */
#chatbot-video-container button:hover {
  background: rgba(255,255,255,0.3) !important;
  transform: scale(1.1);
}

.chatbot-window.open {
  display: flex;
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.chatbot-header {
  padding: 16px 20px;
  background: var(--bg-surface2);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.chatbot-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.chatbot-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--success);
}

.chatbot-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: 0.2s;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.chatbot-intro {
  padding: 24px;
}

.chatbot-name-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--bg-surface2);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  outline: none;
  display: block;
}

.chatbot-name-input:focus {
  border-color: var(--accent-cyan);
}

.chatbot-start-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--gradient-main);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  margin-top: 16px;
  transition: 0.3s;
}

.chatbot-start-btn:hover {
  box-shadow: 0 6px 20px rgba(251, 191, 36, 0.4);
  transform: translateY(-2px);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 280px;
  max-height: 340px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-cyan) transparent;
}

.chat-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: flex-end;
  animation: fadeInUp 0.3s ease;
}

.chat-msg.user-msg {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.chat-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.bot-bubble {
  background: var(--bg-surface2);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
  color: var(--text-secondary);
}

.user-bubble {
  background: var(--gradient-main);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Agent messages */
.agent-bubble {
  background: linear-gradient(135deg, #d97706, #fef08a);
  color: #fff;
  border-bottom-left-radius: 4px;
}

.typing-indicator .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  margin: 0 2px;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-8px);
  }
}

@keyframes fadeInUp {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.chatbot-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--glass-border);
  background: var(--bg-surface2);
}

.chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  outline: none;
}

.chatbot-input:focus {
  border-color: var(--accent-cyan);
}

.chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gradient-main);
  border: none;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
}

/* Branch card extra */
.branch-card-hq {
  border-color: rgba(251, 191, 36, 0.3) !important;
}

.branch-card-hq::before {
  content: 'HQ';
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--gradient-main);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.branch-type-label {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 12px;
}

.branch-type-hq {
  background: rgba(251, 191, 36, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.branch-type-branch {
  background: rgba(217, 119, 6, 0.1);
  color: var(--accent-purple);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

/* Auto-open hint */
.chatbot-hint {
  position: absolute;
  bottom: 75px;
  right: 5px;
  background: var(--bg-surface2);
  border: 1px solid var(--glass-border);
  border-radius: 14px 14px 0 14px;
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-primary);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: hintSlide 0.4s ease;
  max-width: 220px;
}

.chatbot-hint::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--bg-surface2);
}

@keyframes hintSlide {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Responsive chatbot */
@media(max-width:480px) {
  .chatbot-window {
    width: calc(100vw - 40px);
    right: 0;
    bottom: 70px;
  }

  .chatbot-widget {
    right: 16px;
    bottom: 16px;
  }

  .chatbot-hint {
    max-width: 180px;
  }
}