/* AI Chat Widget – Frontend */

#acw-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Toggle Button ── */
#acw-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--acw-accent, #4F46E5);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.20);
  margin-left: auto;
  transition: transform 0.2s, box-shadow 0.2s;
}
#acw-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,0.28);
}
#acw-toggle svg { width:26px; height:26px; fill:#fff; transition: opacity 0.2s; }

/* ── Chat Window ── */
#acw-window {
  width: 360px;
  max-height: 540px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 12px;
  animation: acwSlideUp 0.25s ease;
}
@keyframes acwSlideUp {
  from { opacity:0; transform: translateY(16px); }
  to   { opacity:1; transform: translateY(0); }
}

/* ── Header ── */
#acw-header {
  background: var(--acw-accent, #4F46E5);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#acw-header .acw-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}
#acw-header .acw-title { font-weight: 600; font-size: 15px; flex:1; }
#acw-header .acw-online {
  font-size: 11px; opacity: 0.85;
  display: flex; align-items: center; gap:4px;
}
#acw-header .acw-online::before {
  content:''; display:inline-block;
  width:7px; height:7px; border-radius:50%;
  background:#4ade80;
}
#acw-close-btn {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 18px; line-height:1; padding:0; opacity:0.8;
}
#acw-close-btn:hover { opacity:1; }

/* ── Messages ── */
#acw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f8fb;
  min-height: 200px;
  max-height: 320px;
}
#acw-messages::-webkit-scrollbar { width: 4px; }
#acw-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.acw-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.acw-msg.acw-user {
  background: var(--acw-accent, #4F46E5);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.acw-msg.acw-bot {
  background: #fff;
  color: #1f1f2e;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Typing indicator */
.acw-typing {
  display: flex; gap:5px; align-items:center;
  padding: 10px 13px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.acw-typing span {
  width: 7px; height: 7px;
  background: #aaa; border-radius: 50%;
  animation: acwBounce 1.2s infinite;
}
.acw-typing span:nth-child(2) { animation-delay:.2s; }
.acw-typing span:nth-child(3) { animation-delay:.4s; }
@keyframes acwBounce {
  0%,80%,100% { transform:translateY(0); }
  40%         { transform:translateY(-6px); }
}

/* ── Lead Form ── */
#acw-lead-form {
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid #eee;
  display: none;
}
#acw-lead-form p {
  margin: 0 0 10px;
  font-size: 13px;
  color: #555;
}
#acw-lead-form input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  outline: none;
  transition: border 0.2s;
}
#acw-lead-form input:focus { border-color: var(--acw-accent, #4F46E5); }
#acw-lead-submit {
  width: 100%;
  padding: 9px;
  background: var(--acw-accent, #4F46E5);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
#acw-lead-submit:hover { opacity: 0.88; }

/* ── Input Bar ── */
#acw-input-bar {
  display: flex;
  padding: 10px 12px;
  gap: 8px;
  border-top: 1px solid #eee;
  background: #fff;
  align-items: flex-end;
}
#acw-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.4;
  font-family: inherit;
  transition: border 0.2s;
}
#acw-input:focus { border-color: var(--acw-accent, #4F46E5); }
#acw-send {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--acw-accent, #4F46E5);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
  /* Send icon via CSS mask – works everywhere, can't be stripped */
  -webkit-mask-image: none;
  mask-image: none;
}
#acw-send::after {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  background: #fff;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 21l21-9L2 3v7l15 2-15 2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 21l21-9L2 3v7l15 2-15 2z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}
#acw-send:hover { opacity: 0.88; }
#acw-send svg { width:17px; height:17px; fill:#fff; }

#acw-powered {
  text-align: center;
  font-size: 11px;
  color: #bbb;
  padding: 4px 0 8px;
  background: #fff;
}

/* Mobile */
@media (max-width: 420px) {
  #acw-window { width: calc(100vw - 32px); }
  #acw-root   { bottom: 16px; right: 16px; }
}

/* ── Client admin styles (injected via wp_head on admin pages) ── */
