/**
 * Built Africa Chatbot — Stylesheet v1.1.0
 * Plugin:  Built Africa Chatbot
 * Author:  ProspenTech (https://www.prospentech.co.za)
 */

/* ── CSS Custom Properties ─────────────────────────────── */
:root {
  --bac-green:        #BE1E2E;
  --bac-green-dark:   #961824;
  --bac-green-light:  #fbeced;
  --bac-green-mid:    #f5d0d3;
  --bac-amber:        #f4a825;
  --bac-amber-dark:   #d4891a;
  --bac-white:        #ffffff;
  --bac-bg:           #f4f7f5;
  --bac-text:         #1a1a1a;
  --bac-muted:        #6b7280;
  --bac-border:       #cfe3d6;
  --bac-shadow:       0 10px 40px rgba(27, 107, 58, 0.22);
  --bac-shadow-sm:    0 4px 16px rgba(0, 0, 0, 0.12);
  --bac-radius:       18px;
  --bac-font:         'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --bac-ease:         cubic-bezier(0.4, 0, 0.2, 1);
  --bac-spring:       cubic-bezier(0.34, 1.56, 0.64, 1);
  --bac-w:            360px;
  --bac-h:            540px;
}

/* ── Wrapper — bottom left ─────────────────────────────── */
#bac-chatbot-wrapper {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 999999;
  font-family: var(--bac-font);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.4s var(--bac-ease), transform 0.4s var(--bac-ease);
}

#bac-chatbot-wrapper.bac-ready {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ── "Need Help?" label ────────────────────────────────── */
#bac-attention-label {
  background: var(--bac-amber);
  color: #1a1a1a;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 5px 13px;
  border-radius: 20px;
  box-shadow: var(--bac-shadow-sm);
  white-space: nowrap;
  cursor: pointer;
  margin-left: 8px;
  order: 1;
  animation: bac-bounce 2.6s ease-in-out infinite;
  transition: transform 0.2s;
}

#bac-attention-label:hover { transform: scale(1.06); }

@keyframes bac-bounce {
  0%, 100% { transform: translateY(0); }
  40%       { transform: translateY(-7px); }
  55%       { transform: translateY(-4px); }
}

/* ── Launcher button ───────────────────────────────────── */
#bac-launcher {
  order: 2;
  width: 58px;
  height: 58px;
  border-radius: 50% !important;
  background: var(--bac-green) !important;
  border: 3px solid #ffffff !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: var(--bac-shadow), 0 0 0 3px var(--bac-green) !important;
  transition: background 0.25s var(--bac-ease), transform 0.2s var(--bac-ease);
  position: relative !important;
  padding: 0 !important;
  line-height: 1 !important;
  outline: none !important;
}


#bac-launcher:hover {
  background: var(--bac-green-dark) !important;
  transform: scale(1.07);
}

#bac-launcher:focus-visible { outline: 3px solid var(--bac-amber) !important; outline-offset: 3px; }

/* ── Force SVG icons to always show correctly ──────────── */
#bac-launcher svg,
#bac-launcher svg#bac-icon-open,
#bac-launcher svg#bac-icon-close {
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  min-height: 26px !important;
  color: #ffffff !important;
  fill: #ffffff !important;
  display: block !important;
  flex-shrink: 0 !important;
  pointer-events: none !important;
}

#bac-launcher svg path {
  fill: #ffffff !important;
}

/* Override any theme that hides SVGs globally */
#bac-chatbot-wrapper svg {
  display: block !important;
  overflow: visible !important;
}

#bac-close-btn svg,
#bac-close-btn svg path {
  display: block !important;
  fill: #ffffff !important;
  color: #ffffff !important;
}

/* ── Chat window ───────────────────────────────────────── */
#bac-chat-window {
  order: 0;
  width: var(--bac-w);
  height: var(--bac-h);
  background: var(--bac-white);
  border-radius: var(--bac-radius);
  box-shadow: var(--bac-shadow);
  border: 1px solid var(--bac-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom left;
  transform: scale(0.82) translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.38s var(--bac-spring), opacity 0.25s var(--bac-ease);
}

#bac-chat-window.bac-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ────────────────────────────────────────────── */
#bac-chat-header {
  background: linear-gradient(135deg, var(--bac-green) 0%, #d4253a 100%);
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

#bac-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 2px solid rgba(255,255,255,0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

#bac-header-info { flex: 1; min-width: 0; }

#bac-chat-header-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

#bac-chat-header-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: rgba(255,255,255,0.78);
  display: flex;
  align-items: center;
  gap: 5px;
}

.bac-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: bac-status 2s ease-in-out infinite;
}

@keyframes bac-status {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

#bac-close-btn {
  background: rgba(255,255,255,0.14);
  border: none;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

#bac-close-btn:hover { background: rgba(255,255,255,0.26); }
#bac-close-btn:focus-visible { outline: 2px solid var(--bac-amber); }
#bac-close-btn svg { width: 17px; height: 17px; color: #fff; }

/* ── Messages area ─────────────────────────────────────── */
#bac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bac-bg);
  scroll-behavior: smooth;
}

#bac-messages::-webkit-scrollbar        { width: 4px; }
#bac-messages::-webkit-scrollbar-track  { background: transparent; }
#bac-messages::-webkit-scrollbar-thumb  { background: var(--bac-border); border-radius: 2px; }

/* ── Message bubbles ───────────────────────────────────── */
.bac-msg {
  display: flex;
  animation: bac-in 0.28s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

@keyframes bac-in {
  from { opacity: 0; transform: translateY(10px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bac-msg-bot  { justify-content: flex-start; }
.bac-msg-user { justify-content: flex-end; }

.bac-msg-bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.58;
  word-break: break-word;
}

.bac-msg-bot .bac-msg-bubble {
  background: var(--bac-white);
  color: var(--bac-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border: 1px solid var(--bac-border);
}

.bac-msg-user .bac-msg-bubble {
  background: var(--bac-green);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(27,107,58,0.22);
}

/* ── Link buttons (external URLs) ─────────────────────── */
.bac-link-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 86%;
  animation: bac-in 0.28s cubic-bezier(0.34,1.4,0.64,1) both;
}

.bac-link-btn {
  display: block;
  background: var(--bac-green);
  color: #ffffff !important;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 12px;
  text-align: center;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(190,30,46,0.22);
}

.bac-link-btn:hover {
  background: var(--bac-green-dark);
  transform: translateY(-1px);
  text-decoration: none;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(190,30,46,0.3);
}

/* ── Quick-reply button row ────────────────────────────── */
.bac-quick-reply-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  animation: bac-in 0.32s cubic-bezier(0.34,1.4,0.64,1) both;
  animation-delay: 0.08s;
}

.bac-qr-btn {
  width: 100%;
  text-align: left;
  background: var(--bac-green);
  color: #ffffff !important;
  border: 1.5px solid var(--bac-green);
  border-radius: 11px;
  padding: 9px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--bac-font);
  transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
  line-height: 1.3;
}

.bac-qr-btn:hover:not(:disabled) {
  background: var(--bac-green-dark);
  color: #ffffff !important;
  border-color: var(--bac-green-dark);
  transform: translateX(3px);
  box-shadow: 0 3px 10px rgba(190,30,46,0.25);
}

.bac-qr-btn:focus-visible {
  outline: 2px solid var(--bac-amber);
  outline-offset: 2px;
}

.bac-qr-btn--used,
.bac-qr-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Typing indicator ──────────────────────────────────── */
#bac-typing {
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  background: var(--bac-bg);
}

#bac-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--bac-green);
  border-radius: 50%;
  animation: bac-dot 1.2s ease-in-out infinite;
  opacity: 0.5;
}
#bac-typing span:nth-child(1) { animation-delay: 0s;   }
#bac-typing span:nth-child(2) { animation-delay: 0.2s; }
#bac-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bac-dot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40%           { transform: scale(1.25); opacity: 1; }
}

/* ── Footer branding ───────────────────────────────────── */
#bac-chat-footer {
  text-align: center;
  font-size: 10.5px;
  color: var(--bac-muted);
  padding: 5px 14px 8px;
  background: var(--bac-white);
  border-top: 1px solid var(--bac-border);
  flex-shrink: 0;
}

#bac-chat-footer a {
  color: var(--bac-green);
  text-decoration: none;
  font-weight: 600;
}

#bac-chat-footer a:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────── */
@media ( max-width: 480px ) {
  :root { --bac-w: calc(100vw - 28px); }
  #bac-chatbot-wrapper { bottom: 14px; left: 14px; }
  #bac-chat-window { --bac-h: 480px; }
}
