/* voiceb24 — страница записи голосового сообщения */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Helvetica Neue", Arial, "Segoe UI", sans-serif;
  font-size: 14px;
  color: #333;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.screen { display: none; }

/* ---------- Заглушка ---------- */
#app[data-state="stub"] .screen-stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #8a8f99;
}
.stub-icon { font-size: 28px; }
.screen-stub p { margin: 0; }

/* ---------- Основной экран ---------- */
#app:not([data-state="stub"]) .screen-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}

.status-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  color: #6b7280;
  min-height: 16px;
  font-size: 12px;
  text-align: center;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #374151;
  display: none;
}
#app[data-state="recording"] .timer,
#app[data-state="preview"] .timer { display: inline; }

/* ---------- Эквалайзер во время записи ---------- */
.wave {
  display: none;
  width: 100%;
  max-width: 320px;
  height: 36px;
}
#app[data-state="recording"] .wave { display: block; }

/* ---------- Кнопка записи ---------- */
.rec-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #2066b0;
  transition: background .15s ease, transform .1s ease;
  outline-offset: 3px;
}
.rec-btn:hover { background: #1a569a; }
.rec-btn:active { transform: scale(.96); }

#app[data-state="idle"] .rec-btn,
#app[data-state="recording"] .rec-btn { display: flex; }

#app[data-state="recording"] .rec-btn {
  background: #e0432d;
  animation: pulse 1.4s ease-out infinite;
}
#app[data-state="recording"] .rec-btn:hover { background: #c93a26; }

.rec-btn svg { width: 22px; height: 22px; }

#app[data-state="recording"] .icon-mic { display: none; }
.icon-stop {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #fff;
}
#app[data-state="recording"] .icon-stop { display: block; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(224, 67, 45, .45); }
  70%  { box-shadow: 0 0 0 9px rgba(224, 67, 45, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 67, 45, 0); }
}

/* ---------- Прослушивание ---------- */
.preview {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
#app[data-state="preview"] .preview { display: flex; }

.preview audio {
  width: 100%;
  height: 32px;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: #f3f4f6; }

.btn-primary {
  background: #2066b0;
  border-color: #2066b0;
  color: #fff;
}
.btn-primary:hover { background: #1a569a; }

/* ---------- Отправка / отправлено / ошибка ---------- */
.sending { display: none; align-items: center; gap: 10px; color: #6b7280; }
#app[data-state="sending"] .sending { display: flex; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-top-color: #2066b0;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sent {
  display: none;
  align-items: center;
  gap: 8px;
  color: #1e9e4a;
  font-weight: 600;
}
#app[data-state="sent"] .sent { display: flex; }
.check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1e9e4a;
  color: #fff;
  font-size: 15px;
}

.error-block {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
#app[data-state="error"] .error-block { display: flex; }
.error-block p {
  margin: 0;
  color: #c0392b;
  text-align: center;
  word-break: break-word;
}

/* ---------- Микрофон запрещён в iframe ---------- */
.mic-blocked {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#app[data-state="mic-blocked"] .mic-blocked { display: flex; }
.mic-blocked p {
  margin: 0;
  color: #6b7280;
  text-align: center;
}

/* В состояниях sending/sent/error/mic-blocked статусная строка лишняя */
#app[data-state="sent"] .status-line,
#app[data-state="error"] .status-line,
#app[data-state="mic-blocked"] .status-line { display: none; }

/* ---------- Транскрибация (контекстное меню сообщения) ---------- */
#app[data-state="transcribe"] .screen-main { display: none; }
#app[data-state="transcribe"] .screen-transcribe {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}
.t-status { display: flex; align-items: center; gap: 10px; color: #6b7280; }
.t-text {
  width: 100%;
  max-height: 240px;
  overflow-y: auto;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}
.t-error { margin: 0; color: #c0392b; text-align: center; }

/* ---------- Страница установки ---------- */
.install-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
  font-size: 15px;
}
.install-ok { color: #1e9e4a; }
.install-fail { color: #c0392b; }
