/* ── DocTrans Stylesheet ── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Mono:wght@300;400;500&display=swap');

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

:root {
  --bg: #0a0b0e;
  --surface: #111318;
  --surface2: #181b22;
  --border: #1e2130;
  --border2: #252a3a;
  --text: #e8eaf2;
  --muted: #6b7280;
  --accent: #4f7cff;
  --accent2: #7b5ea7;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --teal: #14b8a6;
  --r: 10px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Syne', sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── NAV ── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  z-index: 10;
}

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo span { color: var(--accent); }

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.ready {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.status-dot.working {
  background: var(--amber);
  animation: pulse 1s infinite;
}

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

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

/* ── MAIN LAYOUT ── */
.app {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-actions {
  margin-top: auto;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 1.5px dashed var(--border2);
  border-radius: var(--r);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  background: var(--surface2);
}

.upload-zone:hover, .upload-zone.drag {
  border-color: var(--accent);
  background: rgba(79, 124, 255, .05);
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-sub { font-size: 11px; color: var(--muted); }

/* ── SELECT ── */
select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

select:focus { border-color: var(--accent); }

/* ── OPTIONS ── */
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}

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

.toggle {
  width: 34px;
  height: 18px;
  border-radius: 9px;
  background: var(--border2);
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}

.toggle.on { background: var(--accent); }

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}

.toggle.on::after { transform: translateX(16px); }

/* ── BUTTONS ── */
.btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--r);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  border: none;
  transition: all .15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6b91ff; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  background: var(--border2);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
}

.btn-secondary:hover {
  border-color: var(--border2);
  color: var(--text);
  background: var(--surface2);
}

/* ── FILE CARD ── */
.file-card {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(239, 68, 68, .15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.file-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

.file-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  flex-shrink: 0;
}

.file-remove:hover { color: var(--red); }

/* ── MAIN CONTENT ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── TABS ── */
.tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  background: var(--bg);
  flex-shrink: 0;
}

.tab {
  display: inline-flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--text); }

/* ── PANELS ── */
.panel {
  flex: 1;
  overflow: auto;
  display: none;
  padding: 20px;
  flex-direction: column;
  gap: 16px;
}

.panel.active { display: flex; }

/* ── EMPTY STATE ── */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  min-height: 200px;
}

.empty-icon { font-size: 40px; opacity: .3; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--muted); }
.empty-sub {
  font-size: 12px;
  color: var(--muted);
  opacity: .7;
  max-width: 280px;
  line-height: 1.6;
}

/* ── DOC PREVIEW ── */
.doc-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  flex: 1;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.preview-toolbar span {
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
}

.preview-body {
  padding: 20px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  overflow: auto;
  max-height: 500px;
  white-space: pre-wrap;
  font-family: 'DM Mono', monospace;
}

.preview-body.rendered-report,
.compare-body.rendered-report {
  padding: 18px;
  white-space: normal;
  font-family: 'DM Sans', sans-serif;
  background: #16181f;
}

/* ── PROGRESS ── */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}

.progress-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.progress-steps { display: flex; flex-direction: column; gap: 8px; }

.step { display: flex; align-items: center; gap: 10px; font-size: 12px; }

.step-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  font-weight: 700;
}

.step-icon.done { background: rgba(34, 197, 94, .15); color: var(--green); }
.step-icon.active {
  background: rgba(245, 158, 11, .15);
  color: var(--amber);
  animation: pulse 1s infinite;
}
.step-icon.pending { background: var(--border); color: var(--muted); }
.step-label { color: var(--muted); }
.step-label.done { color: var(--text); }
.step-label.active { color: var(--amber); }

.progress-bar-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  border-radius: 2px;
  transition: width .4s ease;
}

#currentStepDetail {
  font-size: 12px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  line-height: 1.8;
}

/* ── SEGMENTS ── */
.segments-list { display: flex; flex-direction: column; gap: 8px; }

.segment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.segment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
}

.conf-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
}

.conf-high { background: rgba(34, 197, 94, .15); color: var(--green); }
.conf-med { background: rgba(245, 158, 11, .15); color: var(--amber); }
.conf-low { background: rgba(239, 68, 68, .15); color: var(--red); }

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

.seg-orig, .seg-trans {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.7;
}

.seg-orig { color: var(--muted); border-right: 1px solid var(--border); }
.seg-trans { color: var(--text); }

/* ── COMPARE ── */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.compare-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.compare-header {
  padding: 8px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compare-body {
  padding: 14px;
  font-size: 12px;
  line-height: 1.8;
  overflow: auto;
  max-height: 480px;
  white-space: pre-wrap;
}

.compare-body.source { color: var(--muted); font-style: italic; }
.compare-body.translated { color: var(--text); }
.compare-body.rendered-report.source,
.compare-body.rendered-report.translated {
  color: var(--text);
  font-style: normal;
}

.clinical-report {
  min-height: 100%;
}

.clinical-paper {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d9dee7;
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 18px 40px rgba(3, 7, 18, 0.14);
}

.clinical-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 8px 0 20px;
}

.lifequiro-mark {
  position: relative;
  width: 122px;
  height: 122px;
  flex-shrink: 0;
}

.lifequiro-mark .arc {
  position: absolute;
  top: 8px;
  width: 62px;
  height: 106px;
  border: 8px solid transparent;
  border-radius: 999px;
}

.lifequiro-mark .arc-left {
  left: 0;
  border-left-color: #28368f;
  border-top-color: #28368f;
  border-bottom-color: #28368f;
}

.lifequiro-mark .arc-right {
  right: 0;
  border-right-color: #e23b34;
  border-top-color: #e23b34;
  border-bottom-color: #e23b34;
}

.lifequiro-mark .vertebra {
  position: absolute;
  left: 50%;
  width: 34px;
  height: 14px;
  margin-left: -17px;
  background: #e23b34;
  border-radius: 999px;
  box-shadow:
    -8px 1px 0 -3px #e23b34,
    8px 1px 0 -3px #e23b34;
}

.lifequiro-mark .v1 { top: 6px; transform: rotate(-16deg); }
.lifequiro-mark .v2 { top: 24px; transform: rotate(-11deg); }
.lifequiro-mark .v3 { top: 42px; transform: rotate(-7deg); }
.lifequiro-mark .v4 { top: 60px; transform: rotate(-3deg); }
.lifequiro-mark .v5 { top: 78px; transform: rotate(2deg); }
.lifequiro-mark .v6 { top: 96px; transform: rotate(7deg); }

.lifequiro-brand-copy {
  max-width: min(100%, 700px);
}

.lifequiro-wordmark {
  font-size: clamp(42px, 5vw, 76px);
  line-height: .92;
  font-weight: 800;
  letter-spacing: 0;
  font-family: Georgia, 'Times New Roman', serif;
}

.lifequiro-life { color: #28368f; }
.lifequiro-quiro { color: #e23b34; }

.lifequiro-subtitle {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 4px solid #28368f;
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.08;
  font-weight: 800;
  color: #28368f;
  max-width: 780px;
}

.clinical-header-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid #c8ced8;
}

.clinical-cell {
  min-height: 88px;
  padding: 18px 16px;
  border-right: 1px solid #c8ced8;
  border-bottom: 1px solid #c8ced8;
  font-size: clamp(17px, 2vw, 28px);
  line-height: 1.28;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.clinical-cell:nth-child(2n) {
  border-right: none;
}

.clinical-cell:nth-last-child(-n + 2) {
  border-bottom: none;
}

.clinical-cell strong {
  font-weight: 800;
}

.clinical-page-chip {
  margin-top: 14px;
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #28368f;
  font-size: 12px;
  font-weight: 700;
}

.clinical-body {
  margin-top: 18px;
}

.clinical-section-title {
  margin: 18px 0 8px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 800;
  color: #111827;
}

.clinical-line {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.72;
  color: #243041;
}

.clinical-gap {
  height: 10px;
}

.clinical-page-marker {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 700;
  color: #4b5563;
}

/* ── TAGS ── */
.tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
}

.tag-en { background: rgba(79, 124, 255, .15); color: var(--accent); }
.tag-done { background: rgba(34, 197, 94, .15); color: var(--green); }
.tag-pending { background: rgba(107, 114, 128, .15); color: var(--muted); }

/* ── QA ── */
.qa-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.qa-metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  text-align: center;
}

.qa-value {
  font-size: 22px;
  font-weight: 800;
  font-family: 'DM Mono', monospace;
  margin-bottom: 2px;
}

.qa-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.qa-value.good { color: var(--green); }
.qa-value.warn { color: var(--amber); }

.qa-flags { display: flex; flex-direction: column; gap: 8px; }

.qa-flag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
}

.flag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.flag-dot.green { background: var(--green); }
.flag-dot.amber { background: var(--amber); }
.flag-dot.red { background: var(--red); }
.flag-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.flag-desc { color: var(--muted); }

/* ── DOWNLOAD ── */
.download-card {
  background: linear-gradient(135deg, rgba(79, 124, 255, .1), rgba(123, 94, 167, .1));
  border: 1px solid rgba(79, 124, 255, .3);
  border-radius: var(--r);
  padding: 20px;
  text-align: center;
}

.download-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.download-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; }

.download-meta {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  margin-bottom: 16px;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--r);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .15s;
}

.btn-download:hover { background: #6b91ff; transform: translateY(-1px); }

/* ── STATS BAR ── */
.stats-bar {
  display: flex;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.stat {
  flex: 1;
  padding: 8px 12px;
  border-right: 1px solid var(--border);
  text-align: center;
}

.stat:last-child { border-right: none; }
.stat-val { font-size: 13px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--text); }
.stat-key { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  transform: translateY(100px);
  opacity: 0;
  transition: all .3s;
  pointer-events: none;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ── SPINNER ── */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { width: 260px; }
  .compare-grid { grid-template-columns: 1fr; }
  .qa-grid { grid-template-columns: repeat(2, 1fr); }
  .clinical-brand {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  .clinical-header-grid {
    grid-template-columns: 1fr;
  }
  .clinical-cell {
    border-right: none;
    min-height: 72px;
    font-size: 18px;
  }
  .clinical-cell:nth-last-child(-n + 2) {
    border-bottom: 1px solid #c8ced8;
  }
  .clinical-cell:last-child {
    border-bottom: none;
  }
  .lifequiro-mark {
    transform: scale(.9);
  }
}
