/* ── FenceFinder Chatbot Widget ─────────────────────────────────────────── */

:root {
  --ff-forest: #1a3a2a;
  --ff-lime:   #7cc84c;
  --ff-rust:   #c4622d;
  --ff-sand:   #f5ede0;
  --ff-white:  #ffffff;
  --ff-ink:    #1a2414;
  --ff-muted:  #7a8c72;
  --ff-radius: 16px;
  --ff-shadow: 0 8px 40px rgba(26,58,42,0.18), 0 2px 8px rgba(0,0,0,0.10);
}

/* ── Floating toggle button ─────────────────────────────────────────────── */

#ffchat-toggle {
  position: fixed;
  bottom: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ff-forest), #2e7d52);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(26,58,42,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}
#ffchat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(26,58,42,0.45);
}
#ffchat-toggle.position-right { right: 28px; }
#ffchat-toggle.position-left  { left: 28px;  }

#ffchat-toggle svg { width: 28px; height: 28px; fill: var(--ff-lime); }
#ffchat-toggle .ffchat-close-icon { display: none; }
#ffchat-toggle.open .ffchat-open-icon  { display: none; }
#ffchat-toggle.open .ffchat-close-icon { display: block; }

.ffchat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--ff-rust);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: ffchat-pulse 2s infinite;
}
@keyframes ffchat-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* ── Chat window ────────────────────────────────────────────────────────── */

#ffchat-window {
  position: fixed;
  bottom: 100px;
  width: 380px;
  max-height: 560px;
  background: var(--ff-white);
  border-radius: var(--ff-radius);
  box-shadow: var(--ff-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#ffchat-window.position-right { right: 28px; }
#ffchat-window.position-left  { left: 28px;  }
#ffchat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.ffchat-header {
  background: linear-gradient(135deg, var(--ff-forest) 0%, #2e7d52 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.ffchat-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(124,200,76,0.2);
  border: 2px solid var(--ff-lime);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.ffchat-header-info { flex: 1; }
.ffchat-header-name {
  color: var(--ff-white);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}
.ffchat-header-status {
  color: var(--ff-lime);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ffchat-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ff-lime);
  display: inline-block;
}
.ffchat-header-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  font-size: 1.2rem;
  line-height: 1;
  transition: color 0.15s;
}
.ffchat-header-close:hover { color: #fff; }

/* ── Suggested questions ─────────────────────────────────────────────────── */

.ffchat-suggestions {
  padding: 12px 14px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.ffchat-suggestion {
  background: var(--ff-sand);
  border: 1px solid #dde8d5;
  color: var(--ff-forest);
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.ffchat-suggestion:hover {
  background: #e0f0d0;
  border-color: var(--ff-lime);
}

/* ── Messages ────────────────────────────────────────────────────────────── */

.ffchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.ffchat-messages::-webkit-scrollbar { width: 5px; }
.ffchat-messages::-webkit-scrollbar-track { background: transparent; }
.ffchat-messages::-webkit-scrollbar-thumb { background: #dde8d5; border-radius: 10px; }

.ffchat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
}
.ffchat-msg.user { flex-direction: row-reverse; }

.ffchat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ff-forest), #2e7d52);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.ffchat-msg.user .ffchat-msg-avatar {
  background: linear-gradient(135deg, #4a5c40, #7a8c72);
}

.ffchat-msg-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ff-ink);
  word-break: break-word;
}
.ffchat-msg.bot .ffchat-msg-bubble {
  background: #f0f4ee;
  border-bottom-left-radius: 4px;
}
.ffchat-msg.user .ffchat-msg-bubble {
  background: var(--ff-forest);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.ffchat-typing .ffchat-msg-bubble {
  padding: 12px 16px;
}
.ffchat-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.ffchat-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ff-muted);
  animation: ffchat-bounce 1.2s infinite;
}
.ffchat-dots span:nth-child(2) { animation-delay: 0.2s; }
.ffchat-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ffchat-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* CTA button inside bot messages */
.ffchat-msg-bubble .ffchat-cta {
  display: inline-block;
  margin-top: 8px;
  background: var(--ff-rust);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.ffchat-msg-bubble .ffchat-cta:hover { background: #a8501f; }

/* ── Input area ──────────────────────────────────────────────────────────── */

.ffchat-input-area {
  padding: 12px 14px;
  border-top: 1px solid #eef2ec;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
#ffchat-input {
  flex: 1;
  border: 1px solid #dde8d5;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 0.875rem;
  resize: none;
  max-height: 100px;
  font-family: inherit;
  color: var(--ff-ink);
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.4;
}
#ffchat-input:focus { border-color: var(--ff-lime); }
#ffchat-input::placeholder { color: #a0b090; }

#ffchat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ff-forest);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}
#ffchat-send:hover:not(:disabled) {
  background: #2e7d52;
  transform: scale(1.05);
}
#ffchat-send:disabled { background: #ccc; cursor: not-allowed; }
#ffchat-send svg { width: 16px; height: 16px; fill: #fff; }

.ffchat-footer-note {
  text-align: center;
  font-size: 0.7rem;
  color: #bbb;
  padding: 0 14px 10px;
}

/* ── Inline embed ────────────────────────────────────────────────────────── */

#ffchat-inline .ffchat-inline-wrap {
  border: 1px solid #dde8d5;
  border-radius: var(--ff-radius);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(26,58,42,0.10);
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 520px;
}
#ffchat-inline .ffchat-messages { flex: 1; }
#ffchat-inline .ffchat-suggestions { padding: 14px 14px 0; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  #ffchat-window {
    width: calc(100vw - 24px);
    right: 12px !important;
    left: 12px !important;
    bottom: 88px;
  }
}
