/* translate.vai8.io — слой поверх дизайн-системы vai8.
   Используем её токены (--bg/--surface/--amber/--ink) и компоненты (.btn/.input/.card). */

/* ── каркас: у системы .shell = сайдбар+контент, у нас топбар ── */
#app.shell { display: flex; flex-direction: column; min-height: 100vh; grid-template-columns: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: baseline; gap: 6px; font-weight: 800; letter-spacing: -.03em; }
.brand-mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  border-radius: 8px; background: var(--amber); color: var(--on-amber);
  font-size: 12px; font-weight: 800; letter-spacing: 0; transform: translateY(3px);
}
.brand-name { font-size: 17px; }
.brand-dot, .brand-sub { color: var(--ink-3); font-size: 15px; font-weight: 600; }

.tabs { display: flex; gap: 2px; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 7px 14px; border-radius: 9px;
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  transition: background .16s, color .16s;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.is-active { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); font-weight: 600; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.usage {
  font-family: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace;
  font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.theme-switch { display: flex; gap: 5px; }
.theme-dot {
  width: 17px; height: 17px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); padding: 0; transition: transform .14s, box-shadow .14s;
}
.theme-dot:hover { transform: scale(1.12); }
.theme-dot.is-active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--amber); }
.t-charcoal   { background: linear-gradient(135deg, #1a1816 55%, #f0a35e 55%); }
.t-ivory      { background: linear-gradient(135deg, #faf8f3 55%, #bd6f2c 55%); }
.t-terracotta { background: linear-gradient(135deg, #1f1e1d 55%, #d97757 55%); }

/* ── виды ── */
.view { display: none; padding: 24px; max-width: 1420px; width: 100%; margin: 0 auto; }
.view.is-active { display: block; }

/* ── выбор языков ── */
.langbar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-bottom: 12px; }
.lang-side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lang-side .select { max-width: 260px; }
.lang-hint { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swap {
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  font-size: 15px; transition: background .16s, color .16s, transform .2s;
}
.swap:hover { background: var(--surface-3); color: var(--amber); transform: rotate(180deg); }

/* ── две панели ── */
.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pane {
  display: flex; flex-direction: column; min-height: 340px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.pane-out { background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
}
.pane-head .label { margin: 0; }
.pane-tools { display: flex; gap: 4px; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--ink-3);
  font-size: 13px; line-height: 1; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

.editor {
  flex: 1; width: 100%; resize: none; border: 0; outline: none;
  padding: 16px 18px; background: transparent; color: var(--ink);
  font-family: inherit; font-size: 15px; line-height: 1.6;
  min-height: 240px; max-height: 52vh; overflow-y: auto;
}
.editor::placeholder { color: var(--ink-3); }
.editor-out { white-space: pre-wrap; word-break: break-word; }
.editor-out:empty::before { content: attr(data-placeholder); color: var(--ink-3); }
.editor-out .chunk-new { animation: fade-in .25s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.pane-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px; border-top: 1px solid var(--line-soft); min-height: 36px;
}
.muted { color: var(--ink-3); font-size: 12px; }
.small { font-size: 12px; }
.progress { flex: 1; max-width: 160px; height: 3px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .25s ease-out; }

/* ── панель параметров ── */
.controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  margin-top: 16px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.control { display: flex; flex-direction: column; gap: 4px; min-width: 132px; }
.control .label { margin: 0; }
.controls-spacer { flex: 1; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--amber); width: 15px; height: 15px; cursor: pointer; }
.select { padding-right: 30px; }
kbd {
  font-family: 'SF Mono', ui-monospace, monospace; font-size: 10px;
  padding: 1px 4px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--on-amber) 35%, transparent);
  opacity: .75;
}

/* ── дополнительная панель (варианты/объяснение) ── */
.extra { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.extra-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.extra-head .label { margin: 0; }
.extra-body { padding: 14px 16px; font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; }
.variant { padding: 10px 0; border-bottom: 1px dashed var(--line-soft); }
.variant:last-child { border-bottom: 0; }
.variant-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); font-weight: 700; margin-bottom: 4px; }
.variant-text { cursor: pointer; }
.variant-text:hover { color: var(--amber); }

/* ── разделы: заголовки, карточки ── */
.section-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.section-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.section-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.card-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  display: flex; gap: 16px; align-items: flex-start;
}
.card-item:hover { border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); }
.card-main { flex: 1; min-width: 0; }
.card-line { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.card-line + .card-line { margin-top: 4px; color: var(--ink-2); }
.card-meta { margin-top: 6px; font-size: 11.5px; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 4px; }
.star-btn.is-on { color: var(--amber); }

/* ── статистика ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.stat-value { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--ink-3); }

/* ── глоссарии ── */
.gl-editor { margin-top: 16px; }
.gl-editor-head { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.gl-editor-head .input { flex: 1; min-width: 160px; }
.gl-terms { min-height: 200px; max-height: 40vh; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); margin-top: 8px; }
.gl-editor-foot { display: flex; gap: 8px; margin-top: 12px; }

/* ── документы ── */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: 14px; background: var(--surface);
  padding: 40px 24px; text-align: center; cursor: pointer;
  transition: border-color .18s, background .18s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--amber); background: var(--surface-2); }
.dropzone-icon { font-size: 30px; opacity: .75; margin-bottom: 10px; }
.dropzone-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.dropzone-hint { font-size: 12.5px; color: var(--ink-3); }
#doc-controls { margin-top: 12px; margin-bottom: 18px; }
.job-progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.job-progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .3s ease-out; }
.job-status { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.js-ready     { background: var(--surface-3); color: var(--ink-2); }
.js-running   { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.js-done      { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.js-failed    { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.js-cancelled { background: var(--surface-3); color: var(--ink-3); }
.job-warnings { margin-top: 6px; font-size: 12px; color: var(--warning); }

/* ── заглушка раздела ── */
.state-box { text-align: center; padding: 72px 24px; color: var(--ink-2); }
.state-icon { font-size: 34px; margin-bottom: 12px; opacity: .7; }
.state-title { font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.state-text { max-width: 480px; margin: 0 auto; font-size: 14px; line-height: 1.6; }

/* ── экран входа ── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px 28px; box-shadow: var(--shadow);
}
.gate-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--amber); color: var(--on-amber); font-weight: 800; font-size: 16px;
}
.gate-title { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.gate-lead { color: var(--ink-2); font-size: 13.5px; line-height: 1.55; margin-bottom: 4px; }
.gate-error { color: var(--danger); font-size: 13px; }
.gate-build { color: var(--ink-3); font-size: 11px; letter-spacing: .04em; }

/* ── уведомление ── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--surface-3); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 16px; font-size: 13.5px;
  box-shadow: var(--shadow); z-index: 60; animation: fade-in .2s ease-out;
}
.toast.is-error { border-color: var(--danger); color: var(--danger); }

/* ── доступность ── */
:where(button, select, textarea, input, [tabindex]):focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 8px;
}

/* ── адаптив ── */
@media (max-width: 1020px) {
  .panes { grid-template-columns: 1fr; }
  .editor { max-height: 34vh; }
}
@media (max-width: 780px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px 14px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .topbar-right { gap: 10px; }
  .usage { display: none; }
  .view { padding: 14px; }
  .langbar { grid-template-columns: 1fr auto 1fr; gap: 8px; }
  .lang-side .select { max-width: none; }
  .lang-hint { display: none; }
  .controls { gap: 10px; }
  .control { min-width: calc(50% - 6px); }
}
