/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg:    #16162a;
  --sidebar-hover: #1e1e3f;
  --sidebar-active:#2a2a50;
  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --error:         #ef4444;
  --text-main:     #0f172a;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --surface:       #f8fafc;
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                   "Helvetica Neue", Arial, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-main);
  background: #fff;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Layout ────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.logo {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}
.logo-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 4px;
  font-weight: 400;
}

.sidebar-actions {
  padding: 10px 10px 6px;
  flex-shrink: 0;
}

/* ── Queue ─────────────────────────────────────────────────────────────── */
.queue {
  flex: 1;
  overflow-y: auto;
  padding: 2px 0;
  min-height: 0;
}
.queue::-webkit-scrollbar { width: 3px; }
.queue::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.queue-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: #475569;
  text-align: center;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.12s;
  min-height: 0;
}
.queue-item:hover { background: var(--sidebar-hover); }
.queue-item.active {
  background: var(--sidebar-active);
  border-left-color: var(--accent);
}

/* Checkbox */
.queue-check {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  cursor: pointer;
  accent-color: var(--accent);
}

.queue-item-info { flex: 1; min-width: 0; }
.queue-item-name {
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-item-sub {
  font-size: 10.5px;
  color: #475569;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status dots */
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.status-dot--pending    { background: #475569; }
.status-dot--processing { background: var(--accent); animation: pulse 1s infinite; }
.status-dot--done       { background: var(--success); }
.status-dot--error      { background: var(--error); }

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

.sidebar-footer {
  padding: 8px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary.btn-sm { padding: 5px 10px; font-size: 12px; width: auto; }

.btn-secondary {
  background: rgba(99,102,241,0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: background 0.15s;
}
.btn-secondary:hover { background: rgba(99,102,241,0.2); }

.btn-ghost {
  background: transparent;
  color: #64748b;
  border: none;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: color 0.15s;
}
.btn-ghost:hover { color: #94a3b8; }

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(239,68,68,0.18); }
.btn-danger:disabled { opacity: 0.35; cursor: default; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.btn-icon:hover { color: var(--error); background: #fee2e2; }
.btn-icon svg { width: 22px; height: 22px; }

.btn-chip {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-chip:hover { background: #e2e8f0; color: var(--text-main); }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-download:hover { background: #1e293b; }

/* ── Main area ─────────────────────────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Drop zone ─────────────────────────────────────────────────────────── */
.dropzone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px dashed var(--border);
  margin: 28px;
  border-radius: 14px;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone.drag-over {
  border-color: var(--accent);
  background: #f5f3ff;
}
.dropzone-icon svg { opacity: 0.7; }
.dropzone-text { font-size: 15px; font-weight: 500; color: var(--text-main); }
.dropzone-sub  { font-size: 13px; color: var(--text-muted); }
.dropzone-formats { font-size: 11px; color: #94a3b8; margin-top: -4px; }
.dropzone .btn-primary { width: auto; padding: 8px 18px; }

/* ── Detail panel ──────────────────────────────────────────────────────── */
.detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 28px;
  gap: 16px;
}
.detail::-webkit-scrollbar { width: 5px; }
.detail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.detail-filename {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* State views */
.state-pending,
.state-processing,
.state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 0;
}
.state-icon { font-size: 30px; }
.state-icon--pending { color: #94a3b8; }
.state-icon--error   { color: var(--error); }
.state-label { font-size: 14px; color: var(--text-muted); }

/* Setup form (язык + тип перед обработкой) */
.setup-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 580px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
.setup-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.setup-label {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 130px;
  font-weight: 500;
}
.setup-select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}
.setup-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 12px;
  color: #b91c1c;
  max-width: 480px;
  word-break: break-word;
  text-align: center;
}

/* Progress bar */
.progress-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.progress-label {
  font-size: 13px;
  color: var(--text-muted);
}
.progress-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

/* Doc meta */
.doc-meta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.meta-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 110px;
}
.meta-value {
  font-size: 13px;
  font-weight: 500;
}
.confidence-badge {
  background: #dcfce7;
  color: #166534;
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.confidence-badge.low {
  background: #fef9c3;
  color: #854d0e;
}

/* Override panel */
.override-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #f5f3ff;
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  padding: 10px 14px;
}
.select-type {
  flex: 1;
  min-width: 200px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  background: #fff;
}

/* Fields table */
.fields-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fields-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fields-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fields-table th {
  text-align: left;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
}
.fields-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.fields-table tr:last-child td { border-bottom: none; }
.fields-table tr.needs-review td { background: #fffbeb; }
.review-flag {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 5px;
}
.field-label  { font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.field-orig   { color: #475569; font-style: italic; }
.field-trans  { color: var(--text-main); font-weight: 500; }

/* Scaffold */
.scaffold-section {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
}
.scaffold-title { font-size: 12px; font-weight: 600; color: #92400e; margin-bottom: 6px; }
.scaffold-list  { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; }
.scaffold-list li {
  background: #fef3c7;
  color: #78350f;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11.5px;
}

/* Actions */
.detail-actions { padding-top: 2px; }

/* ── History panel ─────────────────────────────────────────────────────── */
.history-panel {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}
.history-header .btn-ghost { width: auto; padding: 3px 8px; font-size: 14px; }

.history-scroll {
  flex: 1;
  overflow-y: auto;
}
.history-scroll::-webkit-scrollbar { width: 4px; }
.history-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.history-table th {
  text-align: left;
  padding: 7px 14px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
}
.history-table td {
  padding: 3px 14px;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
  line-height: 1.4;
}
.history-table td.col-file { max-width: 260px; }
.history-table tbody tr:nth-child(odd)  td { background: #fff; }
.history-table tbody tr:nth-child(even) td { background: #f8fafc; }
.history-table tbody tr:hover td { background: #eef2ff; }
.badge-done  { color: var(--success); font-weight: 600; }
.badge-error { color: var(--error);   font-weight: 600; }
