/* ============================================================
   Fence Famm Company — AI Chatbot Styles
   Colors: #D79327 (gold/amber), #000 (black)
   ============================================================ */

:root {
  --chat-primary: #D79327;
  --chat-primary-dark: #b87a1e;
  --chat-primary-light: #f0a830;
  --chat-black: #0a0a0a;
  --chat-dark: #1a1a1a;
  --chat-darker: #111111;
  --chat-surface: #1e1e1e;
  --chat-border: rgba(215, 147, 39, 0.25);
  --chat-text: #f0f0f0;
  --chat-text-muted: #999;
  --chat-radius: 20px;
  --chat-btn-size: 64px;
  --chat-width: 380px;
  --chat-height: 520px;
}

/* ── Floating Toggle Button ── */
#fence-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--chat-btn-size);
  height: var(--chat-btn-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  border: none;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(215, 147, 39, 0.5), 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: chat-pulse 2.5s ease-in-out infinite;
}

#fence-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(215, 147, 39, 0.7), 0 4px 12px rgba(0,0,0,0.5);
  animation: none;
}

#fence-chat-btn svg {
  width: 32px;
  height: 32px;
  fill: #fff;
  flex-shrink: 0;
}

@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(215,147,39,0.5), 0 0 0 0 rgba(215,147,39,0.4); }
  50% { box-shadow: 0 4px 20px rgba(215,147,39,0.5), 0 0 0 10px rgba(215,147,39,0); }
}

/* ── Notification Badge ── */
#fence-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e53e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
  animation: badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#fence-chat-badge.visible {
  display: flex;
}

@keyframes badge-pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ── Chat Window ── */
#fence-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: var(--chat-width);
  height: var(--chat-height);
  background: var(--chat-black);
  border-radius: var(--chat-radius);
  border: 1px solid var(--chat-border);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(215,147,39,0.1);
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

/* ── Header ── */
#fence-chat-header {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.fence-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fence-chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fence-chat-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.fence-chat-title {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

.fence-chat-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

@keyframes online-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.fence-chat-close-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background 0.15s;
  flex-shrink: 0;
}

.fence-chat-close-btn:hover {
  background: rgba(255,255,255,0.35);
}

.fence-chat-close-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Messages Area ── */
#fence-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--chat-black);
  scroll-behavior: smooth;
}

#fence-chat-messages::-webkit-scrollbar {
  width: 4px;
}

#fence-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#fence-chat-messages::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 2px;
}

/* ── Message Bubbles ── */
.fence-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
  animation: msg-in 0.25s ease;
}

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

.fence-msg.bot {
  align-self: flex-start;
}

.fence-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.fence-msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.fence-msg.bot .fence-msg-bubble {
  background: var(--chat-surface);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}

.fence-msg.user .fence-msg-bubble {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.fence-msg-bubble a {
  color: var(--chat-primary);
  text-decoration: underline;
}

.fence-msg.user .fence-msg-bubble a {
  color: #fff;
}

.fence-msg-bubble strong {
  font-weight: 600;
}

.fence-msg-bubble ul, .fence-msg-bubble ol {
  margin: 6px 0 0 14px;
}

.fence-msg-bubble li {
  margin-bottom: 3px;
}

.fence-msg-avatar {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fence-msg-avatar svg {
  width: 14px;
  height: 14px;
  fill: #fff;
}

/* ── Typing Indicator ── */
#fence-typing-indicator {
  display: none;
  align-self: flex-start;
  align-items: flex-end;
  gap: 8px;
  animation: msg-in 0.25s ease;
}

#fence-typing-indicator.visible {
  display: flex;
}

.fence-typing-bubble {
  background: var(--chat-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.fence-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--chat-primary);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.fence-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.fence-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick Options ── */
#fence-quick-options {
  padding: 8px 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--chat-darker);
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.fence-quick-btn {
  background: transparent;
  border: 1px solid var(--chat-border);
  color: var(--chat-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.fence-quick-btn:hover {
  background: var(--chat-primary);
  color: #fff;
  border-color: var(--chat-primary);
}

/* ── Input Area ── */
#fence-chat-input-area {
  padding: 10px 12px;
  background: var(--chat-darker);
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#fence-chat-input {
  flex: 1;
  background: var(--chat-surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  padding: 9px 16px;
  color: var(--chat-text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  resize: none;
  height: 38px;
  min-height: 38px;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}

#fence-chat-input::placeholder {
  color: var(--chat-text-muted);
}

#fence-chat-input:focus {
  border-color: var(--chat-primary);
}

#fence-chat-send-btn {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}

#fence-chat-send-btn:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

#fence-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

#fence-chat-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ── Lead Capture Form ── */
.fence-lead-form {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: msg-in 0.25s ease;
}

.fence-lead-form p {
  font-size: 13px;
  color: var(--chat-text);
  font-weight: 600;
  margin: 0;
}

.fence-lead-input {
  background: var(--chat-dark);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--chat-text);
  font-size: 13px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
  font-family: inherit;
}

.fence-lead-input:focus {
  border-color: var(--chat-primary);
}

.fence-lead-submit {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}

.fence-lead-submit:hover { opacity: 0.9; }

/* ── Powered-by footer ── */
.fence-chat-powered {
  text-align: center;
  font-size: 10px;
  color: var(--chat-text-muted);
  padding: 4px 0 2px;
  background: var(--chat-darker);
  flex-shrink: 0;
}

/* ── Mobile: full-screen ── */
@media (max-width: 480px) {
  #fence-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
    top: 0;
  }

  #fence-chat-btn {
    bottom: 16px;
    right: 16px;
  }
}
