/* ============================================================
   Sam Voice Coach widget — English and Art
   Голосовой чат-тренер для начинающих (A0/A1): говорит вслух
   и слушает ответы ученика.
   Палитра: тёмно-зелёный #17513f (спокойный, «дружелюбный»),
   зелёный акцент #2fb98a, светло-серый фон #F6F9F8.
   ============================================================ */

#sam-vc-root {
  --svc-dark: #17513f;
  --svc-blue: #2fb98a;
  --svc-blue-hover: #27a074;
  --svc-border: #dfe9e5;
  --svc-text: #1f2a26;
  --svc-muted: #7d8f88;
  --svc-bg: #f6f9f8;
  --svc-white: #fff;
  --svc-green: #2ecc71;
  --svc-red: #e74c3c;
  --svc-font: "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  font-family: var(--svc-font);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* Страховка: чёрная полоса WordPress сверху (админ-панель) на этой странице
   не нужна. Стили подключаются только здесь, поэтому правило никого больше
   не задевает. Основной механизм — фильтр show_admin_bar в sam-voice.php. */
html { margin-top: 0 !important; }
html #wpadminbar { display: none !important; }

/* сброс внутри корня (нулевая специфичность, чтобы наши правила перебивали) */
:where(#sam-vc-root) *,
:where(#sam-vc-root) *::before,
:where(#sam-vc-root) *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Кнопка-лаунчер и подпись-приглашение УБРАНЫ ----------
   По просьбе владелицы на странице нет плавающего синего виджета.
   Чат открывается кнопкой «Chat» на самой странице (см. sam-voice.js,
   bindPageTriggers). Стили .svc-launcher / .svc-teaser удалены за ненадобностью. */

/* ---------- Окно чата ---------- */
.svc-window {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: min(600px, calc(100vh - 44px));
  background: var(--svc-white);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 999991;
  box-shadow: 0 12px 48px rgba(10, 8, 59, 0.28);
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-family: var(--svc-font);
}

.svc-window.svc-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Шапка ---------- */
.svc-header {
  background: var(--svc-dark);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.svc-avatar {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 50%;
  background: #17513f center/cover no-repeat;
  border: 2px solid rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.svc-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.svc-header-info { flex: 1; min-width: 0; }

.svc-header-name {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.svc-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #b9d4c9;
}

.svc-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--svc-green);
  display: inline-block;
}

.svc-status.svc-speaking i { background: var(--svc-blue); animation: svc-blink 1.1s infinite both; }

/* Оставшееся время занятия — небольшая табличка в шапке */
.svc-session {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #cfd7e6;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.svc-session.svc-session-warn {
  color: #fff;
  background: rgba(255, 138, 76, 0.85);
}

.svc-session.svc-hidden { display: none; }

@keyframes svc-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.svc-header-role { font-size: 12px; color: #b9d4c9; margin-top: 1px; }

.svc-hbtn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.svc-hbtn:hover { background: rgba(255, 255, 255, 0.14); }
.svc-hbtn svg { width: 18px; height: 18px; display: block; }
.svc-hbtn.svc-off { opacity: 0.45; }

/* ---------- Лента сообщений ---------- */
.svc-body {
  flex: 1;
  overflow-y: auto;
  background: var(--svc-bg);
  margin: 12px 12px 8px 12px;
  padding: 14px 14px;
  border: 1px solid var(--svc-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.svc-body::-webkit-scrollbar { width: 6px; }
.svc-body::-webkit-scrollbar-thumb { background: #cdd3de; border-radius: 3px; }

.svc-msg { display: flex; max-width: 90%; }
.svc-msg-user { align-self: flex-end; }
.svc-msg-agent { align-self: flex-start; }

.svc-bubble {
  padding: 10px 13px;
  font-size: 15px;
  border-radius: 15px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.svc-msg-agent .svc-bubble {
  background: #fff;
  color: var(--svc-text);
  border: 1px solid var(--svc-border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 2px rgba(10, 8, 59, 0.05);
}

.svc-msg-user .svc-bubble {
  background: var(--svc-blue);
  color: #fff;
  border-bottom-right-radius: 5px;
}

/* строка с кнопкой «прослушать» под репликой Сэма */
.svc-listen-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.svc-listen {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eef2fb;
  color: var(--svc-blue);
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.svc-listen:hover { background: #e0e8fa; }
.svc-listen svg { width: 13px; height: 13px; display: block; }
.svc-listen.svc-playing { background: var(--svc-blue); color: #fff; }

.svc-time { font-size: 10.5px; color: var(--svc-muted); margin-top: 3px; padding: 0 4px; }
.svc-msg-user .svc-time { text-align: right; }

/* Распознанная речь ученика */
.svc-heard {
  align-self: flex-end;
  font-size: 11.5px;
  color: var(--svc-muted);
  font-style: italic;
  padding-right: 6px;
  max-width: 90%;
  text-align: right;
}

/* «Ричард говорит» */
.svc-typing {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--svc-border);
  border-radius: 15px;
  border-bottom-left-radius: 5px;
  padding: 10px 14px;
  box-shadow: 0 1px 2px rgba(10, 8, 59, 0.05);
  font-size: 12.5px;
  color: var(--svc-muted);
}

.svc-typing.svc-on { display: flex; }

.svc-bars { display: flex; align-items: flex-end; gap: 3px; height: 14px; }
.svc-bars i {
  width: 3px;
  background: var(--svc-blue);
  border-radius: 2px;
  animation: svc-eq 0.9s ease-in-out infinite;
}
.svc-bars i:nth-child(1) { height: 6px;  animation-delay: 0s; }
.svc-bars i:nth-child(2) { height: 12px; animation-delay: 0.15s; }
.svc-bars i:nth-child(3) { height: 8px;  animation-delay: 0.3s; }
.svc-bars i:nth-child(4) { height: 13px; animation-delay: 0.45s; }
.svc-bars i:nth-child(5) { height: 5px;  animation-delay: 0.6s; }

@keyframes svc-eq {
  0%, 100% { transform: scaleY(0.5); }
  50%      { transform: scaleY(1); }
}

/* ---------- Полоса записи ---------- */
.svc-recbar {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 0 12px 8px 12px;
  padding: 9px 12px;
  background: #fdecec;
  border: 1px solid #f5c6c6;
  border-radius: 12px;
  font-size: 13px;
  color: #a33327;
  flex-shrink: 0;
}

.svc-recbar.svc-on { display: flex; }

.svc-recbar .svc-dot {
  width: 9px;
  height: 9px;
  min-width: 9px;
  border-radius: 50%;
  background: var(--svc-red);
  animation: svc-blink 1s infinite both;
}

.svc-recbar .svc-rectext { flex: 1; min-width: 0; }

.svc-recbar .svc-rectime {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ---------- Подвал: ввод ---------- */
.svc-footer {
  border-top: 1px solid var(--svc-border);
  background: #fff;
  padding: 10px 12px 11px 12px;
  flex-shrink: 0;
}

.svc-input-row { display: flex; align-items: flex-end; gap: 8px; }

.svc-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--svc-border);
  border-radius: 16px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.35;
  color: var(--svc-text);
  background: var(--svc-bg);
  outline: none;
  resize: none;
  max-height: 96px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.svc-input:focus { border-color: var(--svc-blue); background: #fff; }
.svc-input::placeholder { color: #9aa3b5; }

/* Кнопка микрофона — главная кнопка */
.svc-mic {
  position: relative;
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 50%;
  border: none;
  background: var(--svc-green);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(46, 204, 113, 0.45);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.svc-mic:hover { background: #27b563; }
.svc-mic:active { transform: scale(0.94); }
.svc-mic svg { width: 24px; height: 24px; display: block; }

.svc-mic.svc-rec {
  background: var(--svc-red);
  box-shadow: 0 4px 14px rgba(231, 76, 60, 0.5);
}

.svc-mic.svc-rec::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(231, 76, 60, 0.7);
  animation: svc-pulse 1.6s ease-out infinite;
}

.svc-mic:disabled { background: #c3c9d4; box-shadow: none; cursor: default; }

.svc-send {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 50%;
  border: none;
  background: var(--svc-blue);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.svc-send:hover { background: var(--svc-blue-hover); }
.svc-send:active { transform: scale(0.94); }
.svc-send:disabled { background: #c3c9d4; cursor: default; }
.svc-send svg { width: 21px; height: 21px; margin-left: 1px; display: block; }

.svc-hint {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--svc-muted);
  text-align: center;
}

.svc-hint b { color: var(--svc-green); }

.svc-note {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--svc-muted);
  text-align: center;
}

.svc-note a { color: var(--svc-blue); font-weight: 700; text-decoration: none; }
.svc-note a:hover { text-decoration: underline; }

/* Системные сообщения (ошибки) */
.svc-sys {
  align-self: center;
  background: #fdecec;
  border: 1px solid #f5c6c6;
  color: #a33327;
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 94%;
  text-align: center;
}

/* ---------- Адаптация под телефон ---------- */
@media (max-width: 520px) {
  .svc-window {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100%; max-width: 100%; height: 100%;
    border-radius: 0;
  }
  .svc-header { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .svc-footer { padding-bottom: calc(11px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .svc-window { transition: none; }
  .svc-bars i, .svc-recbar .svc-dot, .svc-status i { animation: none; }
}
