/* AI-Talapker Chatbot — ВКУ им. Сарсена Аманжолова */
:root {
  --aitlp-primary: #3056D3;
  --aitlp-primary-dark: #2244b8;
  --aitlp-primary-light: #e8edfb;
  --aitlp-bg: #F7F7F7;
  --aitlp-white: #ffffff;
  --aitlp-text: #1a1a2e;
  --aitlp-text-muted: #6b7280;
  --aitlp-border: #e5e7eb;
  --aitlp-radius: 16px;
  --aitlp-shadow: 0 8px 32px rgba(48,86,211,0.18), 0 2px 8px rgba(0,0,0,0.08);
  --aitlp-shadow-btn: 0 4px 16px rgba(48,86,211,0.35);
}

/* ── Toggle button ─────────────────────────────────────────── */
#aitlp-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  background: var(--aitlp-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--aitlp-shadow-btn);
  z-index: 99998;
  transition: transform 0.2s, box-shadow 0.2s;
}
#aitlp-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(48,86,211,0.45);
}
#aitlp-toggle svg {
  width: 30px;
  height: 30px;
  fill: #fff;
}
#aitlp-toggle .aitlp-close-icon { display: none; }
#aitlp-toggle.open .aitlp-cap-icon  { display: none; }
#aitlp-toggle.open .aitlp-close-icon { display: block; }

/* ── Notification dot ──────────────────────────────────────── */
#aitlp-dot {
  position: fixed;
  bottom: 78px;
  right: 28px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
  z-index: 99999;
  animation: aitlp-pulse 2s infinite;
}
@keyframes aitlp-pulse {
  0%,100%{ box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50%    { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

/* ── Chat window ───────────────────────────────────────────── */
#aitlp-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 370px;
  max-height: 580px;
  background: var(--aitlp-white);
  border-radius: var(--aitlp-radius);
  box-shadow: var(--aitlp-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99997;
  overflow: hidden;
  transform: scale(0.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.2s;
}
#aitlp-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ────────────────────────────────────────────────── */
#aitlp-header {
  background: var(--aitlp-primary);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#aitlp-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#aitlp-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}
#aitlp-header-text { flex: 1; }
#aitlp-header-text h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}
#aitlp-header-text p {
  margin: 0;
  font-size: 11px;
  color: rgba(255,255,255,0.75);
}
#aitlp-status {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.6);
  flex-shrink: 0;
}

/* ── Messages area ─────────────────────────────────────────── */
#aitlp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--aitlp-bg);
  scroll-behavior: smooth;
}
#aitlp-messages::-webkit-scrollbar { width: 4px; }
#aitlp-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── Bubbles ───────────────────────────────────────────────── */
.aitlp-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: aitlp-fade 0.22s ease;
}
@keyframes aitlp-fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.aitlp-row.user { flex-direction: row-reverse; }
.aitlp-bot-av {
  width: 28px;
  height: 28px;
  background: var(--aitlp-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.aitlp-bot-av svg { width: 16px; height: 16px; fill: #fff; }
.aitlp-bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.aitlp-row.bot .aitlp-bubble {
  background: var(--aitlp-white);
  color: var(--aitlp-text);
  border-radius: 4px 14px 14px 14px;
  border: 1px solid var(--aitlp-border);
}
.aitlp-row.user .aitlp-bubble {
  background: var(--aitlp-primary);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}
.aitlp-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.aitlp-src-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--aitlp-primary);
  text-decoration: none;
  background: var(--aitlp-primary-light);
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid rgba(48,86,211,0.2);
  transition: background 0.15s;
}
.aitlp-src-link:hover { background: #d1daf7; }
.aitlp-src-link svg { width: 11px; height: 11px; stroke: var(--aitlp-primary); fill: none; }

/* ── Typing dots ───────────────────────────────────────────── */
#aitlp-typing { display: none; }
#aitlp-typing.visible { display: flex; }
.aitlp-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 2px;
}
.aitlp-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--aitlp-text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: aitlp-bounce 1.1s infinite;
}
.aitlp-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.aitlp-typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes aitlp-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-5px); }
}

/* ── Chips ─────────────────────────────────────────────────── */
#aitlp-chips {
  padding: 8px 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--aitlp-bg);
  border-top: 1px solid var(--aitlp-border);
}
.aitlp-chip {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid rgba(48,86,211,0.3);
  color: var(--aitlp-primary);
  background: var(--aitlp-white);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.aitlp-chip:hover {
  background: var(--aitlp-primary);
  color: #fff;
  border-color: var(--aitlp-primary);
}

/* ── Input row ─────────────────────────────────────────────── */
#aitlp-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--aitlp-border);
  background: var(--aitlp-white);
  flex-shrink: 0;
}
#aitlp-input {
  flex: 1;
  border: 1px solid var(--aitlp-border);
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--aitlp-bg);
  color: var(--aitlp-text);
  outline: none;
  resize: none;
  min-height: 38px;
  max-height: 80px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color 0.15s;
}
#aitlp-input:focus { border-color: var(--aitlp-primary); }
#aitlp-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--aitlp-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}
#aitlp-send:hover { opacity: 0.88; }
#aitlp-send:active { transform: scale(0.95); }
#aitlp-send svg { width: 18px; height: 18px; stroke: #fff; fill: none; }

/* ── Powered by ────────────────────────────────────────────── */
#aitlp-footer {
  text-align: center;
  padding: 5px 0 7px;
  font-size: 10.5px;
  color: var(--aitlp-text-muted);
  background: var(--aitlp-white);
  border-top: 1px solid var(--aitlp-border);
  flex-shrink: 0;
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #aitlp-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
  }
  #aitlp-toggle { bottom: 16px; right: 16px; }
  #aitlp-dot { bottom: 66px; right: 16px; }
}
