/* ═══════════════════════════════════════════════
   chatbot.css — Premium AI Chat v4
   Matches Core3 site theme exactly
═══════════════════════════════════════════════ */

/* ── Toggle Button ── */
#chat-toggle {
  position: fixed;
  bottom: 30px; right: 30px;
  z-index: 9990;
  width: 62px; height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff 0%, #c8ccd6 100%);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  outline: none;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
  animation: toggle-pulse 3s ease-in-out infinite;
}
/* Spinning conic ring */
#chat-toggle::before {
  content: '';
  position: absolute;
  inset: -3px; border-radius: 50%;
  background: conic-gradient(from 0deg, #ffffff, #aab0c0, #6e7280, #ffffff);
  z-index: -1;
  opacity: 0;
  animation: spin-ring 3s linear infinite;
  transition: opacity .3s;
}
#chat-toggle:hover::before { opacity: 1; }
#chat-toggle:hover { transform: scale(1.1) translateY(-3px); animation: none; }
#chat-toggle.open { animation: none; transform: scale(1); }
#chat-toggle.open::before { opacity: 0; }

@keyframes toggle-pulse {
  0%,100% { box-shadow: 0 6px 28px rgba(255,255,255,.5), 0 0 0 0 rgba(255,255,255,.3); }
  50%      { box-shadow: 0 6px 28px rgba(255,255,255,.5), 0 0 0 18px rgba(255,255,255,0); }
}
@keyframes spin-ring { to { transform: rotate(360deg); } }

.ct-icon, .ct-close {
  position: absolute; color: #000000; font-size: 1.3rem;
  transition: opacity .22s, transform .3s cubic-bezier(.34,1.56,.64,1);
}
.ct-close { opacity: 0; transform: rotate(-90deg) scale(.4); }
#chat-toggle.open .ct-icon  { opacity: 0; transform: rotate(90deg) scale(.4); }
#chat-toggle.open .ct-close { opacity: 1; transform: rotate(0) scale(1); }

/* Hover tooltip */
.ct-label {
  position: absolute; right: 70px;
  background: #0c0c0e;
  border: 1px solid rgba(255,255,255,.2);
  color: #f4f5f8;
  font-family: 'Inter', sans-serif; font-size: .71rem; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; white-space: nowrap;
  pointer-events: none; opacity: 0; transform: translateX(8px);
  transition: opacity .2s, transform .2s;
  box-shadow: 0 4px 18px rgba(0,0,0,.7);
}
#chat-toggle:hover .ct-label  { opacity: 1; transform: translateX(0); }
#chat-toggle.open  .ct-label  { display: none; }

/* Badge */
.chat-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: #ef4444; color: #fff;
  font-size: .58rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #000000; font-family: 'Inter', sans-serif;
  box-shadow: 0 2px 8px rgba(239,68,68,.5);
  animation: badge-pop .4s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes badge-pop { from { transform: scale(0); } to { transform: scale(1); } }
#chat-toggle.open .chat-badge { transform: scale(0); transition: transform .2s; }

/* ── Chat Window ── */
#chat-window {
  position: fixed;
  bottom: 108px; right: 30px;
  z-index: 9989;
  width: 380px; height: 600px;
  border-radius: 22px;
  background: #000000;
  border: 1px solid rgba(255,255,255,.15);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.06),
    0 32px 80px rgba(0,0,0,.9),
    0 0 60px rgba(255,255,255,.05),
    inset 0 1px 0 rgba(255,255,255,.1);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(20px) scale(.94); pointer-events: none;
  transition: opacity .35s cubic-bezier(.16,1,.3,1), transform .35s cubic-bezier(.16,1,.3,1);
  font-family: 'Inter', sans-serif;
}
/* Animated gradient top border */
#chat-window::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 10;
  background: linear-gradient(90deg, transparent 0%, #ffffff 20%, #aab0c0 50%, #6e7280 80%, transparent 100%);
  background-size: 200% 100%;
  animation: border-flow 3s linear infinite;
}
/* Floating particles */
#chat-window::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 75% 10%, rgba(170,176,192,.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 60%, rgba(110,114,128,.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 75%, rgba(255,255,255,.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 85%, rgba(170,176,192,.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 30%, rgba(255,255,255,.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 40%, rgba(110,114,128,.25) 0%, transparent 100%);
  animation: particles-drift 20s linear infinite;
}
@keyframes border-flow {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@keyframes particles-drift {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-30px); }
}

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

@media(max-width: 520px) {
  #chat-window { width: calc(100vw - 12px); right: 6px; bottom: 82px; height: calc(100svh - 105px); border-radius: 20px; }
  #chat-toggle  { bottom: 18px; right: 18px; width: 56px; height: 56px; }
}

/* ── Header ── */
.cw-header {
  flex-shrink: 0; z-index: 2; position: relative;
  background: linear-gradient(135deg, #0c0c0e 0%, #141416 100%);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.cw-header-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 60% 120% at 0% 50%, rgba(255,255,255,.07), transparent);
}
.cw-header-top {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; position: relative;
}
/* Mac-style bar */
.cw-header-bar {
  padding: 5px 16px;
  background: rgba(0,0,0,.3);
  border-top: 1px solid rgba(255,255,255,.04);
  display: flex; align-items: center; justify-content: space-between;
}
.cw-hbar-left {
  display: flex; align-items: center; gap: 6px;
  font-size: .61rem; color: rgba(233,235,242,.28); font-family: 'Inter', monospace;
}
.cw-hbar-left i { color: rgba(255,255,255,.45); font-size: .55rem; }
.cw-hbar-right { display: flex; gap: 5px; align-items: center; }
.cw-dot { width: 8px; height: 8px; border-radius: 50%; }
.cw-dot-r { background: #ef4444; }
.cw-dot-y { background: #f59e0b; }
.cw-dot-g { background: #ffffff; box-shadow: 0 0 6px rgba(255,255,255,.7); animation: dot-blink 2s ease-in-out infinite; }

/* Avatar */
.cw-av {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0; position: relative;
  background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(170,176,192,.07));
  border: 1px solid rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(255,255,255,.15), inset 0 1px 0 rgba(255,255,255,.08);
}
.cw-av i { color: #ffffff; font-size: 1.1rem; }
.cw-online {
  position: absolute; bottom: -3px; right: -3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle, #ffffff, #ffffff);
  border: 2.5px solid #000000;
  animation: online-ping 2s ease-in-out infinite;
}
@keyframes online-ping {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,.6), 0 0 8px rgba(255,255,255,.9); }
  50%      { box-shadow: 0 0 0 5px rgba(255,255,255,0), 0 0 16px rgba(255,255,255,.8); }
}

.cw-info { flex: 1; min-width: 0; }
.cw-name {
  font-family: 'Syne', sans-serif; font-size: .9rem; font-weight: 700; color: #f4f5f8;
  display: flex; align-items: center; gap: 7px;
}
.cw-ai-badge {
  background: linear-gradient(135deg, rgba(255,255,255,.15), rgba(170,176,192,.1));
  border: 1px solid rgba(255,255,255,.25); border-radius: 5px;
  padding: 2px 7px; font-size: .5rem; font-weight: 800;
  letter-spacing: 2px; text-transform: uppercase; color: #ffffff;
  font-family: 'Inter', sans-serif;
}
.cw-status { font-size: .64rem; color: rgba(255,255,255,.7); display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.cw-status-dot { width: 5px; height: 5px; border-radius: 50%; background: #ffffff; box-shadow: 0 0 5px #ffffff; }
@keyframes dot-blink { 0%,100%{opacity:1} 50%{opacity:.2} }

.cw-header-actions { display: flex; gap: 5px; }
.cw-hbtn {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
  color: rgba(233,235,242,.35); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .7rem;
  transition: all .2s;
}
.cw-hbtn:hover { background: rgba(255,255,255,.08); color: #ffffff; border-color: rgba(255,255,255,.2); }

/* ── Banner ── */
.cw-banner {
  margin: 12px 12px 0; padding: 10px 14px;
  background: linear-gradient(135deg, rgba(255,255,255,.06), rgba(170,176,192,.03));
  border: 1px solid rgba(255,255,255,.11); border-radius: 13px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  position: relative; overflow: hidden; z-index: 1;
}
.cw-banner::before {
  content: ''; position: absolute; top: 0; left: -100%; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  animation: banner-shine 3s ease-in-out infinite;
}
@keyframes banner-shine { 0%{left:-100%} 60%,100%{left:100%} }
.cw-banner-icon { font-size: 1.1rem; flex-shrink: 0; }
.cw-banner-text { font-size: .73rem; color: rgba(233,235,242,.6); line-height: 1.5; }
.cw-banner-text strong { color: #ffffff; font-weight: 600; }

/* ── Messages ── */
.cw-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 12px; min-height: 0;
  position: relative; z-index: 1;
}
.cw-messages::-webkit-scrollbar { width: 2px; }
.cw-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 2px; }

.msg { display: flex; gap: 8px; align-items: flex-end; animation: msg-in .3s cubic-bezier(.16,1,.3,1) both; }
@keyframes msg-in { from { opacity:0; transform:translateY(12px) scale(.97); } to { opacity:1; transform:translateY(0) scale(1); } }
.msg.user { flex-direction: row-reverse; }

.msg-av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .75rem;
}
.msg.bot  .msg-av {
  background: linear-gradient(135deg, rgba(255,255,255,.1), rgba(170,176,192,.06));
  border: 1px solid rgba(255,255,255,.2); color: #ffffff;
}
.msg.user .msg-av {
  background: linear-gradient(135deg, #ffffff, #c8ccd6);
  color: #000000; font-size: .52rem; font-weight: 800;
  box-shadow: 0 3px 10px rgba(255,255,255,.4);
}

.msg-body { max-width: 80%; display: flex; flex-direction: column; }
.msg.user .msg-body { align-items: flex-end; }

/* Bot bubble */
.msg.bot .msg-bubble {
  padding: 10px 14px; font-size: .82rem; line-height: 1.68; word-break: break-word;
  background: #0c0c0e;
  border: 1px solid rgba(255,255,255,.1);
  border-left: 2px solid #ffffff;
  color: rgba(233,235,242,.88);
  border-radius: 3px 16px 16px 16px;
  box-shadow: 0 2px 16px rgba(0,0,0,.4), 0 0 20px rgba(255,255,255,.03);
  position: relative; overflow: hidden;
}
.msg.bot .msg-bubble::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.08), transparent);
}
/* User bubble */
.msg.user .msg-bubble {
  padding: 10px 14px; font-size: .82rem; line-height: 1.68; word-break: break-word;
  background: linear-gradient(135deg, rgba(255,255,255,.14), rgba(190,190,200,.08));
  border: 1px solid rgba(255,255,255,.2);
  color: #f4f5f8;
  border-radius: 16px 3px 16px 16px;
  box-shadow: 0 2px 16px rgba(255,255,255,.1);
}
.msg-time { font-size: .57rem; color: rgba(233,235,242,.18); margin-top: 3px; padding: 0 2px; }

/* Typing */
.msg.typing .msg-bubble { padding: 13px 16px; }
.typing-dots { display: flex; gap: 5px; align-items: center; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; animation: tdot 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(1) { background: #ffffff; }
.typing-dots span:nth-child(2) { background: #aab0c0; animation-delay: .2s; }
.typing-dots span:nth-child(3) { background: #6e7280; animation-delay: .4s; }
@keyframes tdot { 0%,80%,100%{transform:scale(.55) translateY(0);opacity:.3} 40%{transform:scale(1.1) translateY(-5px);opacity:1} }

/* ── Quick Replies ── */
.cw-quick {
  padding: 0 12px 10px; display: flex; flex-wrap: wrap; gap: 7px;
  flex-shrink: 0; z-index: 1; position: relative;
}
.qr-chip {
  background: #0c0c0e;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 100px; padding: 6px 13px;
  font-size: .71rem; color: rgba(233,235,242,.6);
  cursor: pointer; transition: all .25s cubic-bezier(.34,1.56,.64,1);
  font-family: 'Inter', sans-serif; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.qr-chip i { font-size: .62rem; color: rgba(255,255,255,.6); transition: color .2s; }
.qr-chip:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.3);
  color: #f4f5f8; transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 18px rgba(0,0,0,.4), 0 0 12px rgba(255,255,255,.12);
}
.qr-chip:hover i { color: #ffffff; }

/* ── Input ── */
.cw-input-wrap {
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255,255,255,.04);
  background: #0c0c0e;
  flex-shrink: 0; z-index: 1; position: relative;
}
.cw-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  background: #141416;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px; padding: 7px 7px 7px 14px;
  transition: border-color .2s, box-shadow .2s;
}
.cw-input-row:focus-within {
  border-color: rgba(255,255,255,.3);
  box-shadow: 0 0 0 3px rgba(255,255,255,.06), 0 0 20px rgba(255,255,255,.04);
}
#chat-input {
  flex: 1; background: transparent; border: none; color: #f4f5f8;
  font-family: 'Inter', sans-serif; font-size: .82rem;
  resize: none; outline: none; min-height: 34px; max-height: 90px; line-height: 1.55; padding: 3px 0;
}
#chat-input::placeholder { color: rgba(233,235,242,.2); }

#chat-send {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #ffffff, #c8ccd6); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .2s, opacity .2s;
  box-shadow: 0 4px 14px rgba(255,255,255,.35);
}
#chat-send:hover:not(:disabled) { transform: scale(1.12) translateY(-1px); box-shadow: 0 7px 22px rgba(255,255,255,.55); }
#chat-send:active:not(:disabled) { transform: scale(.9); }
#chat-send:disabled { opacity: .35; cursor: not-allowed; }
#chat-send i { color: #000000; font-size: .85rem; }

.cw-input-hint {
  text-align: center; font-size: .56rem; color: rgba(233,235,242,.12);
  margin-top: 6px; font-family: 'Inter', sans-serif;
}
.cw-input-hint span { color: rgba(255,255,255,.25); font-weight: 600; }
