/* css/chat.css — стили встроенного чата */

/* ── Виджет-обёртка ─────────────────────────────────────────────────── */
#cx-chat-widget {
  --chat-bg: #ffffff;
  --chat-bg2: #f4f7fb;
  --chat-primary: #ff7b1f;
  --chat-primary-d: #e06510;
  --chat-text: #1a2540;
  --chat-muted: #6b7da0;
  --chat-border: #e2e8f4;
  --chat-bot-bg: #f0f4fb;
  --chat-user-bg: #ff7b1f;
  --chat-user-text: #fff;
  --chat-radius: 20px;
  --chat-shadow: 0 8px 32px rgba(10,30,80,.10);

  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  border: 1px solid var(--chat-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: 700px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  color: var(--chat-text);
}

/* ── Шапка ───────────────────────────────────────────────────────────── */
.cx-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #050914, #0d2a73);
  color: #fff;
  flex-shrink: 0;
}

.cx-chat-header__avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cx-chat-header__avatar svg {
  width: 22px; height: 22px;
  fill: #71bcff;
}

.cx-chat-header__info { flex: 1; min-width: 0; }
.cx-chat-header__title {
  font-weight: 700; font-size: 15px; line-height: 1.2;
}
.cx-chat-header__sub {
  font-size: 12px; color: rgba(255,255,255,.65); margin-top: 2px;
}
.cx-chat-header__status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #6dffc5;
}
.cx-chat-header__status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6dffc5;
  animation: cxBlink 2s ease-in-out infinite;
}
@keyframes cxBlink {
  0%,100% { opacity: 1; } 50% { opacity: .35; }
}

/* ── Форма регистрации ───────────────────────────────────────────────── */
#cx-reg-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 28px;
  background: var(--chat-bg2);
}

.cx-reg-title {
  font-size: 18px; font-weight: 700; margin-bottom: 6px;
  color: var(--chat-text);
}
.cx-reg-sub {
  font-size: 13px; color: var(--chat-muted); margin-bottom: 22px;
}

.cx-reg-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.cx-reg-field label {
  font-size: 12px; font-weight: 600;
  color: var(--chat-muted); text-transform: uppercase; letter-spacing: .05em;
}
.cx-reg-field input {
  padding: 11px 14px;
  border: 1.5px solid var(--chat-border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--chat-text);
  background: #fff;
  transition: border-color .2s;
  outline: none;
}
.cx-reg-field input:focus { border-color: var(--chat-primary); }

.cx-reg-error {
  color: #d03030; font-size: 13px;
  margin-bottom: 10px; min-height: 18px;
}

.cx-reg-submit {
  margin-top: 4px;
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--chat-primary), #ff9d4a);
  color: #fff;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 8px 20px rgba(255,123,31,.25);
}
.cx-reg-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(255,123,31,.35);
}

/* ── Интерфейс чата ──────────────────────────────────────────────────── */
#cx-chat-interface {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Пользователь-бейдж ──────────────────────────────────────────────── */
.cx-chat-user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--chat-bg2);
  border-bottom: 1px solid var(--chat-border);
  font-size: 13px;
  color: var(--chat-muted);
  flex-shrink: 0;
}
.cx-chat-user-bar svg {
  width: 14px; height: 14px;
  fill: var(--chat-muted);
  flex-shrink: 0;
}
#cx-chat-username { font-weight: 600; color: var(--chat-text); }

/* ── Лента сообщений ─────────────────────────────────────────────────── */
#cx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
#cx-chat-messages::-webkit-scrollbar { width: 5px; }
#cx-chat-messages::-webkit-scrollbar-track { background: transparent; }
#cx-chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 4px; }

#cx-chat-messages.cx-drag-over {
  outline: 2px dashed var(--chat-primary);
  outline-offset: -4px;
}

/* ── Сообщение ───────────────────────────────────────────────────────── */
.cx-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
}
.cx-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.cx-msg--bot  { align-self: flex-start; }

.cx-msg__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--chat-bot-bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cx-msg__avatar svg {
  width: 16px; height: 16px;
  fill: #2672df;
}

.cx-msg__bubble {
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.55;
  word-break: break-word;
}
.cx-msg--bot  .cx-msg__bubble { background: var(--chat-bot-bg); border-bottom-left-radius: 6px; }
.cx-msg--user .cx-msg__bubble {
  background: var(--chat-user-bg);
  color: var(--chat-user-text);
  border-bottom-right-radius: 6px;
}
.cx-msg__bubble p { margin: 0; }
.cx-msg__bubble p + p { margin-top: 6px; }

/* ── Файл-чип ────────────────────────────────────────────────────────── */
.cx-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.25);
  border: 1px solid rgba(255,255,255,.35);
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
  transition: background .2s;
  max-width: 220px;
  overflow: hidden;
}
.cx-msg--bot .cx-file-chip {
  background: rgba(38,114,223,.08);
  border-color: rgba(38,114,223,.2);
  color: #2672df;
}
.cx-file-chip:hover { background: rgba(255,255,255,.4); }
.cx-msg--bot .cx-file-chip:hover { background: rgba(38,114,223,.14); }
.cx-file-chip svg {
  width: 15px; height: 15px;
  fill: currentColor; flex-shrink: 0;
}
.cx-file-chip span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Typing indicator ────────────────────────────────────────────────── */
#cx-chat-typing {
  display: none;
  align-self: flex-start;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--chat-bot-bg);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}
.cx-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--chat-muted);
  animation: cxDot 1.2s ease-in-out infinite;
}
.cx-dot:nth-child(2) { animation-delay: .2s; }
.cx-dot:nth-child(3) { animation-delay: .4s; }
@keyframes cxDot {
  0%,80%,100% { transform: scale(.6); opacity: .4; }
  40%          { transform: scale(1);  opacity: 1;  }
}

/* ── Панель ввода ────────────────────────────────────────────────────── */
.cx-chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-bg);
  flex-shrink: 0;
}

.cx-chat-file-btn {
  width: 38px; height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--chat-bg2);
  color: var(--chat-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.cx-chat-file-btn:hover { background: var(--chat-border); color: var(--chat-text); }
.cx-chat-file-btn svg { width: 18px; height: 18px; fill: currentColor; }

#cx-chat-input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid var(--chat-border);
  border-radius: 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--chat-text);
  background: var(--chat-bg2);
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color .2s;
  line-height: 1.4;
}
#cx-chat-input:focus { border-color: var(--chat-primary); background: #fff; }
#cx-chat-input::placeholder { color: var(--chat-muted); }

#cx-chat-send {
  width: 42px; height: 42px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), #ff9d4a);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 4px 12px rgba(255,123,31,.30);
  flex-shrink: 0;
}
#cx-chat-send:hover { transform: scale(1.08); box-shadow: 0 6px 18px rgba(255,123,31,.40); }
#cx-chat-send svg { width: 18px; height: 18px; fill: #fff; }

/* ── Уведомление ──────────────────────────────────────────────────────── */
.cx-notice {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #1a2540;
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: cxFadeIn .25s ease;
}
@keyframes cxFadeIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* ── Мобильный ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #cx-chat-widget { border-radius: 14px; min-height: 440px; }
  #cx-reg-form { padding: 24px 18px; }
  .cx-msg { max-width: 94%; }
}
