/* ================================================================
   BAELFIZZ CHATBOT WIDGET — chatbot.css
   Premium dark beverage brand aesthetic
   Palette matches main theme: Teal #0ABFBC · Green #4ECB71 · Amber #F5A623
   Fonts: Syne headings, DM Sans body (loaded by theme)
================================================================ */

/* ── Variables (scoped to widget) ── */
#bfc-root {
  --bfc-teal:      #0ABFBC;
  --bfc-teal-dark: #077A7D;
  --bfc-teal-dim:  #0ABFBC18;
  --bfc-green:     #4ECB71;
  --bfc-orange:    #E8621A;
  --bfc-amber:     #F5A623;
  --bfc-bg:        #070E14;
  --bfc-bg2:       #0C1820;
  --bfc-bg3:       #101D2A;
  --bfc-card:      #0F1E2D;
  --bfc-border:    #1A2E42;
  --bfc-text:      #C8E0F0;
  --bfc-muted:     #6A90AA;
  --bfc-white:     #FFFFFF;
  --bfc-r:         14px;
  --bfc-shadow:    0 24px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(10,191,188,.15);
  --bfc-font-h:    'Syne', sans-serif;
  --bfc-font-b:    'DM Sans', sans-serif;
  --bfc-t:         .22s ease;
}

/* ── Root ── */
#bfc-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: var(--bfc-font-b);
  font-size: 14px;
  line-height: 1.5;
}

/* ════════════════════════════
   LAUNCHER BUTTON
════════════════════════════ */
.bfc-launcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px 13px 16px;
  background: linear-gradient(135deg, var(--bfc-teal-dark), var(--bfc-teal));
  color: var(--bfc-bg);
  border: none;
  border-radius: 999px;
  font-family: var(--bfc-font-b);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(10,191,188,.45), 0 2px 8px rgba(0,0,0,.3);
  transition: all var(--bfc-t);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.bfc-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 36px rgba(10,191,188,.55), 0 4px 12px rgba(0,0,0,.35);
}
.bfc-launcher:active {
  transform: translateY(-1px) scale(.99);
}
.bfc-launcher-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bfc-launcher-label {
  font-size: 13.5px;
}
.bfc-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--bfc-amber);
  color: var(--bfc-bg);
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bfc-bg);
  animation: bfc-badge-pop .4s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes bfc-badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ════════════════════════════
   CHAT PANEL
════════════════════════════ */
.bfc-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 620px;
  background: var(--bfc-bg);
  border: 1px solid var(--bfc-border);
  border-radius: 20px;
  box-shadow: var(--bfc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.4,0,.2,1), opacity .28s ease;
  transform-origin: bottom right;
}
.bfc-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Panel grid overlay — matches theme aesthetic */
.bfc-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(10,191,188,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10,191,188,.02) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
  border-radius: 20px;
}

/* ── Header ── */
.bfc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, #061018, #0C1820);
  border-bottom: 1px solid var(--bfc-border);
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}
.bfc-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bfc-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bfc-teal-dark), var(--bfc-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.bfc-header-name {
  font-family: var(--bfc-font-h);
  font-size: 14px;
  font-weight: 700;
  color: var(--bfc-white);
}
.bfc-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--bfc-muted);
  margin-top: 1px;
}
.bfc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bfc-green);
  box-shadow: 0 0 6px var(--bfc-green);
  animation: bfc-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes bfc-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.bfc-header-close {
  background: var(--bfc-card);
  border: 1px solid var(--bfc-border);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bfc-muted);
  cursor: pointer;
  transition: all var(--bfc-t);
  flex-shrink: 0;
}
.bfc-header-close:hover { color: var(--bfc-white); border-color: var(--bfc-teal); }

/* ── Messages ── */
.bfc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
}
.bfc-messages::-webkit-scrollbar { width: 4px; }
.bfc-messages::-webkit-scrollbar-track { background: transparent; }
.bfc-messages::-webkit-scrollbar-thumb { background: var(--bfc-border); border-radius: 2px; }

/* Message bubbles */
.bfc-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: bfc-msg-in .3s ease;
}
@keyframes bfc-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bfc-msg.bot  { align-self: flex-start; }
.bfc-msg.user { align-self: flex-end; }

.bfc-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}
.bfc-msg.bot .bfc-bubble {
  background: var(--bfc-card);
  border: 1px solid var(--bfc-border);
  color: var(--bfc-text);
  border-bottom-left-radius: 5px;
}
.bfc-msg.user .bfc-bubble {
  background: linear-gradient(135deg, var(--bfc-teal-dark), var(--bfc-teal));
  color: var(--bfc-bg);
  font-weight: 500;
  border-bottom-right-radius: 5px;
}
.bfc-bubble strong { color: var(--bfc-white); }
.bfc-msg.bot .bfc-bubble a {
  color: var(--bfc-teal);
  text-decoration: underline;
  text-decoration-color: rgba(10,191,188,.4);
}
.bfc-bubble-time {
  font-size: 10px;
  color: var(--bfc-muted);
  margin-top: 3px;
  padding: 0 4px;
}
.bfc-msg.user .bfc-bubble-time { text-align: right; }

/* Comparison table in bubble */
.bfc-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-top: 8px;
}
.bfc-table th, .bfc-table td {
  padding: 5px 8px;
  border: 1px solid var(--bfc-border);
  text-align: left;
  white-space: nowrap;
}
.bfc-table th {
  background: var(--bfc-bg3);
  color: var(--bfc-teal);
  font-family: var(--bfc-font-h);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.bfc-table td { color: var(--bfc-text); }
.bfc-table td strong { color: var(--bfc-white); }

/* ── Typing indicator ── */
.bfc-typing {
  padding: 6px 16px 4px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.bfc-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bfc-card);
  border: 1px solid var(--bfc-border);
  border-radius: 14px;
  padding: 8px 13px;
}
.bfc-typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bfc-muted);
  animation: bfc-dot .9s ease-in-out infinite;
}
.bfc-typing-bubble span:nth-child(2) { animation-delay: .18s; }
.bfc-typing-bubble span:nth-child(3) { animation-delay: .36s; }
@keyframes bfc-dot {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick replies ── */
.bfc-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 10px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  min-height: 8px;
}
.bfc-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--bfc-border);
  background: var(--bfc-card);
  color: var(--bfc-text);
  font-family: var(--bfc-font-b);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--bfc-t);
  white-space: nowrap;
  line-height: 1.3;
}
.bfc-chip:hover {
  background: var(--bfc-teal-dim);
  border-color: var(--bfc-teal-dark);
  color: var(--bfc-teal);
  transform: translateY(-1px);
}
.bfc-chip:active { transform: translateY(0); }

/* ── Lead form ── */
.bfc-lead-form-wrap {
  padding: 14px 16px;
  border-top: 1px solid var(--bfc-border);
  background: var(--bfc-bg2);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  animation: bfc-msg-in .3s ease;
}
.bfc-lead-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bfc-form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bfc-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bfc-form-field label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--bfc-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.bfc-required { color: var(--bfc-orange); }
.bfc-form-field input,
.bfc-form-field textarea {
  background: var(--bfc-bg3);
  border: 1.5px solid var(--bfc-border);
  color: var(--bfc-text);
  padding: 8px 11px;
  border-radius: 8px;
  font-family: var(--bfc-font-b);
  font-size: 12.5px;
  transition: border-color var(--bfc-t), box-shadow var(--bfc-t);
  width: 100%;
  box-sizing: border-box;
}
.bfc-form-field input:focus,
.bfc-form-field textarea:focus {
  border-color: var(--bfc-teal);
  box-shadow: 0 0 0 3px #0ABFBC12;
  outline: none;
}
.bfc-form-field input::placeholder,
.bfc-form-field textarea::placeholder { color: var(--bfc-muted); opacity: .7; }
.bfc-form-field textarea { resize: vertical; min-height: 64px; }
.bfc-form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bfc-form-submit {
  flex: 1;
  padding: 9px 16px;
  background: linear-gradient(135deg, var(--bfc-teal-dark), var(--bfc-teal));
  color: var(--bfc-bg);
  border: none;
  border-radius: 99px;
  font-family: var(--bfc-font-b);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--bfc-t);
}
.bfc-form-submit:hover { opacity: .88; transform: translateY(-1px); }
.bfc-form-submit:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.bfc-form-cancel {
  padding: 9px 14px;
  background: transparent;
  border: 1px solid var(--bfc-border);
  color: var(--bfc-muted);
  border-radius: 99px;
  font-family: var(--bfc-font-b);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--bfc-t);
}
.bfc-form-cancel:hover { border-color: var(--bfc-teal); color: var(--bfc-teal); }
.bfc-form-privacy {
  font-size: 10px;
  color: var(--bfc-muted);
  text-align: center;
  margin: 0;
}

/* ── Input area ── */
.bfc-input-area {
  border-top: 1px solid var(--bfc-border);
  padding: 10px 14px 8px;
  background: var(--bfc-bg);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.bfc-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bfc-text-input {
  flex: 1;
  background: var(--bfc-card);
  border: 1.5px solid var(--bfc-border);
  color: var(--bfc-text);
  padding: 9px 13px;
  border-radius: 99px;
  font-family: var(--bfc-font-b);
  font-size: 13px;
  transition: border-color var(--bfc-t), box-shadow var(--bfc-t);
  min-width: 0;
}
.bfc-text-input:focus {
  border-color: var(--bfc-teal);
  box-shadow: 0 0 0 3px #0ABFBC12;
  outline: none;
}
.bfc-text-input::placeholder { color: var(--bfc-muted); opacity: .7; }
.bfc-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bfc-teal-dark), var(--bfc-teal));
  border: none;
  color: var(--bfc-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--bfc-t);
  flex-shrink: 0;
}
.bfc-send-btn:hover { transform: scale(1.1); opacity: .9; }
.bfc-send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.bfc-input-footer {
  font-size: 10px;
  color: var(--bfc-muted);
  text-align: center;
  margin-top: 5px;
  opacity: .6;
}

/* ════════════════════════════
   MOBILE
════════════════════════════ */
@media (max-width: 480px) {
  #bfc-root {
    bottom: 16px;
    right: 16px;
  }
  .bfc-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    opacity: 1;
    transform-origin: bottom center;
  }
  .bfc-panel.open {
    transform: translateY(0);
  }
  .bfc-launcher {
    padding: 12px 16px;
  }
  .bfc-launcher-label {
    display: none;
  }
  .bfc-launcher {
    width: 52px;
    height: 52px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
  .bfc-form-row-2 {
    grid-template-columns: 1fr;
  }
  .bfc-quick-replies {
    max-height: 80px;
    overflow-y: auto;
  }
}

/* ════════════════════════════
   DARK MODE OVERRIDE
   (already dark — just confirm)
════════════════════════════ */
@media (prefers-color-scheme: light) {
  /* Widget stays dark regardless of OS theme */
  #bfc-root {
    color-scheme: dark;
  }
}

/* ════════════════════════════
   ACCESSIBILITY
════════════════════════════ */
.bfc-launcher:focus-visible,
.bfc-chip:focus-visible,
.bfc-send-btn:focus-visible,
.bfc-form-submit:focus-visible,
.bfc-header-close:focus-visible {
  outline: 2px solid var(--bfc-teal);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .bfc-panel,
  .bfc-launcher,
  .bfc-chip,
  .bfc-msg,
  .bfc-typing-bubble span {
    animation: none;
    transition: none;
  }
}

/* ── Streaming text effect ── */
.bfc-bubble-streaming {
  border-right: 2px solid var(--bfc-teal);
  animation: bfc-cursor-blink .6s ease-in-out infinite;
}
@keyframes bfc-cursor-blink { 0%,100%{border-right-color:var(--bfc-teal)}50%{border-right-color:transparent} }

/* ── AI badge on launcher ── */
.bfc-launcher-ai-badge {
  position: absolute;
  top: -3px;
  left: -3px;
  background: linear-gradient(135deg, #8B2FC9, #0ABFBC);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Mobile: full-screen on very small phones */
@media (max-width: 380px) {
  .bfc-panel {
    position: fixed;
    inset: 0;
    border-radius: 0;
    bottom: 0;
    max-height: 100dvh;
  }
}
/* Safe area padding for bottom on iPhone */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bfc-input-area {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}
