/* Feuille de style de la plateforme, d'après les maquettes « Diffusion de documents » et la
   charte graphique FREDON.

   Police : Source Sans Pro (police d'accompagnement de la charte, licence OFL), servie par
   l'application ; Arial est la police système de remplacement prévue par la charte. */
@font-face {
  font-family: "Source Sans Pro";
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/SourceSansPro-Regular.3f482321becf.ttf") format("truetype");
}

@font-face {
  font-family: "Source Sans Pro";
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/SourceSansPro-SemiBold.550b42a5f50d.ttf") format("truetype");
}

@font-face {
  font-family: "Source Sans Pro";
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/SourceSansPro-Bold.7e0ee8c45d87.ttf") format("truetype");
}

/* --- Couleurs ---
   Une couleur de marque par espace, déclinée en teintes. Portail : vert mousse. */
:root {
  --brand: #576b35;
  --brand-dark: #405027;
  --brand-darker: #2f3b1a;
  --brand-tint: #e8eddd;
  --page: #f4f5f0;
  --line: #dde0d3;
  --line-strong: #b9bead;
  --row-line: #eceee6;

  --ink: #22251d;
  --ink-soft: #4a4f43;
  --ink-mute: #5a5f52;
  --surface: #fff;

  /* Couleurs de sens, identiques dans les deux espaces. */
  --info-bg: #e3eef3;
  --info-ink: #0c4e67;
  --ok-bg: #e8eddd;
  --ok-ink: #2f3b1a;
  --warn-bg: #fbf0d9;
  --warn-ink: #6b4900;
  --neutral-bg: #ececea;
  --neutral-ink: #45463f;
  --danger-bg: #f8e3e0;
  --danger-ink: #8a2418;
}

/* Backend expéditeur : bleu charron, du nuancier complémentaire. */
.theme-backend {
  --brand: #0c4e67;
  --brand-dark: #083647;
  --brand-darker: #06293a;
  --brand-tint: #e3eef3;
  --page: #f2f5f6;
  --line: #d6dee2;
  --line-strong: #aebcc3;
  --row-line: #e8edef;
}

/* --- Base --- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font-family: "Source Sans Pro", Arial, Helvetica, sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.15;
}

h2 {
  margin: 2rem 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}

h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--info-ink);
}

a:hover {
  color: #083647;
}

li {
  margin-bottom: 0.25rem;
}

code,
.mono {
  font-family: Consolas, "Source Code Pro", monospace;
  font-size: 0.85em;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--ink-mute);
}

.small {
  font-size: 0.87rem;
}

.lead {
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* Surtitre en petites capitales, au-dessus d'un titre ou d'un groupe. */
.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* --- En-tête --- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.75rem;
  background: var(--surface);
  border-bottom: 3px solid var(--brand);
}

.site-title {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  color: var(--brand-dark);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
}

.site-title:hover {
  color: var(--brand-dark);
}

/* Logo : jamais déformé, entouré d'un espace dégagé (charte, « zone de protection »). */
.site-logo {
  display: block;
  height: 2.4rem;
  width: auto;
}

.site-title-text {
  padding-left: 1.1rem;
  border-left: 1px solid var(--line);
}

.site-user {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 0;
  color: var(--ink-soft);
}

/* --- Mise en page --- */
main {
  width: 100%;
  max-width: 70rem;
  margin: 0 auto;
  padding: 1.75rem;
  flex: 1;
}

/* Portail : colonne étroite, pensée pour le téléphone. */
.narrow main {
  max-width: 34rem;
  padding: 2rem 1.5rem 1.5rem;
}

/* Backend : menu latéral et contenu. */
.shell {
  display: flex;
  flex-wrap: wrap;
  flex: 1;
}

.shell main {
  flex: 999 1 35rem;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 1.75rem 2rem 2.5rem 1rem;
}

.side-nav {
  flex: 1 1 13.5rem;
  max-width: 16rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.5rem 1rem;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.side-nav a:hover,
.side-nav a:focus-visible {
  background: var(--brand-tint);
}

.side-nav a[aria-current="page"] {
  background: var(--brand-tint);
  color: var(--brand-darker);
  font-weight: 700;
}

.side-nav svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.side-nav hr {
  width: calc(100% - 0.75rem);
  margin: 0.75rem auto;
  border: 0;
  border-top: 1px solid var(--line);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-head h1,
.page-head p {
  margin-bottom: 0.25rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-decoration: none;
}

.back-link svg {
  width: 16px;
  height: 16px;
}

/* --- Cartes --- */
.card {
  margin-bottom: 1.25rem;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.card > :last-child {
  margin-bottom: 0;
}

.card h2:first-child,
.card h3:first-child {
  margin-top: 0;
}

.card-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 2.5rem;
}

.info-card {
  display: flex;
  gap: 0.9rem;
}

.info-card svg {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  color: var(--info-ink);
}

.info-card strong {
  display: block;
  color: var(--info-ink);
}

.notice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--warn-bg);
  color: #4f3a06;
}

.notice svg {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  color: #7a5300;
}

.kv {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.kv-label {
  color: var(--ink-mute);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* --- Boutons --- */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 1.15rem;
  border: 1.5px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
  color: #fff;
}

button:disabled,
button:disabled:hover {
  border-color: var(--line);
  background: var(--line);
  color: var(--ink-mute);
  cursor: not-allowed;
}

/* Bouton secondaire : contour seul. */
.button-secondary,
.button-secondary:hover {
  background: var(--surface);
  color: var(--brand-dark);
}

.button-secondary:hover {
  background: var(--brand-tint);
}

/* Bouton discret : actions de second plan (déconnexion, détail, annulation). */
.button-plain,
.button-plain:hover {
  min-height: 2.5rem;
  padding: 0 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

.button-plain:hover {
  background: var(--page);
}

.button-block {
  display: flex;
  width: 100%;
  min-height: 3.1rem;
  font-size: 1.05rem;
}

.button svg,
button svg {
  width: 18px;
  height: 18px;
}

/* --- Formulaires --- */
.field {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  display: block;
  width: 100%;
  max-width: 28rem;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--brand);
  outline: 4px solid color-mix(in srgb, var(--brand) 18%, transparent);
}

.narrow input[type="text"],
.narrow input[type="email"] {
  max-width: none;
  min-height: 3.1rem;
  font-size: 1.05rem;
}

/* Code à 6 chiffres : grands chiffres espacés. */
.narrow input.code-input {
  max-width: 16rem;
  min-height: 3.6rem;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-align: center;
}

input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--brand);
  vertical-align: -0.25rem;
}

.checkbox {
  font-weight: 700;
}

.help {
  margin: 0.3rem 0 0;
  color: var(--ink-mute);
  font-size: 0.9rem;
}

.errorlist {
  margin: 0.25rem 0 0.6rem;
  padding: 0;
  list-style: none;
  color: var(--danger-ink);
  font-weight: 600;
}

.copy-text {
  max-width: none;
  margin-bottom: 0.5rem;
  padding: 0.75rem;
  background: var(--page);
  font-size: 0.9rem;
}

progress {
  display: block;
  width: 100%;
  max-width: 28rem;
  margin: 0.5rem 0;
  accent-color: var(--brand);
}

.file-rows {
  margin-top: 0.75rem;
}

.file-row {
  margin-bottom: 0.6rem;
  padding: 0.85rem 1rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--page);
}

.file-row input[type="text"],
.file-row select {
  max-width: none;
}

.file-row button {
  margin-bottom: 0.75rem;
}

.file-list {
  max-height: 14rem;
  overflow-y: auto;
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.75rem 0.6rem 1.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--page);
}

/* Recherche et filtres de la liste des envois. */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.filters .search {
  flex: 1 1 17rem;
  max-width: 26rem;
}

.filters select {
  width: auto;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 2.35rem;
  padding: 0 0.85rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.pill:hover {
  background: var(--brand-tint);
  color: var(--ink);
}

.pill[aria-current="true"],
.pill[aria-current="true"]:hover {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
  color: #fff;
  font-weight: 700;
}

/* --- Tableaux --- */
.table-wrap {
  margin-bottom: 1.25rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid var(--row-line);
  text-align: left;
  vertical-align: top;
}

th:first-child,
td:first-child {
  padding-left: 1.15rem;
}

th:last-child,
td:last-child {
  padding-right: 1.15rem;
}

th {
  border-bottom-color: var(--line);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td form {
  margin: 0;
}

tr.row-warning td {
  background: #fcfaf4;
}

.hash {
  font-family: Consolas, "Source Code Pro", monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.pagination {
  display: flex;
  gap: 1rem;
}

/* --- Pastilles de statut --- */
.status {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding: 0 0.65rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--neutral-ink);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-available {
  background: var(--info-bg);
  color: var(--info-ink);
}

.status-ok,
.status-downloaded {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.status-warning,
.status-expired_not_downloaded {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.status-expired_downloaded {
  background: var(--neutral-bg);
  color: var(--neutral-ink);
}

.status-revoked {
  border-color: #9a9c92;
  background: var(--surface);
  color: var(--neutral-ink);
}

.status-error {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* --- Messages --- */
.message {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--info-bg);
  color: var(--info-ink);
}

.message > :last-child {
  margin-bottom: 0;
}

.message-warning {
  background: var(--warn-bg);
  color: #4f3a06;
}

.message-error {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.message-success {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

/* --- Étapes de l'import en masse --- */
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0.45rem 1rem 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
}

.steps .step-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border: 1.5px solid #9a9c92;
  border-radius: 50%;
  font-size: 0.9rem;
}

.steps .step-done {
  border-color: var(--brand-tint);
  background: var(--brand-tint);
  color: var(--brand-darker);
}

.steps .step-done .step-mark {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.steps .step-current {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
  color: #fff;
  font-weight: 700;
}

.steps .step-current .step-mark {
  border-color: #fff;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 700;
}

/* --- Tableau de bord --- */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.stats li {
  flex: 1 1 10rem;
  margin: 0;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stats strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 600;
}

.stats a {
  color: inherit;
  text-decoration: none;
}

/* --- Portail : documents du destinataire --- */
.doc-group h2 {
  margin: 1.5rem 0 0.6rem;
  padding: 0 0.25rem;
  color: var(--brand);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.doc-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 0.6rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.doc-card-body {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.doc-badge {
  display: flex;
  flex-shrink: 0;
  align-items: flex-end;
  justify-content: center;
  width: 2.75rem;
  height: 3.25rem;
  padding-bottom: 0.4rem;
  border-radius: 6px;
  background: var(--brand-tint);
  color: var(--brand-darker);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.doc-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.doc-meta {
  color: var(--ink-mute);
  font-size: 0.9rem;
}

.doc-state {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--info-ink);
}

.doc-state-downloaded {
  color: var(--brand-darker);
}

/* --- Pied de page --- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.15rem;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 1.75rem;
  color: var(--ink-mute);
  font-size: 0.9rem;
}

/* Un bloc d'aide placé sous un formulaire en est détaché. */
form + .card,
form + section {
  margin-top: 1.5rem;
}

/* --- Portail sur grand écran ---
   Les étapes de connexion restent en colonne étroite et centrée. La liste des documents, elle,
   s'élargit : chaque document tient sur une ligne, avec son bouton à droite. */
.reading main,
.reading .site-footer {
  max-width: 54rem;
}

.reading main {
  padding: 2rem 1.5rem 1.5rem;
}

@media (min-width: 44rem) {
  .doc-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 1.25rem;
  }

  .doc-card .button-block {
    flex-shrink: 0;
    width: auto;
    min-width: 12rem;
    min-height: 2.75rem;
    font-size: 0.95rem;
  }

  .narrow main {
    padding-top: 3rem;
  }

  .narrow main > h1 {
    font-size: 1.8rem;
  }
}
