/* Manuel Chamanique Mongol — dashboard de relecture
   Palette terre/nuit, serif pour les textes, sans-serif pour l'UI. */

:root {
  --bg: #f4efe6;          /* papier crème */
  --bg-alt: #ebe3d4;
  --ink: #1d1b17;          /* encre nuit */
  --ink-soft: #4a463e;
  --accent: #7a2f20;       /* rouge mongol */
  --accent-soft: #a6604f;
  --gold: #9c7a3c;
  --rule: #c8bfac;
  --ok: #2f6b3c;
  --ok-strong: #2a8b3f;
  --warn: #b07a1f;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  --serif: "Iowan Old Style", "Palatino Linotype", "Palatino", "Georgia", serif;
  --sans: "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
  --topbar-h: 88px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* Topbar */
.topbar {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  gap: 12px;
}

.title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.01em;
}
.title .book { color: var(--accent); font-weight: 600; }
.title .sep { margin: 0 8px; color: var(--rule); }
.title .fr { color: var(--ink-soft); font-style: italic; }

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pager button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--rule);
  background: var(--bg);
  border-radius: 3px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
}
.pager button:hover { background: var(--bg-alt); border-color: var(--ink-soft); }
.pager label { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.pager input[type=number] {
  width: 64px;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  text-align: right;
}
.pager .total { color: var(--ink-soft); }

/* Pastille statut */
.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-pill.review { background: #f1e0bd; color: var(--warn); border: 1px solid #d9b974; }
.status-pill.validated { background: #d8ecdc; color: var(--ok); border: 1px solid #94c8a3; }

/* Bouton vert Valider — .pager pour battre .pager button (0-1-1) */
.pager .btn-validate {
  width: auto;
  height: auto;
  line-height: inherit;
  padding: 8px 16px;
  background: var(--ok-strong);
  color: #fff;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 3px rgba(47, 107, 60, 0.3);
  transition: background 120ms;
}
.pager .btn-validate:hover { background: var(--ok); }
.pager .btn-validate:active { transform: translateY(1px); }

.unvalidate {
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
}
.unvalidate:hover { text-decoration: underline; color: var(--accent); }

#save-indicator {
  font-size: 12px;
  min-width: 60px;
  text-align: right;
}
#save-indicator.saving { color: var(--warn); }
#save-indicator.saved  { color: var(--ok); }
#save-indicator.error  { color: var(--accent); }
.muted { color: var(--ink-soft); }

/* Date du jour */
.today-date {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  text-transform: capitalize;
}

/* Bonhomme humeur quotidienne */
.daily-mood {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.daily-mood .mood-face { display: none; }
.daily-mood.happy .mood-happy { display: block; }
.daily-mood.grumpy .mood-grumpy { display: block; }
.daily-mood.happy .mood-happy {
  animation: mood-bounce 600ms ease;
}
@keyframes mood-bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-4px); }
  60% { transform: translateY(-2px); }
}
.daily-label {
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.daily-mood.happy .daily-label { color: var(--ok); font-weight: 600; }

/* Barre de progression */
.progress {
  padding: 6px 20px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px dashed var(--rule);
}
.progress-bar {
  flex: 1 1 auto;
  height: 6px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
}
.seg {
  height: 100%;
  transition: width 300ms ease;
}
.seg-validated { background: var(--ok-strong); }
.seg-review    { background: var(--warn); opacity: 0.6; }
.progress-label {
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Onglets vue mobile (cachés en desktop) */
.view-tabs {
  display: none;
  gap: 4px;
  padding: 6px 12px;
  border-top: 1px solid var(--rule);
  background: var(--bg);
}
.view-tabs button {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.view-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Grid 3 colonnes */
.grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.1fr) minmax(320px, 1fr);
  gap: 1px;
  background: var(--rule);
  height: calc(100vh - var(--topbar-h));
}
.col {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: 14px 18px 18px;
  overflow: hidden;
}
.col h2 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}
.col-head h2 { margin: 0; }

/* Toolbar markdown */
.md-toolbar {
  display: flex;
  gap: 4px;
}
.md-toolbar button {
  padding: 4px 10px;
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
}
.md-toolbar button:hover { background: var(--bg); border-color: var(--ink-soft); }
.md-toolbar button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Colonne originale */
.col-original .image-wrap {
  flex: 1 1 auto;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--rule);
  display: flex;
  justify-content: center;
  padding: 8px;
  position: relative;
}
.col-original img {
  max-width: 100%;
  height: auto;
  box-shadow: var(--shadow);
  background: #fff;
}
.original-text {
  margin-top: 10px;
  max-height: 180px;
  overflow: auto;
  font-size: 12px;
}
.original-text summary {
  cursor: pointer;
  color: var(--ink-soft);
  padding: 4px 0;
}
.original-text pre {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--bg-alt);
  padding: 10px;
  border-radius: 3px;
  margin: 6px 0 0;
}

.col-original .image-wrap {
  position: relative;
}
.ocr-overlay {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  overflow: visible;
}
.ocr-overlay rect {
  fill: rgba(122, 47, 32, 0.08);
  stroke: rgba(122, 47, 32, 0.45);
  stroke-width: 0.6;
}
.photo-gallery {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 160px;
  overflow: auto;
}
.photo-gallery h3 {
  flex: 1 0 100%;
  font-family: var(--serif);
  font-size: 12px;
  margin: 0;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.photo-gallery img {
  height: 88px;
  width: auto;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: #fff;
}

/* Colonne traduction */
.col-translation textarea,
.col-translation .preview {
  flex: 1 1 auto;
  resize: none;
  padding: 16px 20px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: var(--shadow);
  overflow: auto;
}
.col-translation textarea:focus {
  outline: none;
  border-color: var(--accent-soft);
}
.preview mark.hl {
  background: #fde8b8;
  border-radius: 2px;
  padding: 0 2px;
}

/* Colonne notes */
.col-notes {
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.col-notes > textarea#notes {
  resize: none;
  padding: 14px 16px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.6;
  background: #fffbf2;
  border: 1px solid var(--rule);
  border-radius: 3px;
  min-height: 0;
}
.col-notes > textarea#notes:focus {
  outline: none;
  border-color: var(--gold);
}

/* Bloc retraduction */
.retranslation {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--rule);
}
.retranslation h3 {
  font-family: var(--serif);
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
#retranslate-passage {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  font-family: var(--serif);
  font-size: 14px;
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  border-radius: 3px;
  resize: vertical;
}
.retranslation-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.retranslation-actions button {
  flex: 1;
  padding: 8px 10px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}
.retranslation-actions button:hover { background: var(--accent-soft); }
.retranslation-actions button:disabled { background: var(--rule); cursor: not-allowed; }

.queue {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  max-height: 100px;
  overflow: auto;
}
.queue .item {
  padding: 6px 8px;
  border-left: 3px solid var(--gold);
  background: var(--bg-alt);
  margin-bottom: 4px;
}
.queue .item.pending { border-left-color: var(--warn); }
.queue .item.done    { border-left-color: var(--ok); }
.queue .item.error   { border-left-color: var(--accent); }

/* --- Responsive --- */

/* Tablet : 1 colonne, ordre [Trad → Image → Notes] */
@media (max-width: 900px) {
  :root { --topbar-h: 132px; }
  .topbar-row { flex-direction: column; align-items: stretch; }
  .pager { justify-content: center; }
  .grid {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(280px, auto);
    height: auto;
    min-height: calc(100vh - var(--topbar-h));
  }
  .col-translation { order: 1; }
  .col-original    { order: 2; }
  .col-notes       { order: 3; }
  .col-original .image-wrap { max-height: 60vh; }
}

/* Mobile : onglets, une colonne visible à la fois */
@media (max-width: 600px) {
  :root { --topbar-h: 196px; }
  .title .sep, .title .fr { display: none; }
  .title .book { font-size: 16px; }
  #save-indicator { display: none; }
  .pager { gap: 6px; row-gap: 10px; }
  .pager label { order: 1; }
  .pager #prev { order: 0; }
  .pager #next { order: 2; }
  .pager #status-pill { order: 3; }
  .pager #validate-btn { order: 4; flex: 1 1 100%; }
  .pager #unvalidate-link { order: 5; flex: 1 1 100%; text-align: center; }
  .view-tabs { display: flex; }
  .grid {
    display: block;
    height: auto;
  }
  .col {
    display: none;
    height: calc(100vh - var(--topbar-h));
    padding: 12px 14px;
  }
  body[data-view="image"]       .col[data-view="image"],
  body[data-view="translation"] .col[data-view="translation"],
  body[data-view="notes"]       .col[data-view="notes"] {
    display: flex;
  }
  .col-original .image-wrap { max-height: none; flex: 1; }
  .col-translation textarea,
  .col-translation .preview { font-size: 17px; padding: 14px 16px; }
  .progress { padding: 4px 12px 6px; }
  .progress-label { font-size: 10px; }
  .pager { gap: 6px; }
  .btn-validate { padding: 10px 18px; font-size: 15px; }
}
