/* ==========================================================================
   Сервис транскрибации — тёмная «монтажная» тема
   ========================================================================== */

:root {
  --bg: #0e1216;
  --surface: #151b21;
  --surface-2: #1c232b;
  --surface-3: #222a34;
  --border: #26303b;
  --border-soft: #1e2730;

  --ink: #ece7dc;
  --ink-dim: #b9b4a8;
  --muted: #8792a0;

  --amber: #e2a93b;
  --amber-soft: rgba(226, 169, 59, 0.12);
  --green: #6fb382;
  --red: #e06a5a;
  --blue: #5fa8e0;

  --sans: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", monospace;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}

/* --- Базовые элементы --- */

a {
  color: var(--amber);
  text-decoration: none;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* --- Бренд --- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  fill: var(--amber);
  flex: none;
}

.brand-name {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 16px;
}

.brand-lg {
  margin-bottom: 4px;
}

.brand-lg .brand-mark {
  width: 34px;
  height: 34px;
}

.brand-lg .brand-name {
  font-size: 22px;
}

/* --- Экран входа --- */

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(226, 169, 59, 0.07), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-sub {
  color: var(--muted);
  margin: 10px 0 24px;
  font-size: 13px;
  line-height: 1.5;
}

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}

.auth-tab.is-active {
  background: var(--surface-3);
  color: var(--ink);
}

.auth-error {
  color: var(--red);
  font-size: 13px;
  margin: 12px 0 0;
  text-align: left;
}

/* --- Шапка --- */

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-meta {
  flex: 1;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-email {
  color: var(--muted);
  font-size: 13px;
}

/* --- Раскладка --- */

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 56px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main {
  overflow-y: auto;
  padding: 28px 32px 64px;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.panel-title {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* --- Зона загрузки --- */

.dropzone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  margin-bottom: 14px;
}

.dropzone:hover,
.dropzone.is-drag {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.dropzone-icon {
  color: var(--amber);
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.dropzone-text {
  margin: 0;
  font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.dropzone-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* --- Поля формы --- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 9px 10px;
  width: 100%;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.field input:focus,
.field select:focus {
  border-color: var(--amber);
  outline: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-dim);
}

.check-row input {
  accent-color: var(--amber);
  width: 15px;
  height: 15px;
}

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

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--amber);
  color: #191309;
}

.btn-primary:hover {
  background: #f0b64a;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-dim);
}

.btn-ghost:hover {
  border-color: var(--muted);
  color: var(--ink);
}

.btn-block {
  width: 100%;
}

/* --- Прогресс загрузки --- */

.upload-progress {
  margin-top: 12px;
}

.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--amber);
  transition: width 0.2s ease;
}

.progress-label {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* --- История --- */

.history-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.job-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.job-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
}

.job-item:hover {
  background: var(--surface-2);
}

.job-item.is-active {
  background: var(--surface-2);
  border-color: var(--border);
}

.job-item-info {
  flex: 1;
  min-width: 0;
}

.job-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-item-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.history-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

/* --- Бейджи статуса --- */

.badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid;
  flex: none;
  letter-spacing: 0.02em;
}

.badge-pending {
  color: var(--muted);
  border-color: var(--border);
}

.badge-processing {
  color: var(--amber);
  border-color: var(--amber);
  background: var(--amber-soft);
}

.badge-done {
  color: var(--green);
  border-color: rgba(111, 179, 130, 0.4);
}

.badge-error {
  color: var(--red);
  border-color: rgba(224, 106, 90, 0.4);
}

.pulse {
  animation: pulse 1.6s ease-in-out infinite;
}

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

/* --- Пустое состояние --- */

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-glyph {
  color: var(--surface-3);
  margin-bottom: 12px;
}

.empty-title {
  color: var(--ink-dim);
  font-weight: 500;
  margin: 0 0 6px;
}

.empty-sub {
  margin: 0;
  font-size: 13px;
}

/* --- Просмотр задачи --- */

.job-view {
  max-width: 900px;
  margin: 0 auto;
}

.job-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.job-heading {
  min-width: 0;
}

.job-filename {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  overflow-wrap: anywhere;
  letter-spacing: -0.01em;
}

.job-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.job-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* --- Транскрипт --- */

.job-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.line {
  display: grid;
  grid-template-columns: 92px 108px 1fr;
  gap: 14px;
  padding: 9px 6px;
  border-radius: 6px;
  align-items: baseline;
}

.line:hover {
  background: var(--surface);
}

.line .time {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--amber);
  white-space: nowrap;
}

.line .speaker {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line .text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Сообщение о статусе внутри тела задачи */
.job-status-box {
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.job-status-box .spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-box {
  background: rgba(224, 106, 90, 0.08);
  border: 1px solid rgba(224, 106, 90, 0.35);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Адаптивность --- */

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .main {
    padding: 20px 16px 48px;
  }

  .line {
    grid-template-columns: 78px 1fr;
    gap: 10px;
  }

  .line .speaker {
    grid-column: 2;
  }
}
