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

:root {
  color-scheme: dark;

  --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);
  --on-amber: #191309;
  --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);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #e9edf1;
  --surface-3: #dde3e9;
  --border: #d3dae2;
  --border-soft: #e6ebf0;

  --ink: #1b232c;
  --ink-dim: #3c4753;
  --muted: #67737f;

  --amber: #a7650a;
  --amber-soft: rgba(167, 101, 10, 0.10);
  --on-amber: #ffffff;
  --green: #2f8b4c;
  --red: #c23b2e;
  --blue: #2f7fc0;

  --shadow: 0 12px 28px rgba(30, 45, 60, 0.10);
}

* {
  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;
}

.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);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head .panel-title {
  margin: 0;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

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

.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: var(--on-amber);
}

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

:root[data-theme="light"] .btn-primary:hover {
  background: #935a07;
}

.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);
}

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

.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: 1240px;
  margin: 0 auto;
}

.job-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  align-items: start;
}

.job-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 76px;
}

.audio-player {
  margin-bottom: 18px;
}

.audio-player audio {
  width: 100%;
  display: block;
}

.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;
  min-width: 0;
}

.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;
  cursor: text;
  border-radius: 4px;
  padding: 1px 2px;
}

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

.text-editor {
  width: 100%;
  min-height: 26px;
  background: var(--surface-2);
  border: 1px solid var(--amber);
  border-radius: 6px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  padding: 4px 6px;
  resize: vertical;
  box-sizing: border-box;
}

/* Сообщение о статусе внутри тела задачи */
.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;
}

/* --- Вложения --- */

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

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

.attachment-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attachment-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.attachment-name {
  flex: 1 1 100%;
  min-width: 0;
  font-size: 13px;
  overflow-wrap: break-word;
}

.attachment-size {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.attachment-empty {
  color: var(--muted);
  font-size: 13px;
}

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

.speaker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.speaker-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.speaker-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.speaker-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 8px 10px;
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
}

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

/* --- Админ-панель --- */

.admin-view-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  background: var(--amber-soft);
  font-size: 12px;
  color: var(--ink-dim);
}

.admin-view-email {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.admin-modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.admin-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.admin-modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.admin-user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: pointer;
}

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

.admin-user-email {
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

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

@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;
  }

  .job-content {
    grid-template-columns: 1fr;
  }

  .job-side {
    position: static;
  }
}

/* ==========================================================================
   Дополнительно для YouTubeHarvestService
   ========================================================================== */

/* Бренд-иконка скачивания (штриховая) */
.brand-mark {
  fill: none;
  stroke: var(--amber);
}

/* Переключатель формата аудио/видео */
.format-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 14px;
}

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

.format-toggle button.is-active {
  background: var(--surface-3);
  color: var(--ink);
}

/* Список последних видео канала */
.channel-title {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.channel-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.channel-item-main {
  flex: 1;
  min-width: 0;
}

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

.channel-item-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* Таблица метаданных задачи */
.meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.meta-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.meta-table td:first-child {
  color: var(--muted);
  width: 150px;
  white-space: nowrap;
}

.meta-table a {
  color: var(--amber);
}

.nextcloud-note {
  margin-top: 12px;
  font-size: 13px;
}
