/**
 * Bricks WhatsApp Chat Widget Styles
 * High Converting, Responsive & Fluid Micro-interactions
 */

:root {
  --bwc-theme: #25d366;
  --bwc-header-bg: #075e54;
  --bwc-text-dark: #111827;
  --bwc-text-muted: #6b7280;
  --bwc-bg-chat: #efeae2;
  --bwc-shadow: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1);
  --bwc-font: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Container */
.bwc-whatsapp-container {
  --bwc-bottom: 24px;
  --bwc-side: 24px;
  position: fixed;
  z-index: 999999;
  font-family: var(--bwc-font);
  box-sizing: border-box;
}

.bwc-whatsapp-container * {
  box-sizing: border-box;
}

/* Positions with 4-corner responsive flexibility */
.bwc-whatsapp-container.bwc-pos-bottom-right {
  top: auto;
  bottom: var(--bwc-bottom, 24px);
  left: auto;
  right: var(--bwc-side, 24px);
}

.bwc-whatsapp-container.bwc-pos-bottom-left {
  top: auto;
  bottom: var(--bwc-bottom, 24px);
  right: auto;
  left: var(--bwc-side, 24px);
}

.bwc-whatsapp-container.bwc-pos-top-right {
  bottom: auto;
  top: var(--bwc-bottom, 24px);
  left: auto;
  right: var(--bwc-side, 24px);
}

.bwc-whatsapp-container.bwc-pos-top-left {
  bottom: auto;
  top: var(--bwc-bottom, 24px);
  right: auto;
  left: var(--bwc-side, 24px);
}

/* Popup placement depending on corner */
.bwc-whatsapp-container.bwc-pos-top-right .bwc-chat-popup,
.bwc-whatsapp-container.bwc-pos-top-left .bwc-chat-popup {
  bottom: auto;
  top: 72px;
}

.bwc-whatsapp-container.bwc-pos-bottom-left .bwc-chat-popup,
.bwc-whatsapp-container.bwc-pos-top-left .bwc-chat-popup {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

.bwc-whatsapp-container.bwc-pos-top-left .bwc-chat-popup {
  transform-origin: top left;
}

.bwc-whatsapp-container.bwc-pos-top-right .bwc-chat-popup {
  transform-origin: top right;
}

/* Floating Trigger Button */
.bwc-floating-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bwc-theme);
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18), 0 2px 4px rgba(37, 211, 102, 0.3);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, background-color 0.2s ease;
  position: relative;
  outline: none;
  user-select: none;
}

.bwc-floating-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24), 0 4px 8px rgba(37, 211, 102, 0.4);
}

.bwc-floating-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.bwc-btn-icon-wrapper {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bwc-wa-svg {
  width: 32px;
  height: 32px;
  fill: #ffffff;
  display: block;
}

.bwc-btn-label {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  padding-right: 8px;
  white-space: nowrap;
}

/* Unread Badge */
.bwc-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  animation: bwc-badge-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bwc-badge-pop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Pulse Animation */
.bwc-floating-btn.bwc-pulse::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50px;
  background-color: var(--bwc-theme);
  transform: translate(-50%, -50%);
  z-index: -1;
  opacity: 0.6;
  animation: bwc-pulse-wave 2.2s infinite ease-out;
}

@keyframes bwc-pulse-wave {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.7;
  }
  70% {
    transform: translate(-50%, -50%) scale(1.45);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.45);
    opacity: 0;
  }
}

/* Chat Popup Modal */
.bwc-chat-popup {
  position: absolute;
  bottom: 74px;
  width: 360px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: var(--bwc-shadow);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  display: flex;
  flex-direction: column;
}

.bwc-pos-bottom-right .bwc-chat-popup {
  right: 0;
  transform-origin: bottom right;
}

.bwc-pos-bottom-left .bwc-chat-popup {
  left: 0;
  transform-origin: bottom left;
}

.bwc-whatsapp-container.bwc-open .bwc-chat-popup {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Popup Header */
.bwc-popup-header {
  background-color: var(--bwc-header-bg);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.bwc-agent-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bwc-avatar-wrapper {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.bwc-avatar-img,
.bwc-avatar-default {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background-color: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.bwc-avatar-default svg {
  width: 24px;
  height: 24px;
}

.bwc-status-indicator {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  background-color: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--bwc-header-bg);
}

.bwc-agent-meta {
  display: flex;
  flex-direction: column;
}

.bwc-agent-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.bwc-agent-title {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.3;
}

.bwc-agent-status {
  font-size: 11px;
  color: #86efac;
  margin-top: 2px;
}

.bwc-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background-color 0.2s;
}

.bwc-close-btn:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.15);
}

/* Popup Body */
.bwc-popup-body {
  background-color: var(--bwc-bg-chat);
  background-image: radial-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 0);
  background-size: 16px 16px;
  padding: 16px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Chat Message Bubble */
.bwc-chat-message-bubble {
  background: #ffffff;
  padding: 12px 14px;
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  position: relative;
  max-width: 90%;
  animation: bwc-bubble-in 0.3s ease-out;
}

@keyframes bwc-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bwc-bubble-header strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--bwc-text-dark);
  margin-bottom: 4px;
}

.bwc-bubble-content {
  font-size: 13.5px;
  line-height: 1.45;
  color: #374151;
}

.bwc-bubble-time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10.5px;
  color: #9ca3af;
  margin-top: 6px;
}

.bwc-check-icon {
  margin-left: 2px;
}

/* Quick Chips */
.bwc-quick-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.bwc-chips-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-left: 2px;
}

.bwc-chip-btn {
  display: block;
  text-decoration: none;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.bwc-chip-btn:hover {
  background-color: #f0fdf4;
  border-color: var(--bwc-theme);
  color: #15803d;
  text-decoration: none;
  transform: translateX(3px);
  box-shadow: 0 2px 4px rgba(37, 211, 102, 0.15);
}

/* Popup Footer Form */
.bwc-popup-footer {
  background: #f9fafb;
  padding: 12px 14px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.bwc-user-input {
  flex: 1;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1f2937;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.bwc-user-input:focus {
  border-color: var(--bwc-theme);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.bwc-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bwc-theme);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease;
}

.bwc-send-btn:hover {
  transform: scale(1.08);
  background-color: #1ebd5a;
}

.bwc-send-btn:active {
  transform: scale(0.95);
}

.bwc-send-btn svg {
  pointer-events: none;
}

/* Mobile Responsive Defaults */
@media (max-width: 480px) {
  .bwc-whatsapp-container {
    --bwc-bottom: 16px;
    --bwc-side: 16px;
  }
  .bwc-chat-popup {
    width: calc(100vw - 32px);
    max-width: 360px;
    bottom: 68px;
  }
}
