/* ── Chat Widget Styles ─────────────────────────────────────────────────────── */
:root {
  --chat-primary: #6366f1;
  --chat-primary-dark: #4f46e5;
  --chat-radius: 20px;
}

/* ── Cursor glow layer (follows mouse inside the widget) ────────────────────── */
#ycai-cursor-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--chat-radius);
  overflow: hidden;
  z-index: 0;
}
#ycai-cursor-glow::after {
  content: '';
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.18) 0%, rgba(139,92,246,.08) 45%, transparent 70%);
  transform: translate(-50%, -50%);
  left: var(--glow-x, -200px);
  top: var(--glow-y, -200px);
  transition: left .06s linear, top .06s linear;
  pointer-events: none;
}

#ycai-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), #8b5cf6);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 8px 32px rgba(99,102,241,.55), 0 2px 8px rgba(0,0,0,.18);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  z-index: 99998;
  outline: none;
}
#ycai-chat-btn:hover { transform: scale(1.1) translateY(-2px); box-shadow: 0 14px 40px rgba(99,102,241,.65); }
#ycai-chat-btn.open { transform: scale(0.9); }
#ycai-chat-btn .badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  background: #ef4444;
  color: white;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  border: 2px solid white;
  animation: ycai-pop .3s cubic-bezier(.34,1.56,.64,1);
}

#ycai-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  border-radius: var(--chat-radius);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.28), 0 4px 16px rgba(0,0,0,.12);
  z-index: 99997;
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.2,.64,1), opacity .25s ease;
  backdrop-filter: blur(20px);
  background: rgba(15,23,42,.97);
  border: 1px solid rgba(255,255,255,.1);
  isolation: isolate;
}
#ycai-chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#ycai-header {
  background: linear-gradient(135deg, var(--chat-primary) 0%, #8b5cf6 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#ycai-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.35);
  overflow: hidden;
}
#ycai-avatar img { width: 100%; height: 100%; object-fit: cover; }
#ycai-header-info { flex: 1; }
#ycai-header-title { color: white; font-weight: 700; font-size: 15px; line-height: 1.2; }
#ycai-header-status { color: rgba(255,255,255,.75); font-size: 12px; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
#ycai-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80;
  animation: ycai-pulse 2s infinite;
}
#ycai-status-dot.offline { background: #fbbf24; animation: none; }
#ycai-close-btn {
  background: rgba(255,255,255,.15);
  border: none; cursor: pointer;
  color: white; width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: background .18s, transform .18s, box-shadow .18s;
}
#ycai-close-btn:hover {
  background: rgba(255,255,255,.32);
  transform: scale(1.12);
  box-shadow: 0 0 12px rgba(255,255,255,.25);
}

/* Body / Views */
#ycai-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }

/* Pre-chat form */
#ycai-prechat {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
#ycai-prechat::-webkit-scrollbar { width: 4px; }
#ycai-prechat::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
#ycai-prechat-title {
  color: white;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
#ycai-prechat-sub {
  color: rgba(255,255,255,.5);
  font-size: 12.5px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.ycai-field { margin-bottom: 12px; }
.ycai-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
}
.ycai-field input,
.ycai-field select,
.ycai-field textarea {
  width: 100%;
  background: rgba(255,255,255,.07);
  border: 1.5px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  color: white;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
  box-sizing: border-box;
  cursor: text;
}
.ycai-field select { cursor: pointer; }
.ycai-field input::placeholder,
.ycai-field textarea::placeholder { color: rgba(255,255,255,.28); }
.ycai-field input:hover,
.ycai-field select:hover,
.ycai-field textarea:hover {
  border-color: rgba(99,102,241,.45);
  background: rgba(255,255,255,.1);
}
.ycai-field input:focus,
.ycai-field select:focus,
.ycai-field textarea:focus {
  border-color: rgba(99,102,241,.85);
  background: rgba(99,102,241,.08);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15), 0 0 12px rgba(99,102,241,.12);
}
.ycai-field select option { background: #1e293b; color: white; }
.ycai-field textarea { resize: none; }
.ycai-consent {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 14px 0;
}
.ycai-consent input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--chat-primary); width: 15px; height: 15px; }
.ycai-consent label {
  font-size: 11.5px;
  color: rgba(255,255,255,.5);
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0;
}
.ycai-honeypot { display: none !important; }
#ycai-prechat-error {
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.4);
  border-radius: 8px;
  padding: 9px 12px;
  color: #fca5a5;
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
}
#ycai-start-btn {
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--chat-primary), #8b5cf6);
  color: white;
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  box-shadow: 0 4px 16px rgba(99,102,241,.4);
}
#ycai-start-btn:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 28px rgba(99,102,241,.6), 0 0 20px rgba(139,92,246,.3);
}
#ycai-start-btn:active { transform: translateY(0) scale(.98); }
#ycai-start-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* Chat messages area */
#ycai-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
#ycai-messages-area::-webkit-scrollbar { width: 4px; }
#ycai-messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.ycai-msg { display: flex; flex-direction: column; max-width: 82%; }
.ycai-msg.visitor { align-self: flex-end; align-items: flex-end; }
.ycai-msg.admin, .ycai-msg.n8n, .ycai-msg.system { align-self: flex-start; align-items: flex-start; }

.ycai-bubble {
  padding: 9px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  transition: filter .18s, box-shadow .18s;
  cursor: default;
}
.ycai-msg.visitor .ycai-bubble {
  background: linear-gradient(135deg, var(--chat-primary), #8b5cf6);
  color: white;
  border-bottom-right-radius: 4px;
}
.ycai-msg.visitor .ycai-bubble:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 18px rgba(99,102,241,.45);
}
.ycai-msg.admin .ycai-bubble {
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.9);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,.08);
}
.ycai-msg.admin .ycai-bubble:hover {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.18);
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.ycai-msg.n8n .ycai-bubble {
  background: rgba(16,185,129,.15);
  color: #6ee7b7;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(16,185,129,.25);
}
.ycai-msg.n8n .ycai-bubble:hover {
  background: rgba(16,185,129,.22);
  border-color: rgba(16,185,129,.4);
}
.ycai-msg.system .ycai-bubble {
  background: rgba(99,102,241,.12);
  color: rgba(255,255,255,.6);
  font-size: 12px;
  padding: 7px 12px;
  border: 1px solid rgba(99,102,241,.2);
  border-radius: 12px;
  font-style: italic;
}
.ycai-msg-time {
  font-size: 10.5px;
  color: rgba(255,255,255,.28);
  margin-top: 3px;
  padding: 0 3px;
}
.ycai-msg.admin .ycai-sender {
  font-size: 10.5px;
  color: rgba(255,255,255,.4);
  margin-bottom: 3px;
  padding: 0 3px;
}

/* Typing indicator */
#ycai-typing {
  display: none;
  align-self: flex-start;
  padding: 9px 14px;
  background: rgba(255,255,255,.08);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,.08);
}
#ycai-typing span {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.4);
  animation: ycai-bounce 1.2s infinite;
}
#ycai-typing span:nth-child(2) { animation-delay: .2s; }
#ycai-typing span:nth-child(3) { animation-delay: .4s; }

/* Input bar */
#ycai-input-bar {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  gap: 9px;
  align-items: flex-end;
  flex-shrink: 0;
  background: rgba(0,0,0,.2);
}
#ycai-input {
  flex: 1;
  background: rgba(255,255,255,.07);
  border: 1.5px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13.5px;
  color: white;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
  cursor: text;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
#ycai-input::placeholder { color: rgba(255,255,255,.28); }
#ycai-input:hover {
  border-color: rgba(99,102,241,.45);
  background: rgba(255,255,255,.1);
}
#ycai-input:focus {
  border-color: rgba(99,102,241,.85);
  background: rgba(99,102,241,.08);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15), 0 0 14px rgba(99,102,241,.12);
}
#ycai-send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), #8b5cf6);
  border: none;
  cursor: pointer;
  color: white;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  box-shadow: 0 3px 10px rgba(99,102,241,.4);
}
#ycai-send-btn:hover {
  transform: scale(1.18) translateY(-1px);
  box-shadow: 0 6px 22px rgba(99,102,241,.65), 0 0 16px rgba(139,92,246,.4);
}
#ycai-send-btn:active { transform: scale(.95); }
#ycai-send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

/* Closed notice */
#ycai-closed-bar {
  padding: 10px 16px;
  background: rgba(239,68,68,.12);
  border-top: 1px solid rgba(239,68,68,.2);
  color: #fca5a5;
  font-size: 12px;
  text-align: center;
  flex-shrink: 0;
  display: none;
}

/* Offline notice */
#ycai-offline-bar {
  padding: 9px 16px;
  background: rgba(251,191,36,.1);
  border-top: 1px solid rgba(251,191,36,.2);
  color: #fde68a;
  font-size: 12px;
  text-align: center;
  flex-shrink: 0;
  display: none;
}

@keyframes ycai-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
@keyframes ycai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-5px); opacity: 1; }
}
@keyframes ycai-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

@media (max-width: 480px) {
  #ycai-chat-window {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
  }
  #ycai-chat-btn { bottom: 20px; right: 20px; }
}
