/* ═══ LAMAPIXEL CHAT WIDGET (site-wide floating) ═══ */

:root {
  --lpc-bg: #0A0A0A;
  --lpc-bg-2: #141414;
  --lpc-bg-3: #1a1a1a;
  --lpc-border: rgba(255,255,255,.08);
  --lpc-text: #EDEDED;
  --lpc-muted: #8A8A8A;
  --lpc-lime: #CDFF64;
  --lpc-accent: #FF9800;
  --lpc-accent-d: #E68900;
  --lpc-ease: cubic-bezier(.4,0,.2,1);
}

.lpchat, .lpchat * { box-sizing: border-box; }
.lpchat [hidden] { display: none !important; }
.lpchat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── FAB ── */
.lpchat__fab {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--lpc-accent), var(--lpc-accent-d));
  color: #0A0A0A;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 40px rgba(255,152,0,.35), 0 2px 10px rgba(0,0,0,.2);
  transition: transform .25s var(--lpc-ease), box-shadow .25s var(--lpc-ease);
}
.lpchat__fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 18px 50px rgba(255,152,0,.5); }
.lpchat__fab:active { transform: translateY(-1px) scale(.98); }
.lpchat__fab-ico { display:block; }
.lpchat__fab-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lpc-lime);
  box-shadow: 0 0 0 0 rgba(205,255,100,.5);
  animation: lpcPulse 2s ease-in-out infinite;
}
@keyframes lpcPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(205,255,100,.5); }
  50%      { box-shadow: 0 0 0 8px rgba(205,255,100,0); }
}
.lpchat__fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #ff3b30;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid var(--lpc-bg);
}

.lpchat--open .lpchat__fab { transform: scale(0); opacity: 0; pointer-events: none; }

/* ── Панель ── */
.lpchat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: calc(100vw - 20px);
  height: 560px;
  max-height: calc(100vh - 40px);
  background: var(--lpc-bg);
  border: 1px solid var(--lpc-border);
  color: var(--lpc-text);
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s var(--lpc-ease), opacity .28s var(--lpc-ease);
}
.lpchat--open .lpchat__panel {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* ── Верхняя панель ── */
.lpchat__bar {
  background: var(--lpc-bg-2);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--lpc-border);
}
.lpchat__ctrl { display: flex; gap: 6px; }
.lpchat__ctrl span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.lpchat__ctrl span:first-child { background: #ff605c; }
.lpchat__ctrl span:nth-child(2) { background: #ffbd44; }
.lpchat__ctrl span:nth-child(3) { background: #00ca4e; }
.lpchat__bar-title {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--lpc-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.lpchat__live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lpc-lime);
  animation: lpcPulse 2s ease-in-out infinite;
}
.lpchat__close {
  background: none;
  border: none;
  color: var(--lpc-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color .15s;
}
.lpchat__close:hover { color: var(--lpc-text); }

/* ── Экраны ── */
.lpchat__screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lpchat__screen[hidden] { display: none; }

/* ── Intro ── */
.lpchat__intro {
  padding: 26px 22px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lpchat__intro-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.lpchat__intro-sub {
  color: var(--lpc-muted);
  font-size: 14px;
  margin-bottom: 16px;
}
.lpchat__form { display: flex; flex-direction: column; gap: 14px; }
.lpchat__label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--lpc-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.lpchat__label small { text-transform: none; letter-spacing: 0; opacity: .7; }
.lpchat__label input {
  background: var(--lpc-bg-2);
  border: 1px solid var(--lpc-border);
  color: var(--lpc-text);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.lpchat__label input:focus { border-color: var(--lpc-accent); }
.lpchat__submit {
  margin-top: 8px;
  background: var(--lpc-lime);
  color: #0A0A0A;
  border: none;
  padding: 13px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  clip-path: polygon(3% 0%, 100% 4%, 97% 100%, 0% 95%);
  transition: transform .15s, background .2s;
}
.lpchat__submit:hover { background: #b8f04a; transform: translateY(-1px); }
.lpchat__submit:disabled { opacity: .5; cursor: default; }

/* ── Chat body ── */
.lpchat__body {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.lpchat__msg {
  max-width: 82%;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: lpcMsgIn .3s var(--lpc-ease) forwards;
  opacity: 0;
  transform: translateY(10px);
}
@keyframes lpcMsgIn { to { opacity: 1; transform: translateY(0); } }
.lpchat__msg--u {
  background: var(--lpc-accent);
  color: #0A0A0A;
  align-self: flex-end;
  clip-path: polygon(0% 0%, 100% 3%, 98% 96%, 2% 100%);
  font-weight: 500;
}
.lpchat__msg--b {
  background: var(--lpc-bg-2);
  border: 1px solid var(--lpc-border);
  color: #D0D0D0;
  align-self: flex-start;
  clip-path: polygon(2% 3%, 100% 0%, 97% 100%, 0% 96%);
}
.lpchat__msg--b .lpchat__av {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.lpchat__msg--b .lpchat__av svg { width: 14px; height: 14px; flex-shrink: 0; }
.lpchat__msg--b .lpchat__av span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--lpc-accent);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.lpchat__msg-edited {
  font-size: 10px;
  opacity: .6;
  font-style: italic;
  margin-left: 4px;
}

/* AI-бейдж в шапке baббла ассистента */
.lpchat__msg--b.lpchat__msg--ai {
  border-color: rgba(205,255,100,.25);
  box-shadow: 0 0 0 1px rgba(205,255,100,.12);
}
.lpchat__ai-chip {
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #0A0A0A !important;
  background: var(--lpc-lime);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}

/* Карточка waiting_op — интерактивный обратный отсчёт */
.lpchat__wait {
  align-self: stretch;
  padding: 12px 14px;
  margin: 4px 0;
  background: var(--lpc-bg-2);
  border: 1px solid var(--lpc-border);
  border-left: 3px solid var(--lpc-accent);
  color: var(--lpc-text);
  clip-path: polygon(1% 0%, 100% 2%, 99% 100%, 0% 97%);
  animation: lpcMsgIn .3s var(--lpc-ease) forwards;
  opacity: 0;
  transform: translateY(10px);
}
.lpchat__wait-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--lpc-accent);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.lpchat__wait-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lpc-accent);
  animation: lpcPulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.lpchat__wait-title {
  font-weight: 600;
  display: inline-flex;
  align-items: baseline;
  gap: 0;
}
.lpchat__wait-dots {
  display: inline-block;
  min-width: 24px;
  text-align: left;
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--lpc-accent);
}
.lpchat__wait-bar {
  margin-top: 8px;
  height: 2px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
  border-radius: 1px;
}
.lpchat__wait-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--lpc-accent), var(--lpc-lime));
  transition: width 1s linear;
}

/* Карточка ai_fallback */
.lpchat__fallback {
  align-self: stretch;
  padding: 14px 16px;
  margin: 4px 0;
  background: var(--lpc-bg-2);
  border: 1px solid rgba(205,255,100,.25);
  border-left: 3px solid var(--lpc-lime);
  color: var(--lpc-text);
  clip-path: polygon(1% 0%, 100% 2%, 99% 100%, 0% 97%);
  animation: lpcMsgIn .3s var(--lpc-ease) forwards;
  opacity: 0;
  transform: translateY(10px);
}
.lpchat__fallback-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--lpc-accent);
  font-weight: 700;
}
.lpchat__fallback-icon { font-size: 14px; }
.lpchat__fallback-body {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--lpc-text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.lpchat__fallback-icon {
  display: inline-flex;
  align-items: center;
  color: var(--lpc-accent);
}
.lpchat__fallback-foot {
  margin-top: 10px;
  font-size: 12px;
}
.lpchat__fallback-mail {
  color: var(--lpc-accent);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
}
.lpchat__fallback-mail:hover { text-decoration: underline; }

/* Разделитель «Новый разговор» после долгой паузы */
.lpchat__sys {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 6px 0 2px;
  color: var(--lpc-muted);
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
  animation: lpcMsgIn .3s var(--lpc-ease) forwards;
  opacity: 0;
  transform: translateY(10px);
}
.lpchat__sys::before,
.lpchat__sys::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--lpc-border);
}
.lpchat__sys-label {
  flex-shrink: 0;
  color: var(--lpc-accent);
}

/* Typing indicator */
.lpchat__typing {
  padding: 0 16px 14px;
  margin-top: -6px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.lpchat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lpc-muted);
  animation: lpcDot 1.2s infinite ease-in-out;
}
.lpchat__typing span:nth-child(2) { animation-delay: .15s; }
.lpchat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes lpcDot {
  0%, 80%, 100% { opacity: .2; transform: translateY(0); }
  40%           { opacity: 1;  transform: translateY(-3px); }
}

/* Input */
.lpchat__input {
  border-top: 1px solid var(--lpc-border);
  background: var(--lpc-bg-2);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.lpchat__input input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--lpc-text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.lpchat__input input::placeholder { color: var(--lpc-muted); }
.lpchat__input button {
  background: var(--lpc-accent);
  color: #0A0A0A;
  border: none;
  width: 36px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  clip-path: polygon(3% 0%, 100% 4%, 96% 100%, 0% 95%);
  transition: transform .15s;
  flex-shrink: 0;
}
.lpchat__input button:hover { transform: scale(1.08); }
.lpchat__input button:disabled { opacity: .4; cursor: default; }

/* ── Scrollbar ── */
.lpchat__body::-webkit-scrollbar { width: 5px; }
.lpchat__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

/* ── Light theme ── */
[data-theme="light"] .lpchat {
  --lpc-bg: #FFFFFF;
  --lpc-bg-2: #F5F5F5;
  --lpc-bg-3: #EBEBEB;
  --lpc-border: rgba(0,0,0,.08);
  --lpc-text: #1A1A1A;
  --lpc-muted: #6B6B6B;
}
[data-theme="light"] .lpchat__msg--b { color: #2A2A2A; }
[data-theme="light"] .lpchat__label input,
[data-theme="light"] .lpchat__bar { background: var(--lpc-bg-2); }

/* ── Mobile ── */
@media (max-width: 500px) {
  .lpchat { right: 14px; bottom: 14px; }
  .lpchat__fab { width: 54px; height: 54px; }
  .lpchat__panel {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    max-height: none;
  }
}
