/* ==========================================================================
   VivaGifts Live Chat Widget CSS (Botflow Modern UI Reference)
   ========================================================================== */

@keyframes vg-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-6px);
  }
}

@keyframes vg-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(74, 222, 128, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
  }
}

/* Launcher Bubble Wrapper */
#vg-launcher-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  z-index: 2147483647;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#vg-launcher-wrap:hover {
  transform: scale(1.08);
}

#vg-launcher {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--vg-primary, #e11d48);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  transition: box-shadow 0.2s;
}

#vg-launcher:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

#vg-online-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  animation: vg-pulse 2s infinite;
}

/* Popout Teaser Tooltip */
#vg-popout {
  position: fixed;
  bottom: 94px;
  right: 24px;
  background: #ffffff;
  color: #1e293b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  border: 1px solid #f1f5f9;
  z-index: 2147483645;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

#vg-popout-arrow {
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  transform: rotate(45deg);
}

/* Main Chat Container Card */
#vg-chat-win {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 2147483646;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transform: scale(0.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

#vg-chat-win.vg-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
#vg-chat-header {
  background: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
  flex-shrink: 0;
}

.vg-header-home {
  padding: 24px 20px 20px !important;
  flex-direction: column !important;
  text-align: center;
  gap: 10px;
}

.vg-header-chat {
  padding: 14px 16px !important;
  flex-direction: row !important;
  gap: 10px;
}

.vg-avatar-lg {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: var(--vg-primary, #e11d48);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
  margin: 0 auto;
}

.vg-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--vg-primary, #e11d48);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.vg-header-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.vg-header-subtitle {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
}

.vg-btn-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  border-radius: 8px;
  transition: all 0.15s;
}

.vg-btn-close:hover {
  background: #f1f5f9;
  color: #334155;
}

.vg-btn-back {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  border-radius: 8px;
  margin-right: 4px;
  transition: all 0.15s;
}

.vg-btn-back:hover {
  background: #f1f5f9;
}

/* Home View Content */
#vg-home-view {
  flex: 1;
  overflow-y: auto;
  background: #f8fafc;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vg-start-card {
  background: #ffffff;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.vg-start-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.vg-start-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
}

.vg-btn-start {
  background: var(--vg-primary, #e11d48);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.2);
}

.vg-btn-start:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.vg-section-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.vg-conv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vg-conv-item {
  background: #ffffff;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
}

.vg-conv-item:hover {
  border-color: var(--vg-primary, #e11d48);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

/* Chat Messages View */
#vg-messages-view {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}

.vg-msg-row {
  display: flex;
  width: 100%;
}

.vg-msg-row-user {
  justify-content: flex-end;
}

.vg-msg-row-agent {
  justify-content: flex-start;
}

.vg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.vg-bubble-user {
  background: var(--vg-primary, #e11d48);
  color: #ffffff;
  border-bottom-right-radius: 3px;
}

.vg-bubble-agent {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 3px;
}

.vg-msg-img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.2s;
}

.vg-msg-img:hover {
  transform: scale(1.02);
}

/* Typing Indicator */
.vg-typing-bubble {
  padding: 10px 14px;
  border-radius: 16px 16px 16px 3px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.vg-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: vg-bounce 1.4s infinite ease-in-out both;
}

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

/* Input Bar */
#vg-chat-inputbar {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#vg-input-text {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 9999px;
  padding: 9px 16px;
  font-size: 14px;
  outline: none;
  background: #f8fafc;
  transition: border-color 0.15s, background-color 0.15s;
}

#vg-input-text:focus {
  border-color: var(--vg-primary, #e11d48);
  background: #ffffff;
}

.vg-btn-attach {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}

.vg-btn-attach:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.vg-btn-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--vg-primary, #e11d48);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.15s;
}

.vg-btn-send:hover {
  opacity: 0.92;
  transform: scale(1.05);
}

/* Footer / Powered By */
.vg-footer-brand {
  text-align: center;
  font-size: 10px;
  color: #94a3b8;
  padding: 6px 0 8px;
  background: #ffffff;
  flex-shrink: 0;
  border-top: 1px solid #fafafa;
}

.vg-footer-brand a {
  color: #64748b;
  text-decoration: none;
  font-weight: 600;
}

/* System Notice Badge */
.vg-notice-badge {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 9999px;
  text-align: center;
  margin: 4px auto;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  #vg-chat-win {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  #vg-launcher-wrap {
    bottom: 16px;
    right: 16px;
  }
}
