/* ================================================================
   AI Chatbot & Lead Capture — Frontend Widget Styles
   ================================================================ */

#aicl-root * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

/* ---- BUBBLE TRIGGER ---- */
#aicl-bubble {
  position: fixed;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.12);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s;
  z-index: 999998;
  animation: aicl-pop-in 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
#aicl-bubble:hover { transform: scale(1.08); box-shadow: 0 10px 32px rgba(0,0,0,0.26); }
#aicl-bubble:active { transform: scale(0.95); }

#aicl-bubble .aicl-bubble-icon  { transition: transform 0.3s, opacity 0.3s; }
#aicl-bubble .aicl-bubble-close { position: absolute; font-size: 22px; opacity: 0; transform: rotate(-90deg) scale(0); transition: transform 0.3s, opacity 0.3s; }
#aicl-bubble.open .aicl-bubble-icon  { opacity: 0; transform: rotate(90deg) scale(0); }
#aicl-bubble.open .aicl-bubble-close { opacity: 1; transform: rotate(0deg) scale(1); }

#aicl-badge {
  position: absolute; top: -4px; right: -4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  animation: aicl-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

/* ---- POSITIONS ---- */
.aicl-pos-bottom-right #aicl-bubble { bottom: 24px; right: 24px; }
.aicl-pos-bottom-left  #aicl-bubble { bottom: 24px; left: 24px; }
.aicl-pos-bottom-right #aicl-window { bottom: 96px; right: 24px; }
.aicl-pos-bottom-left  #aicl-window { bottom: 96px; left: 24px; }

/* ---- CHAT WINDOW ---- */
#aicl-window {
  position: fixed;
  width: 360px;
  max-height: 580px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.1);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 999997;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
}
#aicl-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ---- HEADER ---- */
#aicl-header {
  padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
#aicl-header-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
#aicl-header-info { flex: 1; min-width: 0; }
#aicl-header-name { font-size: 15px; font-weight: 700; color: #fff; }
#aicl-header-status {
  font-size: 12px; color: rgba(255,255,255,0.8);
  display: flex; align-items: center; gap: 5px;
}
#aicl-header-status::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(74,222,128,0.5);
  animation: aicl-green-pulse 2s ease-in-out infinite;
}

/* ---- MESSAGES ---- */
#aicl-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
#aicl-messages::-webkit-scrollbar { width: 4px; }
#aicl-messages::-webkit-scrollbar-track { background: transparent; }
#aicl-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 99px; }

.aicl-msg {
  display: flex; gap: 8px; align-items: flex-end;
  animation: aicl-msg-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.aicl-msg.user { flex-direction: row-reverse; }

.aicl-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.aicl-msg.bot  .aicl-msg-avatar { background: #f1f5f9; }
.aicl-msg.user .aicl-msg-avatar { display: none; }

.aicl-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.aicl-msg.bot  .aicl-msg-bubble { background: #f1f5f9; color: #1e293b; border-bottom-left-radius: 4px; }
.aicl-msg.user .aicl-msg-bubble { color: #fff; border-bottom-right-radius: 4px; }

.aicl-msg-time { font-size: 10px; color: #94a3b8; margin-top: 4px; padding: 0 4px; }

/* ---- TYPING INDICATOR ---- */
#aicl-typing {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px 8px;
  animation: aicl-msg-in 0.3s ease;
}
#aicl-typing-dots { display: flex; gap: 4px; }
#aicl-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #cbd5e1;
  animation: aicl-dot 1.4s ease-in-out infinite;
}
#aicl-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
#aicl-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
#aicl-typing-label { font-size: 12px; color: #94a3b8; }

/* ---- INPUT AREA ---- */
#aicl-input-area {
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
  display: flex; gap: 8px; align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
#aicl-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px; color: #1e293b;
  resize: none; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.4;
  max-height: 100px;
  min-height: 42px;
  background: #f8fafc;
  font-family: inherit;
}
#aicl-input::placeholder { color: #94a3b8; }
#aicl-input:focus { border-color: var(--aicl-primary, #5b21b6); box-shadow: 0 0 0 3px rgba(91,33,182,0.1); background: #fff; }

#aicl-send {
  width: 42px; height: 42px; border-radius: 12px;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
  color: #fff;
}
#aicl-send:hover  { transform: scale(1.07); }
#aicl-send:active { transform: scale(0.92); }
#aicl-send:disabled { opacity: 0.5; cursor: not-allowed; }
#aicl-send svg { width: 18px; height: 18px; fill: currentColor; }

/* ---- LEAD CAPTURE FORM ---- */
#aicl-lead-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 24px;
  z-index: 10;
  animation: aicl-fade-in 0.3s ease;
}
#aicl-lead-overlay.hidden { display: none; }

#aicl-lead-icon { font-size: 42px; margin-bottom: 12px; }
#aicl-lead-title { font-size: 18px; font-weight: 700; color: #1e293b; text-align: center; margin-bottom: 6px; }
#aicl-lead-subtitle { font-size: 13px; color: #64748b; text-align: center; margin-bottom: 20px; line-height: 1.5; }

.aicl-field {
  width: 100%; margin-bottom: 10px;
}
.aicl-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px; color: #1e293b;
  background: #f8fafc; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.aicl-field input::placeholder { color: #94a3b8; }
.aicl-field input:focus { border-color: var(--aicl-primary, #5b21b6); box-shadow: 0 0 0 3px rgba(91,33,182,0.1); background: #fff; }
.aicl-field input.error { border-color: #ef4444; }

#aicl-lead-submit {
  width: 100%; padding: 12px;
  border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  color: #fff; cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 4px;
}
#aicl-lead-submit:hover  { opacity: 0.9; transform: translateY(-1px); }
#aicl-lead-submit:active { transform: translateY(0); }

#aicl-lead-skip {
  background: none; border: none;
  color: #94a3b8; font-size: 13px; cursor: pointer;
  margin-top: 12px; text-decoration: underline;
  font-family: inherit;
}
#aicl-lead-skip:hover { color: #64748b; }

/* ---- SUCCESS STATE ---- */
#aicl-lead-success {
  text-align: center; animation: aicl-msg-in 0.4s ease;
}
#aicl-lead-success .aicl-success-icon { font-size: 48px; margin-bottom: 12px; }
#aicl-lead-success p { font-size: 14px; color: #64748b; }

/* ---- POWERED BY ---- */
#aicl-powered {
  text-align: center; font-size: 11px; color: #cbd5e1;
  padding: 6px 0 10px; flex-shrink: 0;
}
#aicl-powered a { color: #94a3b8; text-decoration: none; }
#aicl-powered a:hover { color: #5b21b6; }

/* ---- QUICK REPLIES ---- */
#aicl-quick-replies {
  padding: 0 16px 12px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.aicl-quick-btn {
  padding: 6px 12px; border-radius: 99px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc; color: #475569;
  font-size: 12px; cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}
.aicl-quick-btn:hover { background: var(--aicl-primary, #5b21b6); color: #fff; border-color: transparent; }

/* ---- ANIMATIONS ---- */
@keyframes aicl-pop-in    { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes aicl-msg-in    { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes aicl-fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes aicl-dot       { 0%,80%,100% { transform: scale(0.8); opacity: 0.4; } 40% { transform: scale(1.1); opacity: 1; } }
@keyframes aicl-pulse     { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes aicl-green-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(74,222,128,0.5); }
  50%      { box-shadow: 0 0 0 5px rgba(74,222,128,0); }
}

/* ---- MOBILE ---- */
@media (max-width: 480px) {
  #aicl-window {
    width: calc(100vw - 16px);
    max-height: 70vh;
  }
  .aicl-pos-bottom-right #aicl-window,
  .aicl-pos-bottom-left  #aicl-window { right: 8px; left: 8px; }
  .aicl-pos-bottom-right #aicl-bubble { bottom: 16px; right: 16px; }
  .aicl-pos-bottom-left  #aicl-bubble { bottom: 16px; left: 16px; }
}
