/* Голосовой тренажёр — тёмная «приборная» тема.
   Ориентир: аудиовиджет с круговой визуализацией голоса и моноширинными метками. */

:root {
  --bg: #e9e9e9;
  --card: #121212;
  --card-soft: #191919;
  --line: #262626;
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --dim: #5c5c5c;
  --accent: #ff3b30;
  --ok: #35c759;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: #1a1a1a; /* подложка светлая: тёмный текст по умолчанию */
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* Внутри «приборных» карточек — светлый текст на тёмном. */
.panel, .device, .transcript { color: var(--text); }

.hidden { display: none !important; }

/* ---------- Каркас ---------- */

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.app-header .mono-label { color: #6e6e6e; }

.app-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Моноширинные метки ---------- */

.mono-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.mono-value {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Бейджи ---------- */

.badge-group { display: flex; gap: 8px; }

.badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 4px;
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
}

.badge-live { color: var(--ok); border-color: rgba(53, 199, 89, 0.35); }
.badge-stub { color: #d9a441; border-color: rgba(217, 164, 65, 0.35); }
.badge-kb { color: var(--ok); border-color: rgba(53, 199, 89, 0.35); }

/* ---------- Панели ---------- */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.16);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Настройка ---------- */

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field-wide { grid-column: 1 / -1; }

select, input[type="text"] {
  width: 100%;
  padding: 11px 12px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  transition: border-color 0.15s ease;
}

select:focus, input[type="text"]:focus {
  outline: none;
  border-color: #444;
}

select option { background: #191919; color: var(--text); }

/* ---------- Кнопки ---------- */

.btn {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn-primary { background: #f2f2f2; color: #101010; }
.btn-primary:hover:not(:disabled) { background: #fff; }

.btn-danger {
  background: transparent;
  color: var(--accent);
  border-color: rgba(255, 59, 48, 0.4);
}
.btn-danger:hover:not(:disabled) { background: rgba(255, 59, 48, 0.1); }

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

/* ---------- Экран звонка ---------- */

.call-layout {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  gap: 20px;
  align-items: start;
}

/* «Прибор» */

.device {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.device-head, .device-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.device-foot { padding-top: 14px; border-top: 1px solid var(--line); }

.viz-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}

.viz { width: 100%; height: 100%; display: block; }

.viz-dot {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--dim);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.viz-dot.is-listening {
  background: var(--accent);
  box-shadow: 0 0 18px rgba(255, 59, 48, 0.55);
  animation: pulse 1.6s ease-in-out infinite;
}

.viz-dot.is-speaking { background: #f2f2f2; box-shadow: 0 0 18px rgba(255, 255, 255, 0.4); }
.viz-dot.is-processing { background: #d9a441; box-shadow: 0 0 14px rgba(217, 164, 65, 0.4); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.device-status { display: flex; flex-direction: column; gap: 7px; }

.status-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
}

.session-info {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* Лента диалога */

.transcript {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.feed {
  flex: 1;
  overflow-y: auto;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 6px;
  margin-bottom: 18px;
}

.feed::-webkit-scrollbar { width: 6px; }
.feed::-webkit-scrollbar-thumb { background: #2c2c2c; border-radius: 3px; }

.msg { max-width: 82%; display: flex; flex-direction: column; gap: 5px; }
.msg-manager { align-self: flex-end; align-items: flex-end; }
.msg-client { align-self: flex-start; }

.msg-role {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.msg-text {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  background: var(--card-soft);
  border: 1px solid var(--line);
}

.msg-manager .msg-text {
  background: #f2f2f2;
  color: #101010;
  border-color: transparent;
}

/* ---------- Разбор коуча ---------- */

.coach-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.65;
  color: #dcdcdc;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 20px;
}

/* ---------- Плашка ошибок ---------- */

.error-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  background: #2a1210;
  border-bottom: 1px solid rgba(255, 59, 48, 0.4);
  color: #ffb4ae;
  font-size: 14px;
}

.error-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 17px;
  cursor: pointer;
  padding: 0 4px;
}

/* ---------- Адаптив ---------- */

@media (max-width: 860px) {
  .call-layout { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr; }
  .transcript { min-height: 340px; }
  .feed { max-height: 340px; }
}

/* ---------- Переключатель разделов ---------- */

.tabs { display: flex; gap: 8px; }

.tab {
  padding: 10px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tab:hover { color: var(--text); border-color: #3a3a3a; }
.tab.is-active { background: #f2f2f2; color: #101010; border-color: transparent; }

/* Раздел целиком: те же вертикальные отступы, что и у .app-main. */
.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Раздел «Материалы» ---------- */

textarea {
  width: 100%;
  padding: 12px 13px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  min-height: 180px;
  transition: border-color 0.15s ease;
}

textarea:focus { outline: none; border-color: #444; }
textarea::placeholder { color: var(--dim); }

textarea::-webkit-scrollbar { width: 6px; }
textarea::-webkit-scrollbar-thumb { background: #2c2c2c; border-radius: 3px; }

.material-hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* Скрытый input[type=file]: кликаем по нему из кнопки «Загрузить файл». */
.file-input { display: none; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.btn-row .btn { flex: 1 1 200px; width: auto; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--card-soft); border-color: #444; }

/* ---------- Результат разбора материала ---------- */

.analysis {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.analysis-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--text);
}

.analysis-cards, .draft-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.info-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 15px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.info-card-wide { grid-column: 1 / -1; }

.info-value {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.info-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  line-height: 1.5;
  color: #dcdcdc;
}

.info-list li::marker { color: var(--dim); }

/* Черновик сценария — вложенная карточка со своей «шапкой». */
.draft {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.draft .panel-head { padding-bottom: 12px; margin-bottom: 0; }

.draft-pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: #dcdcdc;
  max-height: 260px;
  overflow-y: auto;
}

.draft-pre::-webkit-scrollbar { width: 6px; }
.draft-pre::-webkit-scrollbar-thumb { background: #2c2c2c; border-radius: 3px; }

.draft-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ok);
}

@media (max-width: 860px) {
  .analysis-cards, .draft-grid { grid-template-columns: 1fr; }
  .btn-row .btn { flex: 1 1 100%; }
}

/* ---------- Страница входа (login.html) ---------- */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 28px 20px;
}

/* Карточка входа — тот же «прибор», что и .panel, только узкий и по центру. */
.login-card {
  width: 100%;
  max-width: 380px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
}

.login-hint {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.1em;
  transition: border-color 0.15s ease;
}

input[type="password"]:focus {
  outline: none;
  border-color: #444;
}

/* Плашка ошибки внутри карточки — те же цвета, что и у .error-banner. */
.login-error {
  margin: 0;
  padding: 11px 13px;
  border-radius: 8px;
  background: #2a1210;
  border: 1px solid rgba(255, 59, 48, 0.4);
  color: #ffb4ae;
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- Дашборд (dashboard.html) ---------- */

.app-header .badge[href] { text-decoration: none; }
.app-header .badge[href]:hover { color: var(--text); border-color: #444; }

.dash-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text);
}

.stat-num {
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dash-list { display: flex; flex-direction: column; }

.dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.dash-row:last-child { border-bottom: none; }

.dash-row-active { border-left: 2px solid var(--accent); padding-left: 12px; }

.dash-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dash-name { font-size: 15px; color: var(--text); font-weight: 500; }
.dash-sub { font-size: 12px; color: var(--muted); }

.dash-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.dash-live {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 3px 8px;
  border: 1px solid rgba(255, 59, 48, 0.4);
  border-radius: 4px;
  animation: pulse 1.6s ease-in-out infinite;
}

.dash-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.dash-tag-ok { color: var(--ok); border-color: rgba(53, 199, 89, 0.35); }
.dash-tag-dim { color: var(--dim); }

.dash-empty { color: var(--muted); font-size: 13px; padding: 6px 4px 0; margin: 0; }

@media (max-width: 720px) {
  .dash-stats { grid-template-columns: 1fr; }
  .dash-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .dash-meta { flex-wrap: wrap; }
}

/* ---------- Дашборд: прослушивание записей и живая стенограмма ---------- */

.dash-row-wrap { border-bottom: 1px solid var(--line); }
.dash-row-wrap:last-child { border-bottom: none; }
.dash-row-wrap .dash-row { border-bottom: none; }

.dash-play {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  border: 1px solid #3a3a3a;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dash-play:hover { border-color: #555; background: rgba(255, 255, 255, 0.04); }

.dash-player {
  padding: 4px 4px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dash-player audio { width: 100%; height: 34px; }

.dash-transcript, .dash-livechat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 12px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.dash-livechat { margin: 0 4px 12px; max-height: 150px; }

.dash-line { display: flex; flex-direction: column; gap: 2px; }
.dash-line-manager { align-items: flex-end; }
.dash-line-who {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.dash-line-text {
  font-size: 13px;
  line-height: 1.4;
  color: #dcdcdc;
  max-width: 88%;
  padding: 6px 10px;
  border-radius: 8px;
  background: #1e1e1e;
}
.dash-line-manager .dash-line-text { background: #2a2a2a; color: #f2f2f2; }

/* ---------- «Кому звоните»: личность собеседника до старта ---------- */

.callee-card {
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.callee-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.callee-name {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.callee-about {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
