/* Client Chatbot Widget CSS - TechSolutions S.A. */

/* Floating Chat Trigger Button */
#chatbot-trigger {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: var(--transition-bounce);
}

#chatbot-trigger:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 15px 35px hsla(var(--primary-hue), 80%, 60%, 0.45);
}

#chatbot-trigger svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  transition: var(--transition-smooth);
}

/* Chatbot Container */
#chatbot-container {
  position: fixed;
  bottom: 105px;
  right: 30px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 140px);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  transform: translateY(30px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-bounce);
}

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

/* Header */
.chat-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar-container {
  position: relative;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border: 2px solid white;
}

.chat-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background-color: var(--color-success);
  border: 2px solid white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.chat-header-text h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.chat-header-text p {
  font-size: 11px;
  opacity: 0.8;
  margin: 0;
}

.close-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  opacity: 0.7;
  transition: var(--transition-smooth);
}

.close-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Chat Status Notification (Human Escalation) */
.operator-status-alert {
  background-color: var(--color-primary-glow);
  color: var(--color-primary-dark);
  font-size: 13px;
  padding: 8px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(79, 70, 229, 0.1);
  display: none;
  font-weight: 500;
  animation: slideDown 0.3s forwards;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Chat Body / Messages Area */
.chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background-color: rgba(248, 250, 252, 0.5);
}

/* Custom Scrollbar */
.chat-body::-webkit-scrollbar {
  width: 6px;
}
.chat-body::-webkit-scrollbar-track {
  background: transparent;
}
.chat-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-full);
}
.chat-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* Messages */
.message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: fadeInBubble 0.3s ease-out forwards;
}

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

.message.bot {
  align-self: flex-start;
}

.message.client {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 80%;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary-glow);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
}

.message.client .message-avatar {
  background-color: var(--color-secondary-light);
  color: var(--color-secondary-dark);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  word-break: break-word;
}

.message.bot .message-bubble {
  background-color: white;
  color: #334155;
  border-top-left-radius: 4px;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.message.client .message-bubble {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.message-bubble strong {
  font-weight: 600;
}

.message-bubble ul {
  margin-left: 20px;
  margin-top: 5px;
}

/* Quick Reply Chips */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px 20px 15px 20px;
  background-color: rgba(248, 250, 252, 0.5);
}

.quick-reply-btn {
  background-color: white;
  border: 1px solid rgba(79, 70, 229, 0.2);
  color: var(--color-primary-dark);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-sans);
  font-weight: 500;
}

.quick-reply-btn:hover {
  background-color: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.15);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
  background-color: white;
  border-radius: var(--radius-md);
  border-top-left-radius: 4px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  width: fit-content;
  box-shadow: var(--shadow-sm);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #94a3b8;
  border-radius: var(--radius-full);
  animation: bounceDot 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 bounceDot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Chat Footer */
.chat-footer {
  padding: 15px 20px;
  background-color: white;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-full);
  padding: 12px 20px;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

.chat-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-bounce);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
  flex-shrink: 0;
}

.send-btn:hover {
  background-color: var(--color-primary-dark);
  transform: scale(1.05);
}

.send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  margin-left: 2px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  #chatbot-container {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  #chatbot-trigger {
    bottom: 20px;
    right: 20px;
  }
}
