/* theme.css — меняй только переменные в :root */

body { overflow-x: hidden; }

:root {
  --brand-primary:     #3b71ca;
  --brand-primary-rgb: 59, 113, 202;
  --brand-danger:      #dc4c64;
  --brand-success:     #14a44d;
  --brand-success-rgb: 20, 164, 77;
  --brand-border:      #bdbdbd;

  --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-font-size:  0.9rem;

  --bs-border-radius:    0.375rem;
  --bs-border-radius-sm: 0.25rem;
  --bs-border-radius-lg: 0.5rem;

  --bs-body-bg: #f8f9fa;
  --bs-card-bg: #ffffff;
}


/* ── Кнопки ──────────────────────────────────────────────────────── */
.btn-primary {
  --mdb-btn-bg:           var(--brand-primary);
  --mdb-btn-border-color: var(--brand-primary);
  --mdb-btn-hover-bg:     var(--brand-primary);
  --mdb-btn-focus-bg:     var(--brand-primary);
  --mdb-btn-active-bg:    var(--brand-primary);
}
.btn { box-shadow: none !important; }


/* ── Инпуты ──────────────────────────────────────────────────────── */
.form-outline .form-control {
  padding-top: 0.9rem;
  padding-bottom: 0.6rem;
  line-height: 1.5;
}
.form-outline .form-control ~ .form-label { padding-top: 0.8rem; }
.form-outline .form-control:focus ~ .form-label,
.form-outline .form-control.active ~ .form-label {
  transform: translateY(-1.3rem) translateY(0.1rem) scale(0.8);
}


/* ── Dropzone ─────────────────────────────────────────────────────── */
.dropzone {
  display: block;
  border: 2px dashed var(--mdb-form-control-border-color);
  border-radius: var(--bs-border-radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bs-card-bg);
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover,
.dropzone--active {
  border-color: var(--brand-primary);
  background: rgba(var(--brand-primary-rgb), 0.05);
}
.dropzone--selected {
  border-color: var(--brand-success);
  background: rgba(var(--brand-success-rgb), 0.05);
}


/* ── Note item ────────────────────────────────────────────────────── */
.note-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--mdb-form-control-border-color);
  background: var(--bs-card-bg);
  transition: background 0.15s;
}
.note-item:last-child { border-bottom: none; }
.note-item:hover      { background: var(--bs-body-bg); }
.note-item__body      { flex: 1; min-width: 0; }
.note-item__title     { font-size: 0.875rem; font-weight: 500; }
.note-item__text      { font-size: 0.8125rem; color: #6c757d; margin-top: 2px; line-height: 1.5; }
.note-item__delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--brand-danger);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
  transition: opacity 0.15s;
}
.note-item:hover .note-item__delete { opacity: 1; }


/* ── Chat bubbles ─────────────────────────────────────────────────── */
.msg-bubble {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-start;
}
.msg-bubble--user         { flex-direction: row-reverse; }
.msg-bubble--user .msg-bubble__body { max-width: 70%; }
.msg-bubble--ai .msg-bubble__body   { flex: 1; min-width: 0; }
.msg-bubble__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.msg-bubble__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-bubble__text {
  font-size: 0.875rem;
  line-height: 1.65;
  word-break: break-word;
}
.msg-bubble--user .msg-bubble__text {
  background: var(--brand-primary);
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-right-radius: 4px;
}
.msg-bubble__meta-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.msg-bubble__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e9ecef;
  font-size: 14px;
  flex-shrink: 0;
  color: #6c757d;
  margin-top: 2px;
}
.msg-bubble__time { font-size: 0.7rem; color: #adb5bd; margin-top: 4px; }
.msg-bubble--user .msg-bubble__time { text-align: right; }


/* ── Chat input ───────────────────────────────────────────────────── */
.chat-input-wrap {
  display: flex;
  flex-direction: column;
  border: 2px solid transparent;
  outline: 1px solid var(--mdb-form-control-border-color);
  border-radius: var(--bs-border-radius);
  transition: outline-color 0.2s;
}
.chat-input-wrap:focus-within {
  outline: none;
  border-color: var(--brand-primary);
}
.chat-input-wrap textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 10px 12px 6px;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.5;
  max-height: 200px;
  display: block;
}
.chat-input-wrap__actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px 8px 8px;
}
.chat-input__attachment  { position: relative; }
.chat-input__attachment img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--bs-border-radius-sm);
  border: 1px solid var(--brand-border);
  display: block;
}
.chat-input__attachment-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--brand-danger);
  color: #fff;
  border: none;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-input__attach { cursor: pointer; }

@keyframes pulse-mic {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
.btn--recording { animation: pulse-mic 1s ease-in-out infinite; }


/* ── Wiki / База знаний ───────────────────────────────────────────── */
.wiki-layout {
  display: flex;
  height: calc(100vh - 80px);
  margin: -20px;
}

.wiki-nav {
  width: 320px;
  min-width: 320px;
  background: var(--bs-card-bg);
  border-right: 1px solid var(--brand-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.wiki-nav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--brand-border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  font-weight: 600;
}

.wiki-nav__header a {
  color: #6c757d;
  text-decoration: none;
  font-size: 1rem;
  transition: color 0.15s;
}
.wiki-nav__header a:hover { color: var(--brand-primary); }

.wiki-nav ul {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
}

.wiki-nav__item {
  display: flex;
  align-items: center;
}

.wiki-nav__link {
  flex: 1;
  display: block;
  padding: 10px 20px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #333;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.wiki-nav__link:hover {
  background: var(--bs-body-bg);
  color: var(--brand-primary);
}
.wiki-nav__link.active {
  background: rgba(var(--brand-primary-rgb), 0.08);
  color: var(--brand-primary);
  border-left-color: var(--brand-primary);
  font-weight: 500;
}

.wiki-nav__delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--brand-danger);
  cursor: pointer;
  font-size: 12px;
  padding: 0 12px;
  transition: opacity 0.15s;
}
.wiki-nav__item:hover .wiki-nav__delete { opacity: 1; }

.wiki-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px 60px;
}

.wiki-content h1 { font-size: 1.6rem; margin-bottom: 1rem; color: #1a1a2e; }
.wiki-content h2 { font-size: 1.2rem; margin-top: 2rem; color: #1a1a2e; }
.wiki-content h3 { font-size: 1rem;   margin-top: 1.5rem; color: #1a1a2e; }
.wiki-content p, .wiki-content li { line-height: 1.75; color: #444; }
.wiki-content img { max-width: 100%; border-radius: var(--bs-border-radius); margin: 1rem 0; }
.wiki-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.wiki-content th, .wiki-content td { padding: 8px 12px; border: 1px solid var(--brand-border); font-size: 0.875rem; }
.wiki-content th { background: var(--bs-body-bg); font-weight: 600; }
.wiki-content ul, .wiki-content ol { padding-left: 1.5rem; margin: 0.75rem 0; }
.wiki-content ul { list-style: disc; }
.wiki-content ol { list-style: decimal; }
.wiki-content li { margin-bottom: 0.25rem; }
.wiki-content code { background: #f1f3f5; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; color: #c0392b; }
.wiki-content pre { background: #f1f3f5; border: 1px solid var(--brand-border); border-radius: var(--bs-border-radius); padding: 1rem; overflow-x: auto; margin: 1rem 0; }
.wiki-content pre code { background: none; padding: 0; color: inherit; font-size: 0.875rem; }

.wiki-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}