/* QA 2.0 — современный интерфейс вопросов и ответов.
   Всё пространство имён ограничено #qa-app / .qa-* чтобы не задеть тему сайта. */
#qa-app {
  --qa-bg: #f4f7fb;
  --qa-card: #ffffff;
  --qa-ink: #1e293b;
  --qa-muted: #7b8798;
  --qa-line: #e6ecf3;
  --qa-accent: #2563eb;
  --qa-accent2: #12b886;
  --qa-radius: 16px;
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  color: var(--qa-ink);
}
#qa-app * { box-sizing: border-box; }
#qa-app.qa-wrap {
  display: flex;
  gap: 18px;
  min-height: 560px;
  margin: 8px 0 24px;
}
#qa-app .qa-col { display: flex; flex-direction: column; min-width: 0; }
#qa-app .qa-side { width: 330px; flex: 0 0 330px; }
#qa-app .qa-main { flex: 1 1 auto; }
@media (max-width: 900px) {
  #qa-app.qa-wrap { flex-direction: column; }
  #qa-app .qa-side { width: 100%; flex: none; max-height: 320px; }
}

#qa-app .qa-card {
  background: var(--qa-card);
  border: 1px solid var(--qa-line);
  border-radius: var(--qa-radius);
  box-shadow: 0 8px 28px rgba(20, 40, 80, .06);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#qa-app .qa-card-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--qa-line);
  background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
}
#qa-app .qa-card-title {
  font-size: 17px; font-weight: 700; letter-spacing: -.2px;
  display: flex; align-items: center; gap: 8px;
}
#qa-app .qa-card-title .qa-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--qa-accent2); box-shadow: 0 0 0 4px rgba(18,184,134,.12);
}
#qa-app .qa-card-sub { color: var(--qa-muted); font-size: 12px; margin-top: 3px; }

#qa-app .qa-new {
  display: block; width: 100%; margin: 12px 0 10px;
  padding: 11px 14px; border: 0; border-radius: 11px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(37,99,235,.25);
  transition: transform .15s, box-shadow .15s;
}
#qa-app .qa-new:hover { transform: translateY(-1px); box-shadow: 0 9px 20px rgba(37,99,235,.32); }
#qa-app .qa-search {
  width: 100%; padding: 9px 12px; border: 1px solid var(--qa-line);
  border-radius: 10px; font-size: 13px; outline: none; background: #fbfdff;
}
#qa-app .qa-search:focus { border-color: var(--qa-accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

#qa-app .qa-threads { overflow-y: auto; flex: 1; padding: 8px; }
#qa-app .qa-thread {
  position: relative; display: block; width: 100%; text-align: left;
  border: 0; background: transparent; border-radius: 12px;
  padding: 11px 12px; margin-bottom: 4px; cursor: pointer;
  transition: background .15s;
}
#qa-app .qa-thread:hover { background: #f3f7fd; }
#qa-app .qa-thread.qa-active { background: #eaf1ff; }
#qa-app .qa-thread-top { display: flex; gap: 8px; align-items: baseline; }
#qa-app .qa-thread-subject {
  font-size: 13px; font-weight: 700; color: var(--qa-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
#qa-app .qa-thread-time { font-size: 11px; color: var(--qa-muted); white-space: nowrap; }
#qa-app .qa-thread-preview {
  font-size: 12px; color: var(--qa-muted); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#qa-app .qa-thread-user { font-size: 11px; color: var(--qa-accent); margin-top: 3px; }
#qa-app .qa-badge {
  display: inline-block; min-width: 18px; height: 18px; line-height: 18px;
  border-radius: 9px; background: var(--qa-accent); color: #fff;
  font-size: 11px; font-weight: 700; text-align: center; padding: 0 5px;
}
#qa-app .qa-tag {
  display: inline-block; padding: 2px 7px; border-radius: 7px;
  background: #e8f1ff; color: #1d4ed8; font-size: 10px; font-weight: 700;
  white-space: nowrap; vertical-align: middle;
}
#qa-app .qa-empty {
  padding: 40px 20px; text-align: center; color: var(--qa-muted); font-size: 14px;
}
#qa-app .qa-empty .qa-ico { font-size: 38px; display: block; margin-bottom: 10px; opacity: .7; }

#qa-app .qa-chat-head {
  padding: 15px 20px; border-bottom: 1px solid var(--qa-line);
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #f8fbff, #eef4ff);
}
#qa-app .qa-avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 38px;
  background: linear-gradient(135deg, #60a5fa, #2563eb); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
#qa-app .qa-chat-title { font-weight: 700; font-size: 15px; }
#qa-app .qa-chat-meta { font-size: 12px; color: var(--qa-muted); margin-top: 2px; }
#qa-app .qa-chat-actions { margin-left: auto; display: flex; gap: 6px; }
#qa-app .qa-icon-btn {
  border: 1px solid var(--qa-line); background: #fff; border-radius: 9px;
  width: 32px; height: 32px; cursor: pointer; color: var(--qa-muted); font-size: 14px;
}
#qa-app .qa-icon-btn:hover { color: var(--qa-accent); border-color: var(--qa-accent); }

#qa-app .qa-messages {
  flex: 1; overflow-y: auto; padding: 22px 20px;
  background: var(--qa-bg);
  display: flex; flex-direction: column; gap: 14px;
  min-height: 300px;
}
#qa-app .qa-msg { max-width: 78%; display: flex; flex-direction: column; }
#qa-app .qa-msg.qa-them { align-self: flex-start; align-items: flex-start; }
#qa-app .qa-msg.qa-me { align-self: flex-end; align-items: flex-end; }
#qa-app .qa-bubble {
  padding: 11px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5;
  word-wrap: break-word; white-space: pre-wrap; box-shadow: 0 2px 8px rgba(20,40,80,.05);
}
#qa-app .qa-them .qa-bubble {
  background: #fff; border: 1px solid var(--qa-line); border-bottom-left-radius: 5px;
}
#qa-app .qa-me .qa-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff;
  border-bottom-right-radius: 5px;
}
#qa-app .qa-msg.qa-admin .qa-bubble {
  background: linear-gradient(135deg, #12b886, #0ca678); color: #fff;
  border-bottom-left-radius: 5px;
}
#qa-app .qa-msg-meta { font-size: 11px; color: var(--qa-muted); margin-top: 5px; padding: 0 4px; }

#qa-app .qa-composer {
  border-top: 1px solid var(--qa-line); padding: 12px 14px; background: #fff;
  display: flex; gap: 10px; align-items: flex-end;
}
#qa-app .qa-composer textarea {
  flex: 1; resize: none; height: 46px; max-height: 140px;
  border: 1px solid var(--qa-line); border-radius: 11px; padding: 12px 14px;
  font-size: 14px; font-family: inherit; outline: none; background: #fbfdff;
}
#qa-app .qa-composer textarea:focus { border-color: var(--qa-accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
#qa-app .qa-send {
  border: 0; border-radius: 11px; padding: 0 20px; height: 46px;
  background: var(--qa-accent); color: #fff; font-weight: 700; cursor: pointer;
}
#qa-app .qa-send:disabled { opacity: .5; cursor: default; }

/* модальное окно */
.qa-modal-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(3px);
}
.qa-modal, .qa-modal * { box-sizing: border-box; }
.qa-modal {
  width: 100%; max-width: 480px; background: #fff; border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,.22); overflow: hidden;
  font-family: 'Inter', Arial, Helvetica, sans-serif;
}
.qa-modal-head { padding: 18px 20px 12px; font-size: 17px; font-weight: 700; }
.qa-modal-body { padding: 0 20px 18px; }
.qa-modal-body input, .qa-modal-body textarea {
  width: 100%; border: 1px solid #e6ecf3; border-radius: 11px;
  padding: 11px 13px; font-size: 14px; font-family: inherit; outline: none; margin-bottom: 10px;
  background: #fbfdff;
}
.qa-modal-body input:focus, .qa-modal-body textarea:focus { border-color: #2563eb; }
.qa-modal-body textarea { height: 110px; resize: vertical; }
.qa-modal-foot { display: flex; gap: 10px; padding: 0 20px 20px; }
.qa-modal-foot button {
  flex: 1; padding: 11px; border-radius: 11px; border: 0; font-weight: 700; cursor: pointer;
}
.qa-modal-foot .qa-cancel { background: #eef2f7; color: #475569; }
.qa-modal-foot .qa-ok { background: #2563eb; color: #fff; }

/* тосты */
.qa-toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 10000;
  background: #1e293b; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s;
  pointer-events: none; max-width: 360px;
}
.qa-toast.qa-show { opacity: 1; transform: translateY(0); }
.qa-toast.qa-error { background: #b42318; }

/* улучшенная форма вопроса на страницах урока/эфира */
.qa-ask, .qa-ask * { box-sizing: border-box; }
.qa-ask { width: 100%; max-width: 100%; background: #f8fbff; border: 1px solid #e6ecf3; border-radius: 14px; padding: 12px; margin: 12px 0; overflow: hidden; }
.qa-ask .qa-ask-label { font-size: 12px; color: #7b8798; margin-bottom: 6px; }
.qa-ask input, .qa-ask textarea {
  width: 100%; max-width: 100%; display: block;
  border: 1px solid #e6ecf3; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none; resize: vertical;
  background: #fff;
}
.qa-ask input { margin-bottom: 10px; }
.qa-ask textarea { min-height: 64px; }
.qa-ask input:focus, .qa-ask textarea:focus { border-color: #2563eb; }
.qa-ask .qa-ask-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.qa-ask button {
  flex: 0 0 auto; max-width: 100%; white-space: nowrap;
  border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 700;
  background: #2563eb; color: #fff; cursor: pointer;
}
.qa-ask .qa-ask-hint { font-size: 12px; color: #7b8798; }

/* счётчик в меню */
.qa-menu-count {
  display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px;
  border-radius: 9px; background: #2563eb; color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
}
