/* =====================================================
   BPBF Chat Widget — Shared Styles
   Uses CSS custom properties for per-version theming.
   Each version overrides --chat-* vars in their own CSS.
   ===================================================== */

/* ---- Default theme (V1 Navy/Gold) ---- */
:root {
  --chat-primary: #002868;
  --chat-primary-dark: #001D4A;
  --chat-accent: #D4A838;
  --chat-accent-light: #E8C55A;
  --chat-bg: #ffffff;
  --chat-bg-subtle: #F8F9FA;
  --chat-text: #1A1A2E;
  --chat-text-muted: #666666;
  --chat-bubble-bot: #F0F2F5;
  --chat-bubble-user: var(--chat-primary);
  --chat-bubble-user-text: #ffffff;
  --chat-radius: 20px;
  --chat-shadow: 0 12px 48px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
  --chat-bubble-shadow: 0 8px 32px rgba(0,40,104,0.2);
}

/* ---- Floating Bubble ---- */
.chat-bubble-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--chat-bubble-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
}
.chat-bubble-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(0,40,104,0.35);
}
.chat-bubble-btn:active {
  transform: scale(0.95);
}

/* Pulse ring */
.chat-bubble-btn::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--chat-accent);
  opacity: 0;
  animation: chat-pulse 2.5s ease-out infinite;
}
@keyframes chat-pulse {
  0% { opacity: 0.6; transform: scale(0.95); }
  70% { opacity: 0; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(1.3); }
}

/* Unread badge */
.chat-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: #E53E3E;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: chat-badge-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes chat-badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ---- Chat icon SVG ---- */
.chat-icon-open, .chat-icon-close {
  width: 28px;
  height: 28px;
  transition: all 0.3s ease;
}

/* ---- Chat Panel ---- */
.chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-height: 580px;
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);

  /* Entry animation */
  animation: chat-panel-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom right;
}
@keyframes chat-panel-in {
  0% { opacity: 0; transform: scale(0.85) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Mobile: full width */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 8px;
    max-height: calc(100vh - 16px);
    border-radius: 16px;
  }
  .chat-bubble-btn {
    bottom: 16px;
    right: 16px;
  }
}

/* ---- Chat Header ---- */
.chat-header {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Decorative mesh */
.chat-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(212,168,56,0.12) 0%, transparent 50%),
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.04) 0%, transparent 40%);
  pointer-events: none;
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--chat-accent);
  color: var(--chat-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
/* Online dot */
.chat-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #22C55E;
  border-radius: 50%;
  border: 2px solid var(--chat-primary);
}
.chat-header-info {
  position: relative;
  z-index: 1;
}
.chat-header-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.chat-header-status {
  font-size: 0.72rem;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-close-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  position: relative;
  z-index: 1;
}
.chat-close-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* ---- Messages Area ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 300px;
  max-height: 360px;
  background: var(--chat-bg-subtle);
  scroll-behavior: smooth;
}
/* Custom scrollbar */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }

/* ---- Message Bubbles ---- */
.chat-msg {
  max-width: 85%;
  animation: chat-msg-in 0.25s ease-out;
}
@keyframes chat-msg-in {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.chat-msg-bot {
  align-self: flex-start;
}
.chat-msg-bot .chat-msg-bubble {
  background: var(--chat-bg);
  color: var(--chat-text);
  border-radius: 4px 16px 16px 16px;
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.04);
}
.chat-msg-bot .chat-msg-bubble strong {
  color: var(--chat-primary);
  font-weight: 600;
}

.chat-msg-user {
  align-self: flex-end;
}
.chat-msg-user .chat-msg-bubble {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: var(--chat-bubble-user-text);
  border-radius: 16px 4px 16px 16px;
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  box-shadow: 0 2px 8px rgba(0,40,104,0.15);
}

.chat-msg-time {
  font-size: 0.65rem;
  color: var(--chat-text-muted);
  margin-top: 3px;
  padding: 0 2px;
}
.chat-msg-user .chat-msg-time {
  text-align: right;
}

/* ---- Typing Indicator ---- */
.chat-typing {
  align-self: flex-start;
  background: var(--chat-bg);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 18px;
  display: flex;
  gap: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.04);
}
.chat-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: chat-typing-bounce 1.2s ease-in-out infinite;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Quick Reply Buttons ---- */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  animation: chat-msg-in 0.3s ease-out;
}
.chat-quick-btn {
  background: var(--chat-bg);
  color: var(--chat-primary);
  border: 1.5px solid var(--chat-primary);
  border-radius: 100px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}
.chat-quick-btn:hover {
  background: var(--chat-primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,40,104,0.2);
}

/* WhatsApp green variant */
.chat-quick-btn-wa {
  border-color: #25D366;
  color: #25D366;
}
.chat-quick-btn-wa:hover {
  background: #25D366;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,211,102,0.3);
}

/* ---- Input Area ---- */
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(0,0,0,0.06);
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--chat-bg);
}
.chat-input {
  flex: 1;
  background: var(--chat-bg-subtle);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 100px;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  color: var(--chat-text);
}
.chat-input:focus {
  border-color: var(--chat-accent);
}
.chat-input::placeholder {
  color: var(--chat-text-muted);
}
.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.chat-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,40,104,0.3);
}
.chat-send-btn:active {
  transform: scale(0.95);
}

/* ---- Powered by footer ---- */
.chat-powered {
  text-align: center;
  padding: 6px;
  font-size: 0.6rem;
  color: var(--chat-text-muted);
  background: var(--chat-bg);
}
