/* ==========================================================================
   ONEBIT SOLUTIONS - LIVE CHAT WIDGET STYLES (chat-widget.css)
   Thiết kế khung chat chuẩn UI/UX cao cấp, đồng bộ nhận diện OneBit Solutions
   ========================================================================== */

.onebit-chat-widget {
  position: fixed;
  bottom: 35px;
  right: 105px;
  width: 380px;
  max-width: calc(100vw - 30px);
  height: 560px;
  max-height: calc(100vh - 90px);
  background: #ffffff;
  border-radius: 22px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18), 0 4px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1050;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  animation: chatSlideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes chatSlideInUp {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 1. Header */
.chat-widget-header {
  background: linear-gradient(135deg, #00bba7 0%, #008778 100%);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 14px rgba(0, 187, 167, 0.25);
  position: relative;
  z-index: 2;
}

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

.chat-avatar-wrapper {
  position: relative;
  width: 42px;
  height: 42px;
}

.chat-avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  padding: 4px;
}

.chat-avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: chatPulseGreen 2s infinite ease-in-out;
}

@keyframes chatPulseGreen {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
  }
}

.chat-header-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.chat-header-status {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

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

.chat-btn-action {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.1rem;
}

.chat-btn-action:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* 2. Messages Container */
.chat-widget-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-widget-body::-webkit-scrollbar {
  width: 5px;
}

.chat-widget-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.chat-date-divider {
  text-align: center;
  margin: 4px 0 8px;
}

.chat-date-divider span {
  font-size: 0.72rem;
  color: #94a3b8;
  background: #e2e8f0;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

/* Message Rows */
.chat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 90%;
  animation: fadeInBubble 0.25s ease forwards;
}

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

.msg-incoming {
  align-self: flex-start;
}

.msg-outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chat-msg-bubble-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.msg-outgoing .chat-msg-bubble-group {
  align-items: flex-end;
}

.chat-msg-bubble {
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  border-radius: 16px;
  word-break: break-word;
}

.msg-incoming .chat-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.msg-outgoing .chat-msg-bubble {
  background: linear-gradient(135deg, #00bba7 0%, #009383 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 187, 167, 0.25);
}

.chat-msg-time {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 2px;
  padding: 0 4px;
}

/* Quick Suggestion Chips */
.chat-suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 36px;
  margin-top: 4px;
}

.chat-chip {
  background: #ffffff;
  border: 1px solid #00bba7;
  color: #008778;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 187, 167, 0.08);
}

.chat-chip:hover {
  background: #00bba7;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 187, 167, 0.2);
}

/* Typing Indicator */
.chat-typing-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
  margin-top: 2px;
}

.chat-typing-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00bba7;
  display: inline-block;
  animation: typingBounce 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 typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* 3. Lead Contact Bar */
.chat-lead-info-bar {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-lead-prompt {
  font-size: 0.74rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.chat-lead-inputs {
  display: flex;
  gap: 6px;
}

.chat-lead-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.chat-lead-input:focus {
  border-color: #00bba7;
  background: #ffffff;
}

/* 4. Footer Input */
.chat-widget-footer {
  padding: 12px 14px 10px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

.chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: all 0.2s ease;
}

.chat-input-form:focus-within {
  border-color: #00bba7;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 187, 167, 0.12);
}

.chat-input-field {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.88rem;
  color: #1e293b;
  resize: none;
  max-height: 80px;
  padding: 6px 0;
  line-height: 1.4;
  font-family: inherit;
}

.chat-input-field::placeholder {
  color: #94a3b8;
  font-size: 0.84rem;
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #00bba7 0%, #009383 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 187, 167, 0.3);
}

.chat-send-btn:hover {
  transform: scale(1.06);
  background: #008778;
}

.chat-footer-brand {
  margin-top: 6px;
  text-align: center;
  font-size: 0.7rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Floating Quick Bar Chat Button active badge */
.chat-badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.btn-floating-chat.active {
  background: #00bba7 !important;
  color: #ffffff !important;
  box-shadow: 0 10px 24px rgba(0, 187, 167, 0.4) !important;
}

.btn-floating-chat.active i {
  color: #ffffff !important;
}

/* Mobile responsive */
@media (max-width: 575.98px) {
  .onebit-chat-widget {
    right: 12px;
    left: 12px;
    bottom: 85px;
    width: auto;
    max-width: none;
    height: calc(100vh - 120px);
    max-height: 540px;
    border-radius: 18px;
  }
}
