/* ================================================================
   FlowChat Widget — WhatsApp-Authentic CSS
   ================================================================ */

:root {
  --fcwp-wa-green:    #25D366;
  --fcwp-wa-dark:     #075E54;
  --fcwp-wa-mid:      #128C7E;
  --fcwp-wa-bubble-user: #DCF8C6;
  --fcwp-wa-bubble-bot:  #ffffff;
  --fcwp-wa-bg:       #ECE5DD;
  --fcwp-wa-ts:       #667781;
  --fcwp-wa-tick:     #53BDEB;
  --fcwp-wa-chip-txt: #128C7E;
  --fcwp-shadow:      0 12px 40px rgba(0,0,0,.18);
  --fcwp-radius:      12px;
}

/* ── Widget root ─────────────────────────────────────────────────── */
#fcwp-widget {
  position: fixed;
  z-index: 99999;
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  box-sizing: border-box;
}
#fcwp-widget *, #fcwp-widget *::before, #fcwp-widget *::after { box-sizing: border-box; }

/* Desktop Placement */
@media (min-width: 768px) {
  #fcwp-widget { bottom: var(--fcwp-bottom-d, 20px) !important; }
  .fcwp-pos-d-right { right: var(--fcwp-side-d, 20px) !important; left: auto !important; }
  .fcwp-pos-d-left  { left: var(--fcwp-side-d, 20px) !important; right: auto !important; }
  .fcwp-tooltip, .fcwp-window { bottom: calc(var(--fcwp-fab-d, 60px) + 14px) !important; }
}

/* Mobile Placement */
@media (max-width: 767px) {
  #fcwp-widget { bottom: var(--fcwp-bottom-m, 20px) !important; }
  .fcwp-pos-m-right { right: var(--fcwp-side-m, 16px) !important; left: auto !important; }
  .fcwp-pos-m-left  { left: var(--fcwp-side-m, 16px) !important; right: auto !important; }
  .fcwp-tooltip, .fcwp-window { bottom: calc(var(--fcwp-fab-m, 55px) + 12px) !important; }
}

/* ── FAB (Floating Action Button) ───────────────────────────────── */
.fcwp-fab {
  pointer-events: auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fcwp-primary, #25D366);
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(37,211,102,.45);
  transition: transform .2s, box-shadow .2s, background .2s, border-radius .3s, width .3s, padding .3s, bottom .3s;
  position: relative;
  outline: none;
}

/* Dynamic FAB Sizing based on device settings */
@media (min-width: 768px) {
  .fcwp-fab { width: var(--fcwp-fab-d, 60px); height: var(--fcwp-fab-d, 60px); }
}
@media (max-width: 767px) {
  .fcwp-fab { width: var(--fcwp-fab-m, 55px); height: var(--fcwp-fab-m, 55px); }
}

.fcwp-fab:hover { transform: scale(1.05); box-shadow: 0 8px 28px rgba(37,211,102,.55); background: var(--fcwp-btn-hover); }
.fcwp-fab:active { transform: scale(.96); }

.fcwp-fab-content { width: 100%; height: 100%; }
.fcwp-fab__icon { color: var(--fcwp-header-text, #fff); width: 28px; height: 28px; }

/* Styles */
/* 1. Classic */
.fcwp-style-classic .fcwp-fab { animation: fcwp-subtle-bounce 3s ease infinite; }
.fcwp-style-classic .fcwp-fab:hover { animation: none; }
@keyframes fcwp-subtle-bounce { 0%,100% {transform:translateY(0)} 50% {transform:translateY(-4px)} }

/* 2. Pulse */
.fcwp-style-pulse .fcwp-fab { animation: fcwp-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.fcwp-style-pulse .fcwp-fab:hover { animation: none; }
@keyframes fcwp-pulse {
  0%,100% { box-shadow: 0 6px 20px rgba(37,211,102,.45), 0 0 0 0 rgba(37,211,102,.5); }
  50%      { box-shadow: 0 6px 20px rgba(37,211,102,.45), 0 0 0 15px rgba(37,211,102,0); }
}
.fcwp-style-pulse .fcwp-tooltip { display: none !important; }

/* 3. Pill */
.fcwp-style-pill .fcwp-fab { width: auto; padding: 0 20px 0 16px; border-radius: 30px; }
.fcwp-style-pill .fcwp-fab-content { gap: 8px !important; }
.fcwp-style-pill .fcwp-fab__text { display: block !important; color: var(--fcwp-header-text); font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.fcwp-style-pill .fcwp-tooltip { display: none !important; }

/* 4. Card */
.fcwp-style-card .fcwp-fab { width: auto; height: auto; padding: 14px 20px; border-radius: 12px; background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.15); border: 1px solid #e5e7eb; }
.fcwp-style-card .fcwp-fab__icon { color: var(--fcwp-primary); }
.fcwp-style-card .fcwp-fab__text { display: block !important; color: #111; font-weight: 600; font-size: 15px; white-space: nowrap; }
.fcwp-style-card .fcwp-tooltip { display: none !important; }
.fcwp-style-card .fcwp-fab:hover { background: #f9fafb; transform: translateY(-3px); }

.fcwp-fab__badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 18px; height: 18px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}
.fcwp-fab__icon--image { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  border-radius: 50%;
}
.fcwp-fab__icon svg { width: 32px; height: 32px; flex-shrink: 0; }

/* ── Tooltip ─────────────────────────────────────────────────────── */
.fcwp-tooltip {
  position: absolute;
  /* bottom handled by media queries above */
  background: #fff;
  border-radius: 10px 10px 0 10px;
  padding: 10px 14px;
  max-width: 220px;
  font-size: 13px;
  line-height: 1.4;
  color: #111;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  white-space: pre-line;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: fcwp-slide-up .3s ease;
}
.fcwp-pos-d-right .fcwp-tooltip, .fcwp-pos-m-right .fcwp-tooltip { right: 0; left: auto; }
.fcwp-pos-d-left .fcwp-tooltip,  .fcwp-pos-m-left .fcwp-tooltip  { left: 0; right: auto; border-radius: 10px 10px 10px 0; }
.fcwp-tooltip__close {
  background: none; border: none; cursor: pointer;
  color: #9ca3af; font-size: 14px; line-height: 1; padding: 0; flex-shrink: 0;
}

/* ── Chat Window ─────────────────────────────────────────────────── */
.fcwp-window {
  position: absolute;
  /* bottom handled by media queries above */
  width: 360px;
  max-height: 560px;
  background: #fff;
  border-radius: var(--fcwp-radius);
  box-shadow: var(--fcwp-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fcwp-pop-in .25s cubic-bezier(.34,1.56,.64,1);
}
.fcwp-pos-d-right .fcwp-window, .fcwp-pos-m-right .fcwp-window { right: 0; left: auto; transform-origin: bottom right; }
.fcwp-pos-d-left .fcwp-window,  .fcwp-pos-m-left .fcwp-window  { left: 0; right: auto; transform-origin: bottom left; }

@media (max-width: 480px) {
  .fcwp-window {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
  }
}

/* ── Window Header ───────────────────────────────────────────────── */
.fcwp-window__header {
  background: var(--fcwp-secondary);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.fcwp-window__agent  { display: flex; align-items: center; gap: 10px; }
.fcwp-window__close  { background: none; border: none; cursor: pointer; color: var(--fcwp-header-text); opacity: .8; padding: 4px; border-radius: 4px; transition: opacity .15s; }
.fcwp-window__close:hover { opacity: 1; }

.fcwp-agent-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.fcwp-agent-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.fcwp-agent-name   { font-size: 15px; font-weight: 600; color: var(--fcwp-header-text); display: block; line-height: 1.2; }
.fcwp-agent-status { display: flex; align-items: center; gap: 4px; }
.fcwp-online-dot   { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; flex-shrink: 0; }
.fcwp-agent-role   { font-size: 11px; color: var(--fcwp-header-text); opacity: .8; }

/* ── Chat Body ───────────────────────────────────────────────────── */
.fcwp-chat-body {
  flex: 1;
  overflow-y: auto;
  background: var(--fcwp-wa-bg) url("data:image/svg+xml,%3Csvg width='400' height='400' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M100 200c0-55.2 44.8-100 100-100s100 44.8 100 100m-200 0c0 55.2 44.8 100 100 100' stroke='%23D4C9B8' stroke-width='.8' fill='none' opacity='.4'/%3E%3C/svg%3E");
  padding: 12px 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ── Bubbles ─────────────────────────────────────────────────────── */
.fcwp-bubble-wrap { display: flex; margin-bottom: 6px; }
.fcwp-bubble-wrap--bot  { justify-content: flex-start; }
.fcwp-bubble-wrap--user { justify-content: flex-end; }

.fcwp-bubble {
  max-width: 82%;
  padding: 8px 11px;
  border-radius: 0 12px 12px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  animation: fcwp-slide-up .2s ease;
}
.fcwp-bubble--bot {
  background: var(--fcwp-bot-bg);
  color: var(--fcwp-bot-txt);
  box-shadow: 0 1px 2px rgba(0,0,0,.13);
}
.fcwp-bubble--user {
  background: var(--fcwp-user-bg);
  color: var(--fcwp-user-txt);
  border-radius: 12px 0 12px 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

/* Meta: timestamp + ticks */
.fcwp-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 3px;
}
.fcwp-ts    { font-size: 10.5px; color: var(--fcwp-wa-ts); }
.fcwp-ticks { color: var(--fcwp-wa-tick); font-size: 13px; line-height: 1; }

/* Typing indicator */
.fcwp-typing-bubble {
  background: var(--fcwp-wa-bubble-bot);
  border-radius: 0 12px 12px 12px;
  padding: 10px 14px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.13);
  animation: fcwp-slide-up .2s ease;
}
.fcwp-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: fcwp-bounce 1.2s ease infinite;
}
.fcwp-dot:nth-child(2) { animation-delay: .15s; }
.fcwp-dot:nth-child(3) { animation-delay: .3s; }

@keyframes fcwp-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-5px); }
}

/* ── Quick Reply Chips ───────────────────────────────────────────── */
.fcwp-chips-wrap { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px; animation: fcwp-slide-up .2s ease; }
.fcwp-chip {
  background: var(--fcwp-choice-bg, #fff);
  border: 1.5px solid var(--fcwp-choice-border, var(--fcwp-primary));
  color: var(--fcwp-choice-txt, var(--fcwp-bot-txt));
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s, transform .1s, border-color .15s, box-shadow .15s;
  line-height: 1.3;
  display: block;
  width: 100%;
}
.fcwp-chip:hover  { 
  background: var(--fcwp-choice-bg-h, var(--fcwp-primary)); 
  color: var(--fcwp-choice-txt-h, var(--fcwp-header-text)); 
  border-color: var(--fcwp-choice-border-h, var(--fcwp-primary)); 
  transform: translateX(2px); 
  box-shadow: 0 4px 10px rgba(0,0,0,0.08); 
}
.fcwp-chip:active { transform: translateX(2px) scale(.98); }
.fcwp-chip--selected { 
  background: var(--fcwp-choice-bg-h, var(--fcwp-primary)); 
  color: var(--fcwp-choice-txt-h, var(--fcwp-header-text)); 
  border-color: var(--fcwp-choice-border-h, var(--fcwp-primary)); 
  cursor: default; 
}
.fcwp-chip--selected:hover { transform: none; background: var(--fcwp-choice-bg-h, var(--fcwp-primary)); box-shadow: none; }

.fcwp-chip--browsing {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--fcwp-wa-ts) !important;
  text-align: center;
  font-size: 13px;
  padding: 6px !important;
  margin-top: 2px;
}
.fcwp-chip--browsing:hover {
  text-decoration: underline;
  transform: none !important;
  background: transparent !important;
  color: var(--fcwp-wa-mid) !important;
}
.fcwp-chip--browsing.fcwp-chip--selected {
  background: transparent !important;
  color: var(--fcwp-wa-mid) !important;
  border: none !important;
  text-decoration: underline;
}

/* ── Lead Form (rendered as bot bubble) ─────────────────────────── */
.fcwp-form-bubble {
  background: var(--fcwp-wa-bubble-bot);
  border-radius: 0 12px 12px 12px;
  padding: 14px 14px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.13);
  width: 100%;
  max-width: 100%;
  animation: fcwp-slide-up .2s ease;
}

.fcwp-form-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.fcwp-form-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; }
.fcwp-form-field input, .fcwp-form-field textarea {
  border: 1.5px solid #e5e7eb;
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 13px;
  color: #111;
  background: #fff;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.fcwp-form-field input:focus, .fcwp-form-field textarea:focus {
  outline: none;
  border-color: var(--fcwp-wa-green);
  box-shadow: 0 0 0 3px rgba(37,211,102,.15);
}
.fcwp-form-field--error input { border-color: #ef4444; }
.fcwp-field-error { font-size: 11px; color: #ef4444; margin-top: 2px; }

/* Social proof & urgency */
.fcwp-social-proof { font-size: 11.5px; color: #374151; background: #f0fdf4; border-radius: 6px; padding: 5px 10px; margin: 4px 0 10px; text-align: center; }
.fcwp-urgency      { font-size: 11px; color: #6b7280; text-align: center; margin-top: 6px; }

/* GDPR */
.fcwp-gdpr { font-size: 11px; color: #6b7280; margin: 8px 0 10px; display: flex; gap: 6px; align-items: flex-start; }
.fcwp-gdpr a { color: var(--fcwp-wa-green); }

/* CTA Buttons */
.fcwp-cta-group { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.fcwp-cta-wa {
  display: block;
  background: var(--fcwp-primary);
  color: var(--fcwp-header-text);
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  width: 100%;
  transition: background .15s, transform .1s;
  box-shadow: 0 4px 12px rgba(37,211,102,.3);
}
.fcwp-cta-wa:hover  { background: var(--fcwp-btn-hover); }
.fcwp-cta-wa:active { transform: scale(.98); }

.fcwp-cta-email {
  display: block;
  background: #fff;
  color: #111;
  border: 1.5px solid var(--fcwp-primary);
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  width: 100%;
  transition: background .15s, transform .1s;
}
.fcwp-cta-email:hover  { background: #f0fdf4; }
.fcwp-cta-email:active { transform: scale(.98); }
.fcwp-cta-wa:disabled, .fcwp-cta-email:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* Nurture link */
.fcwp-nurture-link { display: block; text-align: center; color: var(--fcwp-wa-green); font-size: 12px; font-weight: 600; text-decoration: none; margin-top: 10px; }
.fcwp-nurture-link:hover { text-decoration: underline; }

/* Browsing links */
.fcwp-browse-links { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.fcwp-browse-link  { color: var(--fcwp-wa-mid); font-size: 13px; text-decoration: none; font-weight: 500; }
.fcwp-browse-link:hover { text-decoration: underline; }

/* ── Input Bar ───────────────────────────────────────────────────── */
.fcwp-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f2f5;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.fcwp-input-emoji { font-size: 20px; cursor: pointer; flex-shrink: 0; }
.fcwp-chat-input {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 14px;
  background: #fff;
  outline: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.fcwp-chat-input:focus { box-shadow: 0 1px 3px rgba(37,211,102,.25); }
.fcwp-send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--fcwp-wa-green);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.fcwp-send-btn:hover  { background: #1da851; }
.fcwp-send-btn:active { transform: scale(.92); }
.fcwp-send-btn:disabled { background: #d1d5db; cursor: not-allowed; }

/* ── Footer ──────────────────────────────────────────────────────── */
.fcwp-chat-footer {
  text-align: center;
  font-size: 10.5px;
  color: #9ca3af;
  padding: 5px 0;
  background: #f0f2f5;
  flex-shrink: 0;
}

/* ── Animations ──────────────────────────────────────────────────── */
@keyframes fcwp-pop-in {
  0%   { opacity: 0; transform: scale(.92); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes fcwp-slide-up {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── Utility ─────────────────────────────────────────────────────── */
.fcwp-hidden { display: none !important; }

/* ── Spinner ───────────────────────────────────────────────────────── */
.fcwp-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: fcwp-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes fcwp-spin {
  to { transform: rotate(360deg); }
}

/* ── Additional Polish ────────────────────────────────────────────── */
.fcwp-bubble--bot a { color: var(--fcwp-wa-mid); font-weight: 600; text-decoration: none; }
.fcwp-bubble--bot a:hover { text-decoration: underline; }
.fcwp-window__header { box-shadow: 0 2px 4px rgba(0,0,0,0.1); z-index: 10; }
