/* FENGCHI AI Chat widget — brand colors: #066aab (blue), #ff6900 (orange accent) */
#fc-ai-chat-root, #fc-ai-chat-root * { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }

#fc-ai-chat-root {
  position: fixed;
  left: 20px;
  bottom: 90px;
  z-index: 2147483647;
  font-size: 14px;
  line-height: 1.5;
  color: #1e293b;
}

/* ---- Bubble ---- */
.fc-ai-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #066aab 0%, #046bd2 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(6, 106, 171, 0.45);
  border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}
.fc-ai-bubble:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(6, 106, 171, 0.55); }
.fc-ai-bubble svg { width: 30px; height: 30px; }

.fc-ai-bubble .fc-ai-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* ---- Window ---- */
.fc-ai-window {
  position: fixed;
  left: 20px;
  bottom: 160px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 220px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 56px rgba(15, 23, 42, 0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.fc-ai-window.fc-ai-open { display: flex; animation: fc-ai-pop 0.22s ease; }
@keyframes fc-ai-pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Header */
.fc-ai-header {
  background: linear-gradient(135deg, #066aab 0%, #046bd2 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.fc-ai-header .fc-ai-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.fc-ai-header .fc-ai-avatar svg { width: 24px; height: 24px; }
.fc-ai-header .fc-ai-title { flex: 1; min-width: 0; }
.fc-ai-header .fc-ai-title b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-ai-header .fc-ai-status { font-size: 12px; opacity: 0.9; }
.fc-ai-header .fc-ai-status .fc-ai-dot { display: inline-block; width: 8px; height: 8px; background: #4ade80; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.fc-ai-close {
  background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; opacity: 0.85; padding: 2px 6px;
}
.fc-ai-close:hover { opacity: 1; }

/* Messages */
.fc-ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.fc-ai-msg { display: flex; gap: 10px; max-width: 88%; }
.fc-ai-msg.fc-ai-user { align-self: flex-end; flex-direction: row-reverse; }
.fc-ai-msg .fc-ai-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: #fff; border: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center;
}
.fc-ai-msg .fc-ai-msg-avatar svg { width: 16px; height: 16px; }
.fc-ai-msg .fc-ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.55;
}
.fc-ai-msg.fc-ai-user .fc-ai-msg-bubble {
  background: #066aab;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.fc-ai-msg.fc-ai-bot .fc-ai-msg-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.fc-ai-msg .fc-ai-msg-bubble b { font-weight: 600; }
.fc-ai-msg .fc-ai-msg-bubble p { margin: 0 0 10px; }
.fc-ai-msg .fc-ai-msg-bubble p:last-child { margin-bottom: 0; }
.fc-ai-msg .fc-ai-msg-bubble ul,
.fc-ai-msg .fc-ai-msg-bubble ol { margin: 10px 0 10px 18px; }
.fc-ai-msg .fc-ai-msg-bubble li { margin-bottom: 6px; }
.fc-ai-msg .fc-ai-msg-bubble a { color: #046bd2; text-decoration: underline; }

/* Quick questions */
.fc-ai-quick {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px 14px; background: #f8fafc;
}
.fc-ai-quick button {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.fc-ai-quick button:hover { border-color: #066aab; color: #066aab; background: #f0f7fd; }

/* Input */
.fc-ai-input {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.fc-ai-input textarea {
  flex: 1;
  border: none; outline: none;
  resize: none;
  font-size: 13.5px;
  font-family: inherit;
  max-height: 90px;
  line-height: 1.4;
  color: #1e293b;
  background: transparent;
}
.fc-ai-input .fc-ai-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: #066aab; color: #fff; border: none;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.fc-ai-input .fc-ai-send:hover { background: #046bd2; }
.fc-ai-input .fc-ai-send svg { width: 18px; height: 18px; }
.fc-ai-input .fc-ai-send:disabled { background: #cbd5e1; cursor: not-allowed; }

/* Quote button strip */
.fc-ai-cta {
  display: flex; justify-content: center; padding: 18px 14px;
  background: #fff; border-top: 1px solid #e2e8f0;
}
.fc-ai-cta button {
  width: auto;
  min-width: 200px;
  background: linear-gradient(135deg, #ff6900 0%, #e55a00 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 30px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255,105,0,0.38);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fc-ai-cta button:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(255,105,0,0.48); }

/* Lead form */
.fc-ai-form {
  position: absolute;
  top: 58px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 24px 30px;
  background: #fff;
  display: none;
  flex-direction: column;
  gap: 14px;
  z-index: 3;
}
.fc-ai-form.fc-ai-open { display: flex; }
.fc-ai-form h3 { font-size: 16px; color: #0f172a; margin-bottom: 4px; }
.fc-ai-form p { font-size: 12.5px; color: #64748b; margin-bottom: 10px; line-height: 1.45; }
.fc-ai-form label { font-size: 12px; font-weight: 600; color: #334155; display: block; margin-bottom: 5px; }
.fc-ai-form label .fc-ai-required { color: #ef4444; font-weight: 500; margin-left: 2px; }
.fc-ai-form input,
.fc-ai-form select,
.fc-ai-form textarea {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  color: #1e293b;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.fc-ai-form input:focus,
.fc-ai-form select:focus,
.fc-ai-form textarea:focus { border-color: #066aab; box-shadow: 0 0 0 3px rgba(6, 106, 171, 0.12); }
.fc-ai-form textarea { resize: vertical; min-height: 70px; }
.fc-ai-form .fc-ai-form-row { display: flex; gap: 12px; }
.fc-ai-form .fc-ai-form-row > div { flex: 1; min-width: 0; }
.fc-ai-form .fc-ai-submit {
  width: 100%;
  background: linear-gradient(135deg, #ff6900 0%, #e55a00 100%);
  color: #fff; border: none;
  border-radius: 10px; padding: 13px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(255,105,0,0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin-top: 4px;
}
.fc-ai-form .fc-ai-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255,105,0,0.45); }
.fc-ai-form .fc-ai-submit:disabled { background: #cbd5e1; box-shadow: none; cursor: not-allowed; transform: none; }
.fc-ai-form .fc-ai-back {
  background: #fff; border: 1px solid #cbd5e1; color: #475569;
  font-size: 12px; cursor: pointer; padding: 5px 10px;
  border-radius: 999px; align-self: flex-start;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}
.fc-ai-form .fc-ai-back:hover { background: #f8fafc; border-color: #94a3b8; }
.fc-ai-form .fc-ai-form-ok { text-align: center; padding: 44px 20px; color: #15803d; background: #fff; border-radius: 12px; font-size: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* Typing indicator */
.fc-ai-typing .fc-ai-msg-bubble { display: flex; gap: 4px; align-items: center; padding: 12px 14px; }
.fc-ai-typing .fc-ai-typing-dot { width: 7px; height: 7px; background: #94a3b8; border-radius: 50%; animation: fc-ai-blink 1.2s infinite; }
.fc-ai-typing .fc-ai-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.fc-ai-typing .fc-ai-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes fc-ai-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Mobile */
@media (max-width: 480px) {
  #fc-ai-chat-root { left: 12px; bottom: 78px; }
  .fc-ai-bubble { width: 52px; height: 52px; }
  .fc-ai-bubble svg { width: 24px; height: 24px; }
  .fc-ai-window {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 78dvh;
    max-height: 560px;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.22);
  }
  .fc-ai-header { border-radius: 18px 18px 0 0; }
  .fc-ai-input {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .fc-ai-body { padding: 14px 12px; gap: 12px; }
  .fc-ai-msg { max-width: 92%; }
  .fc-ai-msg .fc-ai-msg-bubble { padding: 10px 12px; font-size: 14px; }
  .fc-ai-quick { padding: 10px 12px 12px; gap: 6px; }
  .fc-ai-quick button { padding: 6px 10px; font-size: 12px; }
  .fc-ai-cta { padding: 12px 14px; }
  .fc-ai-cta button { min-width: 170px; padding: 10px 22px; font-size: 14px; }
  .fc-ai-form { padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); gap: 12px; }
  .fc-ai-form .fc-ai-form-row { flex-direction: column; gap: 12px; }
}
