:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #1d2a3a;
  --muted: #5b6b7f;
  --line: #d5dde7;
  --accent: #1d5f8a;
  --accent-ink: #ffffff;
  --row-hover: #f4f8fb;
  --code-bg: #f6f8fa;
  --error-bg: #fdecec;
  --error-ink: #8a1f1f;
  --ok: #2e7d4f;
  --ko: #b23a3a;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a24;
    --panel: #1a2431;
    --ink: #e3e9f0;
    --muted: #93a3b6;
    --line: #2c3a4b;
    --accent: #5aa5d6;
    --accent-ink: #0e1620;
    --row-hover: #202d3c;
    --code-bg: #141d28;
    --error-bg: #3a1c1f;
    --error-ink: #f2b8b8;
    --ok: #6cc28f;
    --ko: #e88585;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.app-logo {
  display: block;
  width: 100%;      /* occupe toute la largeur du panneau */
  height: auto;     /* conserve les proportions */
  margin-bottom: 1rem;
}

/* ---------- Filtres ---------- */
.filters {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1.5rem 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  letter-spacing: -0.01em;
}

fieldset {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 0.9rem 0 0.4rem;
}

legend {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
  padding-right: 0.5rem;
}

fieldset.inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

input, select {
  display: block;
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 1rem;
}

button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button.primary, #more-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Zone principale ---------- */
main {
  padding: 1.5rem;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

#status { margin: 0; color: var(--muted); }

.error {
  background: var(--error-bg);
  color: var(--error-ink);
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tr.statement { cursor: pointer; }
tr.statement:hover, tr.statement.open { background: var(--row-hover); }

td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }

.sub {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

/* Pastille de verbe : la couleur est dérivée de l'IRI du verbe */
.verb {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.82rem;
  border: 1px solid currentColor;
  white-space: nowrap;
  color: hsl(var(--h, 210) 55% 36%);
}

@media (prefers-color-scheme: dark) {
  .verb { color: hsl(var(--h, 210) 65% 72%); }
}

.success { color: var(--ok); font-weight: 500; }
.failure { color: var(--ko); font-weight: 500; }

tr.details td { background: var(--code-bg); padding: 0; }

pre {
  margin: 0;
  padding: 1rem;
  max-height: 420px;
  overflow: auto;
  font: 0.8rem/1.45 "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

.empty td {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.pager {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

/* ---------- Progression de l'export ---------- */
.export-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.export-progress[hidden] { display: none; }

.progress {
  position: relative;
  flex: 1;
  min-width: 120px;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

/* Barre indéterminée : le nombre total de statements n'est pas connu à l'avance */
.progress-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -35%;
  width: 35%;
  background: var(--accent);
  border-radius: inherit;
  animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
  from { left: -35%; }
  to   { left: 100%; }
}

.export-progress.finished .progress-bar {
  animation: none;
  left: 0;
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar { animation: none; left: 0; width: 100%; opacity: 0.6; }
}

#export-text {
  font-size: 0.85rem;
  color: var(--muted);
}

#export-cancel {
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
}

/* ---------- Petits écrans ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  main { padding: 1rem; }
}
