/* ========== Общие стили модуля ассистентов ========== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3142; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3a4255; }

body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

/* Карточка ассистента в списке */
.asst-card {
  display: block;
  padding: 18px;
  border-radius: 16px;
  background: #11141b;
  border: 1px solid #222836;
  transition: border-color .2s, transform .15s, box-shadow .2s;
  text-decoration: none;
  color: inherit;
}
.asst-card:hover {
  border-color: rgba(124, 92, 255, .5);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
}
.asst-card-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.asst-stat {
  background: #0f1119;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #1a2030;
}
.asst-stat-label { font-size: 10px; color: #8a93a6; text-transform: uppercase; letter-spacing: .05em; }
.asst-stat-value { font-size: 16px; font-weight: 700; margin-top: 2px; }

/* Бейджи провайдеров */
.provider-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #1a2030;
  color: #c9cdd9;
}
.provider-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}

/* SPA вкладки ассистента */
.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  color: #c9cdd9;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.tab-btn:hover { background: #161a23; }
.tab-btn.active {
  background: linear-gradient(135deg, rgba(124,92,255,.18), rgba(34,211,238,.10));
  border-color: rgba(124,92,255,.35);
  color: #fff;
}
.tab-btn .tab-ico { font-size: 16px; }

/* Документы */
.doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #11141b;
  border: 1px solid #222836;
  border-radius: 12px;
  transition: border-color .2s, background .2s;
}
.doc-row:hover { border-color: rgba(124,92,255,.4); background: #131722; }
.doc-row .doc-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(124,92,255,.20), rgba(34,211,238,.12));
  font-size: 18px;
  flex-shrink: 0;
}
.doc-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid;
}
.doc-status.pending  { color: #fbbf24; border-color: rgba(251,191,36,.4);  background: rgba(251,191,36,.08); }
.doc-status.chunking { color: #38bdf8; border-color: rgba(56,189,248,.4);  background: rgba(56,189,248,.08); }
.doc-status.ready    { color: #22c55e; border-color: rgba(34,197,94,.4);   background: rgba(34,197,94,.08); }
.doc-status.error    { color: #ef4444; border-color: rgba(239,68,68,.4);   background: rgba(239,68,68,.08); }

/* Drag-n-drop зона */
.drop-zone {
  border: 2px dashed #2a3142;
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: rgba(124,92,255,.6);
  background: rgba(124,92,255,.05);
}

/* Чанки документа */
.chunk-item {
  background: #0f1119;
  border: 1px solid #1a2030;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: #c9cdd9;
  white-space: pre-wrap;
  word-break: break-word;
}
.chunk-item .chunk-head {
  display: flex; justify-content: space-between;
  font-size: 10px; color: #6b7280;
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 6px;
}

/* Чат-тест */
.msg { display: flex; gap: 10px; animation: fadeIn .2s ease; }
.msg-user { justify-content: flex-end; }
.bubble {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg-user .bubble {
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-assistant .bubble {
  background: #161a23;
  border: 1px solid #222836;
  color: #e6e8ee;
  border-bottom-left-radius: 4px;
}
.msg-sources {
  margin-top: 6px;
  font-size: 11px;
  color: #8a93a6;
}
.msg-sources details summary { cursor: pointer; color: #a78bfa; }
.msg-sources details summary:hover { color: #c9cdd9; }
.source-chunk {
  background: #0f1119;
  border: 1px solid #1a2030;
  padding: 8px 10px;
  border-radius: 8px;
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11.5px;
  max-height: 200px;
  overflow-y: auto;
}
.avatar-ai {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  color: white; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #8a93a6;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Модалка создания */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-card {
  background: #11141b;
  border: 1px solid #222836;
  border-radius: 18px;
  width: 100%; max-width: 520px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

/* Бейджи статистики */
.kpi {
  background: #11141b;
  border: 1px solid #222836;
  border-radius: 14px;
  padding: 14px 16px;
}
.kpi-label { font-size: 11px; color: #8a93a6; text-transform: uppercase; letter-spacing: .06em; }
.kpi-value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.kpi-sub   { font-size: 11px; color: #6b7280; margin-top: 2px; }

/* ===== Токены API ===== */
.token-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center; gap: 12px;
  padding: 12px 14px;
  background: #11141b;
  border: 1px solid #222836;
  border-radius: 12px;
}
.token-row.revoked { opacity: 0.55; }
.token-prefix {
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  font-size: 12.5px; color: #a78bfa;
}
.token-meta { font-size: 11px; color: #8a93a6; }

.code-block {
  background: #0a0c12;
  border: 1px solid #1a2030;
  border-radius: 10px;
  padding: 12px 14px;
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #c9cdd9;
  white-space: pre;
  overflow-x: auto;
  position: relative;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: #1a2030; color: #c9cdd9;
  border: 1px solid #2a3142;
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  cursor: pointer; transition: background .15s;
}
.copy-btn:hover { background: #2a3142; }
.copy-btn.copied { background: #22c55e22; color: #22c55e; border-color: #22c55e44; }

/* ===== Лиды ===== */
.lead-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 2fr auto;
  gap: 12px; align-items: center;
  padding: 10px 14px;
  background: #11141b;
  border: 1px solid #222836;
  border-radius: 10px;
  font-size: 13px;
}
.lead-row .lead-date { color: #8a93a6; font-size: 11.5px; }

/* ===== Разговоры ===== */
.conv-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 14px;
  background: #11141b;
  border: 1px solid #222836;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.conv-row:hover { border-color: rgba(124,92,255,.4); background: #131722; }
.conv-source {
  font-size: 10px; padding: 2px 6px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .05em;
}
.conv-source.admin  { background: #7c5cff22; color: #a78bfa; }
.conv-source.widget { background: #22d3ee22; color: #67e8f9; }
.conv-source.api    { background: #22c55e22; color: #22c55e; }

/* Inline-форма лида прямо в чате */
.lead-inline {
  margin: 14px 0 6px 38px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(124,92,255,.08), rgba(34,211,238,.06));
  border: 1px solid rgba(124,92,255,.35);
  border-radius: 14px;
  animation: leadPop .25s ease-out;
}
@keyframes leadPop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lead-inline-head {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px;
}
.lead-inline-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.lead-inline-title { font-size: 13px; font-weight: 600; color: #e6e8ee; }
.lead-inline-sub   { font-size: 11px; color: #8a93a6; margin-top: 2px; }
.lead-inline-form  {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.lead-inline-input {
  background: #0b0d12;
  border: 1px solid #222836;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #e6e8ee;
  outline: none;
  transition: border-color .15s;
}
.lead-inline-input:focus { border-color: rgba(124,92,255,.5); }
.lead-inline-input[name="message"] { grid-column: span 2; }
.lead-inline-actions {
  grid-column: span 2;
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  margin-top: 4px;
}
.lead-inline-cancel {
  font-size: 12px; padding: 7px 14px;
  background: transparent; color: #8a93a6;
  border: 1px solid #222836; border-radius: 8px;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.lead-inline-cancel:hover { color: #e6e8ee; border-color: #333a4d; }
.lead-inline-submit {
  font-size: 12px; padding: 7px 16px;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  color: white; font-weight: 600;
  border: none; border-radius: 8px;
  cursor: pointer; transition: opacity .15s;
}
.lead-inline-submit:hover { opacity: .9; }
.lead-inline-submit:disabled { opacity: .5; cursor: default; }
.lead-inline-status { grid-column: span 2; font-size: 12px; min-height: 16px; }
.lead-inline-ok { color: #22c55e; font-weight: 600; }

/* ===== Виджет — превью ===== */
.theme-color-dot {
  width: 32px; height: 32px; border-radius: 8px;
  border: 2px solid transparent; cursor: pointer;
  transition: transform .15s;
}
.theme-color-dot:hover { transform: scale(1.1); }
.theme-color-dot.active { border-color: white; box-shadow: 0 0 0 2px #7c5cff; }
.position-btn {
  padding: 8px;
  background: #11141b; border: 1px solid #222836;
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #8a93a6;
}
.position-btn.active { border-color: #7c5cff; color: #a78bfa; background: #7c5cff15; }
