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

: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; }

/* ── Alpine.js ────────────────────────────────────────────────────────────── */
[x-cloak] { display: none !important; }

/* ── Collapsible card toggle header ──────────────────────────────────────── */
.card-toggle-header { cursor: pointer; user-select: none; }

/* ── Autocomplete ─────────────────────────────────────────────────────────── */
.autocomplete { position: relative; flex: 1; min-width: 0; }
.autocomplete__dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 1050;
  background: var(--bs-body-bg);
  border: 1px solid var(--brand-border);
  border-radius: var(--bs-border-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-height: 240px; overflow-y: auto;
}
.autocomplete__item { padding: 8px 12px; cursor: pointer; }
.autocomplete__item:hover { background: rgba(var(--brand-primary-rgb), 0.07); }
.autocomplete__item-label { font-size: 0.875rem; }
.autocomplete__item-meta { font-size: 0.75rem; color: #6c757d; }

/* ── Checklist (keyword / competitor lists) ───────────────────────────────── */
.checklist { max-height: 280px; overflow-y: auto; border: 1px solid var(--brand-border); border-radius: var(--bs-border-radius); }
.checklist--full { max-height: none; overflow-y: visible; }
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--brand-border);
  cursor: pointer;
  transition: background 0.12s;
}
.checklist-item:last-child  { border-bottom: none; }
.checklist-item:hover       { background: var(--bs-body-bg); }
.checklist-item.is-selected { background: rgba(var(--brand-primary-rgb), 0.07); }
.checklist-item__check { flex-shrink: 0; margin-top: 2px; font-size: 1.1rem; color: #bdbdbd; }
.checklist-item.is-selected .checklist-item__check { color: var(--brand-primary); }
.checklist-item__body  { flex: 1; min-width: 0; }
.checklist-item__label { font-size: 0.875rem; font-weight: 500; }
.checklist-item__meta  { font-size: 0.775rem; color: #6c757d; margin-top: 1px; }


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


/* ── Page loader ───────────────────────────────────────────────────── */
body.loading { cursor: wait; }
body.loading::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.5);
  z-index: 9998;
}
body.loading::after {
  content: '';
  display: block;
  position: fixed;
  top: calc(50% - 20px);
  left: calc(50% - 20px);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(var(--brand-primary-rgb), 0.2);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  z-index: 9999;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }