/* VoiceChat — оформление страницы (статичный CSS, без сборки). */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: #f2f4f8;
  color: #1c2333;
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

h1 {
  font-size: 26px;
  margin: 8px 0 12px;
}

h2 {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5a6478;
  margin: 0 0 8px;
}

/* ── Баннер «используйте наушники» ─────────────────────────────── */

.banner {
  background: #fff6df;
  border: 1px solid #e8cf8f;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: #6b5410;
}

/* ── Панель состояния ──────────────────────────────────────────── */

.statusbar {
  background: #ffffff;
  border: 1px solid #dde3ee;
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 16px;
}

/* Строка 1: индикаторы состояний (как раньше) */
.status-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Вторая строка: слева — «Новая сессия» + «Озвучка ответов», справа — шестерёнка;
   между ними — текст сообщений (ошибки, подсказки) */
.status-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #ccd3e0;
  background: #eef1f6;
  color: #8a93a6;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}

.chip.on {
  border-color: #2e9e5b;
  background: #e2f6e9;
  color: #1d7a42;
}

/* «Слушает» — мигающий индикатор (бриф §4.3) */
#chipListen.on {
  animation: chipPulse 1.4s ease-in-out infinite;
}

@keyframes chipPulse {
  0%,
  100% {
    background: #e2f6e9;
    color: #1d7a42;
  }
  50% {
    background: #8fdcab;
    color: #0d5c2d;
  }
}

#chipThink.on {
  border-color: #3f74d8;
  background: #e3ecfd;
  color: #24509e;
}

#chipTts.on {
  border-color: #8a50d8;
  background: #efe6fd;
  color: #5f2f9e;
}

.chip-err.on {
  border-color: #d84040;
  background: #fde3e3;
  color: #a91d1d;
  animation: chipPulseErr 1.4s ease-in-out infinite;
}

@keyframes chipPulseErr {
  0%,
  100% {
    background: #fde3e3;
  }
  50% {
    background: #f5b3b3;
  }
}

.status-text {
  flex: 1 1 160px;
  font-size: 14px;
  color: #4a5468;
  min-width: 160px;
}

/* Шестерёнка настроек — правый край строки управления */
.status-controls > .btn-gear {
  margin-left: auto;
}

.voice-toggle {
  font-size: 14px;
  color: #2a3244;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* ── Черновик и кнопки ─────────────────────────────────────────── */

.draft-panel,
.history-panel {
  background: #ffffff;
  border: 1px solid #dde3ee;
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 16px;
}

.draft {
  min-height: 52px;
  background: #f6f8fc;
  border: 1px dashed #b9c3d6;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 14px;
}

.draft:empty::before {
  content: "Здесь появится живой транскрипт по мере вашей речи…";
  color: #97a0b3;
  font-style: italic;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.btn {
  font-family: inherit;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid #b9c3d6;
  background: #eef1f6;
  color: #1c2333;
  padding: 10px 18px;
  cursor: pointer;
}

.btn:hover {
  background: #e2e8f2;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-small {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
}

.btn-start {
  border-color: #2e9e5b;
  color: #145c31;
}

.btn-thought {
  font-size: 19px;
  font-weight: 700;
  padding: 16px 34px;
  background: #2f6fd8;
  border-color: #2459ab;
  color: #ffffff;
}

.btn-thought:hover {
  background: #2459ab;
}

.hint {
  font-size: 13px;
  color: #8a5a20;
  min-height: 18px;
  margin: 10px 0 0;
}

/* ── Вкладки «Диалог» / «История» (план 6.1) ───────────────────── */

.tabbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.tab-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid #ccd3e0;
  background: #eef1f6;
  color: #8a93a6;
  cursor: pointer;
  user-select: none;
}

.tab-btn:hover {
  background: #e2e8f2;
}

.tab-btn.active {
  border-color: #2459ab;
  background: #2f6fd8;
  color: #ffffff;
}

.tab-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #d84040;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.tab-badge[hidden] {
  display: none;
}

/* Скрытие панелей вкладок: правило нужно, потому что авторские стили
   панели перебивают UA-стиль для атрибута [hidden] */
.draft-panel[hidden],
.history-panel[hidden] {
  display: none;
}

/* ── История диалога: чат-раскладка (2026-11-01) ───────────────── */

/* Прокрутка внутри вкладки — сама страница не растёт (план 6.1) */
.history {
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px 2px;
}

.history .empty {
  color: #97a0b3;
  font-style: italic;
}

/* Строка сообщения: подпись «кто говорил» — РЯДОМ с пузырём, не сверху */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 10px;
}

/* Мысли пользователя — вправо, ответы ассистента — влево (как в чате) */
.msg-row.msg-user {
  justify-content: flex-end;
}

.msg-row.msg-bot {
  justify-content: flex-start;
}

.msg-role {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #6b7891;
  padding-bottom: 6px;
  user-select: none;
}

.msg-role-user {
  color: #3d62a8;
}

.msg-role-bot {
  color: #3f7a3f;
}

.msg-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
}

.msg-user .msg-bubble {
  background: #f2f7ff;
  border: 1px solid #d5e2f7;
  border-bottom-right-radius: 4px;
}

.msg-bot .msg-bubble {
  background: #f7faf6;
  border: 1px solid #e0e9dd;
  border-bottom-left-radius: 4px;
}

.msg-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-raw {
  margin: 6px 0 0;
  font-size: 12px;
  color: #7a849a;
  font-style: italic;
}

.msg-questions {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: #4a5468;
}


/* ── Шестерёнка настроек: справа строки состояния, открывает окно ── */

/* Маленькая кнопка с шестерёнкой: открывает всплывающее окно настроек и промптов */
.btn-gear {
  font-family: inherit;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid #b9c3d6;
  background: #eef1f6;
  color: #5a6478;
  cursor: pointer;
  padding: 0;
}

.btn-gear:hover {
  background: #e2e8f2;
  color: #2a3244;
}

/* ── Всплывающее окно «Настройки и промпты» (2026-11-01) ───────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 35, 51, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: #ffffff;
  border: 1px solid #dde3ee;
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(28, 35, 51, 0.25);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #dde3ee;
}

.modal-head h2 {
  margin: 0;
}

.modal-close {
  font-family: inherit;
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #b9c3d6;
  background: #eef1f6;
  color: #5a6478;
  cursor: pointer;
  padding: 0;
}

.modal-close:hover {
  background: #e2e8f2;
}

.modal-body {
  overflow-y: auto;
  padding: 4px 18px 18px;
}

.modal-section {
  border-top: 1px dashed #dde3ee;
  margin-top: 14px;
  padding-top: 10px;
}

.modal-section:first-child {
  border-top: none;
  margin-top: 6px;
}

.modal-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5a6478;
  margin: 0 0 6px;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0 4px;
}

.settings-row label {
  font-size: 13px;
  color: #4a5468;
}

.settings-row select {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid #b9c3d6;
  border-radius: 8px;
  background: #f6f8fc;
  color: #1c2333;
}

.settings-row input.settings-input {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid #b9c3d6;
  border-radius: 8px;
  background: #f6f8fc;
  color: #1c2333;
}

.settings-input-wide {
  flex: 1 1 220px;
  min-width: 180px;
}

.settings-input-num {
  width: 90px;
}

/* Выбор модели и панель промптов (2026-11-02) */

.settings-select-wide {
  flex: 1 1 320px;
  min-width: 240px;
  font-family: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid #b9c3d6;
  border-radius: 8px;
  background: #f6f8fc;
  color: #1c2333;
}

.settings-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 4px;
}

.settings-col label {
  font-size: 13px;
  color: #4a5468;
}

.settings-col textarea {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 8px 10px;
  border: 1px solid #b9c3d6;
  border-radius: 8px;
  background: #f6f8fc;
  color: #1c2333;
  resize: vertical;
}

/* Промпты — моноширинный текст, прокрутка внутри окна */
.modal-section textarea {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  min-height: 90px;
  max-height: 320px;
}

/* Режим просмотра: текст приглушён; правка открывается кнопкой «Редактировать» */
.modal-section textarea[readonly] {
  background: #f2f4f8;
  color: #5a6478;
}

.modal-section textarea.editing {
  background: #f6f8fc;
  color: #1c2333;
}
