/* Thème sombre de l'interface Tkinter (theme.py) */
:root {
  --fond: #16181d; --champ: #262a32; --survol: #323843; --bord: #353b45;
  --texte: #e6e6e6; --gris: #9aa3ad; --inactif: #5c636d;
  --accent: #2ea7e0; --accent-survol: #4bb8ea; --accent-appui: #1f8cc0;
  --vert: #6ccb5f; --fond-liste: #1d2026; --fond-image: #0c0d10; --cadre: #ffd400;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fond); color: var(--texte);
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  display: flex; flex-direction: column;
}
h1 { font-size: 17px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 6px; }
.sous-titre { color: var(--gris); font-weight: 400; margin-left: 6px; }
.gris { color: var(--gris); font-weight: 400; }
.petit { font-size: 12.5px; }
code { background: var(--champ); padding: 1px 5px; border-radius: 4px; }

header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--bord);
}
.pastille { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--champ); color: var(--gris); }
.pastille.ok { color: var(--vert); }
.pastille.ko { color: #ff8a7a; }

/* --- grille : liste | origine | résultat | réglages */
.atelier {
  flex: 1; min-height: 0;
  display: grid; gap: 4px;
  grid-template-columns: 270px minmax(320px, 1fr) minmax(320px, 1.15fr) 300px;
}
.colonne { padding: 10px 12px; overflow-y: auto; min-width: 0; }
@media (max-width: 1280px) {
  .atelier { grid-template-columns: 250px 1fr 1fr; }
  .col-reglages { grid-column: 2 / 4; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
  .cadre-image.grand, .grand .porte-image img { height: auto; max-height: 52vh; }
  .cadre-image.grand { height: 52vh; }
}
@media (max-width: 860px) {
  body { height: auto; }
  .atelier { display: block; }
  .colonne { overflow: visible; padding: 10px 16px; }
  .col-reglages { display: block; }
  .liste { max-height: 260px; }
}

/* --- contrôles */
button, input[type=text], input[type=number] {
  font: inherit; color: var(--texte); background: var(--champ);
  border: 1px solid var(--bord); border-radius: 6px; padding: 5px 10px;
}
button { cursor: pointer; white-space: nowrap; }
button:hover { background: var(--survol); }
button:disabled { color: var(--inactif); cursor: default; background: var(--champ); }
button.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
button.accent:hover { background: var(--accent-survol); }
button.accent:active { background: var(--accent-appui); }
button.large { width: 100%; margin-top: 6px; white-space: normal; }
.deux button { white-space: normal; padding: 5px 6px; }
input[type=number] { width: 80px; }
input[type=text] { flex: 1; min-width: 0; }
input[type=checkbox] { accent-color: var(--accent); }
/* min-width : un fieldset prend sinon la largeur de son contenu le plus long et déborde de la colonne */
fieldset { border: 1px solid var(--bord); border-radius: 8px; margin: 10px 0 0; padding: 8px 10px 10px; min-width: 0; }
#zones { list-style: none; padding: 0; margin: 4px 0; }
legend { color: var(--gris); padding: 0 4px; }
.rangee { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.rangee.fin { justify-content: flex-end; margin-top: 12px; }
.etiquette { min-width: 78px; color: var(--gris); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.separateur { border-top: 1px solid var(--bord); padding-top: 8px; margin: 10px 0 4px; }
.ligne-titre { display: flex; align-items: center; gap: 6px; }
.ligne-titre h2 { flex: 1; }
#formats label { margin-right: 8px; white-space: nowrap; }

/* curseurs : libellé, glissière, valeur (double-clic = valeur par défaut) */
.curseur { display: grid; grid-template-columns: 1fr 52px; column-gap: 8px; margin: 6px 0; }
.curseur label { grid-column: 1 / 3; font-size: 12.5px; color: var(--gris); }
.curseur input[type=range] { width: 100%; accent-color: var(--accent); margin: 0; }
.curseur output { text-align: right; font-variant-numeric: tabular-nums; }
.curseur.inactif { opacity: .45; }

/* --- liste des photos */
.liste {
  list-style: none; margin: 6px 0; padding: 0; background: var(--fond-liste); border-radius: 6px;
  max-height: calc(100vh - 250px); overflow-y: auto; outline: none;
  font: 13px/1.35 Consolas, "Cascadia Mono", monospace;
}
.liste li { padding: 4px 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste li:hover { background: var(--survol); }
.liste li.verifiee { color: var(--vert); }
.liste li.exclue { color: #777; }
.liste li.courante { background: var(--accent); color: #fff; }
#dossier { margin: 4px 0 0; word-break: break-all; }

/* --- images */
.cadre-image {
  position: relative; background: var(--fond-image); border-radius: 6px;
  height: 38vh; min-height: 220px; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cadre-image.grand { height: calc(100vh - 160px); min-height: 320px; }
@media (max-width: 860px) { .cadre-image, .cadre-image.grand { height: auto; min-height: 200px; } }
.porte-image { position: relative; line-height: 0; max-width: 100%; max-height: 100%; }
.porte-image img { max-width: 100%; max-height: 38vh; display: block; user-select: none; }
.grand .porte-image img { max-height: calc(100vh - 160px); }
@media (max-width: 860px) { .porte-image img, .grand .porte-image img { max-height: 70vh; } }
#source { cursor: pointer; touch-action: none; }
#rect-cadre { position: absolute; border: 2px solid var(--cadre); pointer-events: none; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.vide { position: absolute; color: var(--gris); margin: 0; text-align: center; padding: 20px; white-space: pre-line; }
img.en-cours { opacity: .75; transition: opacity .2s; }

footer {
  padding: 5px 16px; border-top: 1px solid var(--bord); color: var(--gris); font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
progress { width: 100%; margin-top: 10px; accent-color: var(--accent); }
#etat-export, .etat { white-space: pre-line; overflow-wrap: anywhere; }

/* --- fenêtres */
#hors-ligne {
  position: fixed; inset: 0; background: rgba(10,11,14,.88); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10;
}
#hors-ligne[hidden] { display: none; }
.carte { background: var(--fond); border: 1px solid var(--bord); border-radius: 10px; padding: 18px 20px; max-width: 560px; width: 100%; }
.carte h2 { margin-bottom: 10px; }
.carte li { margin: 4px 0; }
dialog { padding: 0; border: none; background: transparent; color: var(--texte); width: min(640px, calc(100vw - 32px)); max-width: none; }
dialog .carte { max-width: none; }
dialog::backdrop { background: rgba(0,0,0,.6); }
#sous-dossiers {
  list-style: none; padding: 0; margin: 8px 0 0; height: 300px; overflow-y: auto;
  background: var(--fond-liste); border-radius: 6px;
}
#sous-dossiers li { padding: 5px 10px; cursor: pointer; }
#sous-dossiers li:hover { background: var(--survol); }
#question-texte { white-space: pre-line; }

/* --- modes : navigateur (traitement dans la page) ou agent du PC */
body.navigateur .agent-seul, body:not(.navigateur) .navigateur-seul { display: none; }
button.discret { font-size: 12.5px; padding: 3px 10px; color: var(--gris); }
header .rangee { margin: 0; justify-content: flex-end; }
body.depot::after {
  content: attr(data-depot); position: fixed; inset: 10px; z-index: 20; pointer-events: none;
  display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff;
  border: 3px dashed var(--accent); border-radius: 14px; background: rgba(22,24,29,.85);
}

/* --- onglets Photos / Vidéos */
header .rangee.titre { justify-content: flex-start; gap: 14px; }
.onglets { display: flex; gap: 2px; background: var(--fond-liste); border-radius: 8px; padding: 2px; }
.onglets button { border: none; background: transparent; color: var(--gris); padding: 4px 12px; border-radius: 6px; }
.onglets button[aria-pressed="true"] { background: var(--accent); color: #fff; }
body.onglet-videos #atelier, body:not(.onglet-videos) #atelier-video { display: none; }

/* --- onglet Vidéos */
.cadre-image canvas { display: block; max-width: 100%; max-height: 100%; }
#v-source { cursor: pointer; touch-action: none; }
.rangee.position input[type=range] { flex: 1; accent-color: var(--accent); margin: 0; }
.rangee.position output { min-width: 64px; text-align: right; color: var(--gris); font-variant-numeric: tabular-nums; }
#v-passages { display: block; width: 100%; height: 14px; background: var(--fond-liste); border-radius: 3px; cursor: pointer; margin: 2px 0 6px; }
#v-texte-passages { flex: 1; }
#v-travail { min-height: 1.4em; }
select { font: inherit; color: var(--texte); background: var(--champ); border: 1px solid var(--bord); border-radius: 6px; padding: 4px 6px; }
#v-texte-encodeur { white-space: pre-line; margin: 2px 0 6px; }
label.rangee { cursor: pointer; flex-wrap: nowrap; align-items: flex-start; }
label.rangee input { flex-shrink: 0; margin-top: 2px; }
#dlg-pc a { color: var(--accent-survol); }
#dlg-pc ol { padding-left: 20px; }
