/* Плавающая кнопка коуча + выезжающая панель чата */

.coach-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #7c3aed 100%));
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--brand-1, #2563eb) 35%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  z-index: 9000;
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.coach-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--brand-1, #2563eb) 50%, transparent);
}
.coach-fab:active { transform: scale(0.95); }

.coach-fab .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

.coach-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 9001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.coach-panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.coach-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  background: #fff;
  z-index: 9002;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.15);
}
.coach-panel.open { transform: translateX(0); }

.coach-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #7c3aed 100%));
  color: #fff;
}
.coach-panel-header .title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.coach-panel-header .actions {
  display: flex;
  gap: 4px;
}
.coach-panel-header button {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.2s;
}
.coach-panel-header button:hover { background: rgba(255, 255, 255, 0.35); }

.coach-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.coach-msg {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: msgIn 0.25s ease-out;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.coach-msg.user {
  align-self: flex-end;
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #7c3aed 100%));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.coach-msg.assistant {
  align-self: flex-start;
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}
.coach-msg.assistant.typing::after {
  content: "▋";
  animation: blink 1s infinite;
  color: var(--brand-2, #7c3aed);
  font-weight: 700;
}
@keyframes blink { 50% { opacity: 0.2; } }

.coach-empty {
  text-align: center;
  color: #64748b;
  padding: 40px 20px;
  font-size: 14px;
  line-height: 1.5;
}
.coach-empty .emoji { font-size: 48px; margin-bottom: 12px; }
.coach-empty .suggest {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 20px;
}
.coach-empty .suggest button {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  color: #0f172a;
  transition: all 0.2s;
  font-family: inherit;
}
.coach-empty .suggest button:hover {
  border-color: var(--brand-1, #2563eb);
  background: #eff6ff;
}

.coach-input-wrap {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.coach-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.coach-input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  font-family: inherit;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s;
}
.coach-input:focus { border-color: #2563eb; background: #fff; }

.coach-send-btn, .coach-mic-btn {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
  flex-shrink: 0;
  font-family: inherit;
}
.coach-send-btn {
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #7c3aed 100%));
  color: #fff;
}
.coach-send-btn:hover { transform: scale(1.05); }
.coach-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.coach-mic-btn {
  background: #f1f5f9;
  color: #0f172a;
  border: 1.5px solid #e2e8f0;
}
.coach-mic-btn:hover { border-color: #2563eb; }
.coach-mic-btn.recording {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border-color: transparent;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }

@media (max-width: 480px) {
  .coach-fab { right: 12px; bottom: 12px; width: 52px; height: 52px; font-size: 22px; }
  .coach-panel { max-width: 100%; }
  .coach-fab-svg { width: 24px; height: 24px; }
}

/* Brand SVG inside FAB / panel title / empty state (Партия 8.5) */
.coach-fab-svg {
  width: 28px; height: 28px; color: var(--brand-text, #fff);
  stroke: currentColor; fill: none; pointer-events: none;
}
.coach-title-svg {
  width: 22px; height: 22px; color: var(--brand-text, #fff);
  stroke: currentColor; fill: none; vertical-align: -5px; margin-right: 4px;
}
.coach-empty-svg {
  width: 56px; height: 56px; color: var(--brand-1, #7c3aed);
  stroke: currentColor; fill: none;
}

/* ──────────── Coach-chat panel v2: chips + floating mic + actions ──────────── */

/* Chips: горизонтальный wrap, scroll на узких экранах. */
.coach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  max-height: 86px;
  overflow-y: auto;
}
.coach-chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  font-size: 12px;
  color: #0f172a;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}
.coach-chip:hover { background: #e0e7ff; border-color: #6366f1; }
.coach-chip-tip { display: none; }  /* legacy markup safety: tip → теперь в title-attr */

/* Textarea с микрофоном внутри. .textarea-mic-wrap дублирует .coach-input-textarea
   как алиас (в JS используется оба класса). */
.textarea-mic-wrap,
.coach-input-textarea {
  position: relative;
  width: 100%;
  margin-bottom: 10px;
}
.textarea-mic-wrap .coach-input,
.coach-input-textarea .coach-input {
  width: 100%;
  min-height: 90px;
  max-height: 240px;
  padding: 12px 52px 12px 14px;  /* справа место для floating-mic */
  box-sizing: border-box;
}
.mic-floating {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f8fafc;
  border: 1.5px solid #c7d2fe;
  color: #6366f1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.mic-floating:hover { background: #eef2ff; border-color: #6366f1; transform: scale(1.05); }
.mic-floating svg { width: 18px; height: 18px; }
.mic-floating.recording {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border-color: transparent;
  animation: pulse 1.2s ease-in-out infinite;
}

/* Send-кнопка в новой раскладке — полная ширина, отдельной строкой. */
.coach-input-wrap .coach-send-btn {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  padding: 0 16px;
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #7c3aed 100%));
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.2s;
  flex-shrink: 0;
}
.coach-input-wrap .coach-send-btn:hover:not(:disabled) { transform: translateY(-1px); }
.coach-input-wrap .coach-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Action-кнопки (deep-link) под ответом assistant. */
.coach-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.coach-action-btn {
  display: inline-block;
  padding: 8px 14px;
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #7c3aed 100%));
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.1s;
}
.coach-action-btn:hover { transform: translateY(-1px); }

/* Thinking-индикатор: серый курсив пока выполняется tool в Pass-1. */
.coach-thinking {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* AI-ссылки в нейрозонде (insight, mechanism, meaning, tip).
   Все href санитизированы bleach на сервере и ведут на blog.internativa.biz.
   target="_blank" rel="noopener" гарантирован JS-постпроцессом. */
.ai-link,
.zond-field a {
  color: var(--brand-1, #2563eb);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  font-weight: 500;
}
.ai-link:hover,
.zond-field a:hover {
  opacity: 0.75;
  text-decoration-thickness: 2px;
}
.ai-link:focus-visible,
.zond-field a:focus-visible {
  outline: 2px solid var(--brand-1, #2563eb);
  outline-offset: 2px;
  border-radius: 2px;
}
