/* RedDesk Media — charte RedDesk (« rd »), jetons repris de DESIGN.md de RedDesk.
   Règles propres à cet outil : pas de liseré de couleur sur les cartes, pas de
   contour au focus ni à la sélection (le focus se lit par le fond ou la bordure
   du champ), pas de lien souligné (tout lien est un bouton ou une ligne). */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/fonts/inter-400-700-latinext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/fonts/inter-400-700-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url(/assets/fonts/plusjakartasans-500-800-latinext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url(/assets/fonts/plusjakartasans-500-800-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;
  --red: #C0392B;
  --red-dark: #A62F23;
  --red-ink: #A62F23;
  --red-hover: #A62F23;
  --red-tint: #FCEEEC;
  --red-border: #F0B2AA;
  --red-on: #FFFDF8;
  --bg: #F7F6F4;
  --paper: #FFFFFF;
  --paper-deep: #F1EFEC;
  --text: #22262C;
  --text-muted: #5A6069;
  --border: #ECE9E6;
  --border-strong: #D9D4CF;
  --border-card: #E4E0DB;
  --focus: #5A6069;
  --success: #3E694E;
  --success-bg: #D3E0D7;
  --warning: #815923;
  --warning-bg: #ECE0CB;
  --neutral: #5A606A;
  --neutral-bg: #E0DCD7;
  --danger: #A9372A;
  --danger-bg: #ECD7D3;
  --voile: rgba(34, 38, 44, 0.45);
  --shadow-overlay: 0 0.25rem 1rem rgba(31, 41, 55, 0.10);

  --serif: "Plus Jakarta Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --sans: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --radius-card: 14px;
  --radius-puce: 6px;
  --esp-1: 0.25rem;
  --esp-2: 0.5rem;
  --esp-3: 0.75rem;
  --esp-4: 1rem;
  --esp-5: 1.25rem;
  --esp-6: 1.5rem;
  --esp-8: 2rem;
  --pile: 1.2rem;
  --cible: 44px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --red: #D6604C;
    --red-dark: #E8846F;
    --red-ink: #E8846F;
    --red-hover: #DE6F5B;
    --red-tint: #2E211E;
    --red-border: #5C3B33;
    --red-on: #1B1210;
    --bg: #181716;
    --paper: #201F1E;
    --paper-deep: #2A2927;
    --text: #E7E9EC;
    --text-muted: #9CA2AC;
    --border: #33312F;
    --border-strong: #3E3B38;
    --border-card: #393634;
    --focus: #9CA2AC;
    --success: #7FC08F;
    --success-bg: #223226;
    --warning: #E0B368;
    --warning-bg: #382E1C;
    --neutral: #AEB4BE;
    --neutral-bg: #2C2A28;
    --danger: #E08A7B;
    --danger-bg: #38251F;
    --shadow-overlay: 0 0.25rem 1rem rgba(0, 0, 0, 0.45);
  }
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
@media (min-width: 769px) { html { font-size: 16px; } }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; color: var(--text); }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.12rem; letter-spacing: -0.015em; }
p { margin: 0; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
::selection { background: color-mix(in oklab, var(--red) 18%, transparent); }

/* Pas de contour au focus : le retour se fait par la couleur. */
:focus, :focus-visible { outline: none; }

.icone { width: 1.1rem; height: 1.1rem; flex: none; }
.aide { color: var(--text-muted); font-size: 0.9rem; }
.discret { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.visuellement-cache {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: var(--esp-3); }
.logo img { height: 1.9rem; width: auto; }
.logo-media {
  font-family: var(--sans); font-weight: 500; font-size: 0.95rem;
  color: var(--text-muted);
  padding-left: var(--esp-3);
  border-left: 1px solid var(--border-strong);
  line-height: 1.4;
}

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--esp-4);
  min-height: 4.4rem;
  padding: 0 2rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar form { margin: 0; }
.topbar-marque { display: inline-flex; border-radius: var(--radius); }

/* ---------- Mise en page ---------- */
.contenu { padding: 1.86667rem 2rem 3rem; display: flex; flex-direction: column; gap: var(--pile); max-width: 90rem; margin: 0 auto; }
.contenu-etroit { max-width: 46rem; }
.entete-page { display: flex; flex-direction: column; gap: var(--esp-1); }
.retour { align-self: flex-start; margin-left: calc(-1 * 0.875rem); }

/* ---------- Cartes ---------- */
.carte {
  background: var(--paper);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 1.5rem 1.625rem;
}
.carte-entete {
  display: flex; align-items: center; justify-content: space-between; gap: var(--esp-3);
  padding-bottom: var(--esp-3); margin-bottom: var(--esp-4);
  border-bottom: 1px solid var(--border);
}
.titre-carte { display: inline-flex; align-items: center; gap: var(--esp-2); font-size: 1.12rem; }
.carte > p + p, .carte > p + .cle { margin-top: var(--esp-3); }
.carte-tableau { padding-bottom: var(--esp-2); }

/* ---------- Tuiles ---------- */
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: var(--pile); }
.tuile { display: flex; flex-direction: column; gap: var(--esp-1); }
.tuile-valeur { font-family: var(--serif); font-weight: 800; font-size: 2.4rem; line-height: 1; letter-spacing: -0.015em; color: var(--red); }
.tuile-libelle { color: var(--text-muted); font-weight: 500; }

/* ---------- Boutons ---------- */
.button, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--esp-2);
  height: 38px; padding: 0 0.875rem;
  border: 1px solid transparent; border-radius: var(--radius);
  background: var(--paper); color: var(--text);
  font: 500 0.875rem/1.2 var(--sans);
  white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.button:hover, .button:focus-visible { background: var(--paper-deep); }
.button:active { background: var(--border); }
.button-sm { height: 32px; padding: 0 0.6875rem; font-size: 0.8125rem; }
.button-large { height: var(--cible); width: 100%; font-size: 0.95rem; }
.button-ghost { background: transparent; color: var(--text-muted); }
.button-ghost:hover, .button-ghost:focus-visible { background: var(--paper-deep); color: var(--text); }
.button-primary { background: var(--red); color: var(--red-on); }
.button-primary:hover, .button-primary:focus-visible { background: var(--red-hover); }
.button-primary:active { background: var(--red-dark); }
.button-outline { border-color: var(--border-strong); }
.button-danger { border-color: var(--border-strong); color: var(--danger); }
.button-danger:hover, .button-danger:focus-visible { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-danger-plein { background: var(--danger); color: #fff; }
.button-danger-plein:hover, .button-danger-plein:focus-visible { background: color-mix(in oklab, var(--danger) 85%, #000); }
.button[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.button.is-copie { color: var(--success); }

.icon-button { width: 2.4rem; height: 2.4rem; padding: 0; }
.icon-button:hover, .icon-button:focus-visible { background: var(--paper-deep); color: var(--red); }
.icon-button-danger:hover, .icon-button-danger:focus-visible { background: var(--danger-bg); color: var(--danger); }

/* ---------- Champs ---------- */
.pile { display: flex; flex-direction: column; gap: var(--esp-4); }
.champ { display: flex; flex-direction: column; gap: var(--esp-1); min-width: 0; }
.champ label { color: var(--text-muted); font-weight: 500; font-size: 0.9rem; }
input:not([type="file"]):not([type="hidden"]), select {
  height: 44px; width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--paper); color: var(--text);
  font: 400 1rem/1.55 var(--sans);
  transition: border-color 0.15s var(--ease);
}
input::placeholder { color: var(--text-muted); }
input:hover, select:hover { border-color: var(--red-border); }
input:focus, select:focus { border-color: var(--focus); box-shadow: none; }
select {
  appearance: none; padding-right: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%235A6069' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1.1rem;
}
.champ-icone { position: relative; }
.champ-icone .icone { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.champ-icone input:not([type="file"]):not([type="hidden"]) { padding-left: 2.4rem; }

.grille-formulaire { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--esp-4); }
.formulaire-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
@media (max-width: 640px) { .grille-formulaire { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Bandeaux ---------- */
.flash {
  display: flex; align-items: center; gap: var(--esp-2);
  padding: 0.8rem 1.2rem; border-radius: var(--radius);
  font-weight: 500;
  animation: glisse 0.25s var(--ease);
}
.flash-succes { background: var(--success-bg); color: var(--success); }
.flash-erreur { background: var(--danger-bg); color: var(--danger); }
@keyframes glisse { from { transform: translateY(-5px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Connexion ---------- */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: var(--esp-6) 16px; }
.connexion-carte { width: min(26rem, 100%); display: flex; flex-direction: column; gap: var(--esp-4); padding: 2rem 2.26667rem; }
.connexion-marque { margin-bottom: var(--esp-2); }
.connexion-carte.vide { align-items: center; text-align: center; }

/* ---------- Liste des espaces ---------- */
.liste-espaces { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.ligne-espace {
  display: flex; align-items: center; gap: var(--esp-3);
  padding: var(--esp-3); margin: 0 calc(-1 * var(--esp-3));
  border-radius: var(--radius);
  transition: background-color 0.15s var(--ease);
}
.ligne-espace:hover, .ligne-espace:focus-visible { background: var(--red-tint); }
.ligne-espace:hover strong, .ligne-espace:focus-visible strong { color: var(--red-ink); }
.pastille-icone {
  width: 2.4rem; height: 2.4rem; border-radius: var(--radius);
  display: grid; place-items: center;
  background: var(--paper-deep); color: var(--text-muted);
}
.ligne-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ligne-texte strong { font-weight: 600; }
.ligne-texte small { color: var(--text-muted); font-size: 0.85rem; }
.ligne-chevron { color: var(--text-muted); }

/* ---------- Tableau ---------- */
.tableau-defile { overflow-x: auto; margin: 0 -1.625rem; }
.tableau { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tableau th {
  text-align: left; padding: 0.6rem 1.2rem;
  background: var(--paper-deep); color: var(--text-muted);
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
.tableau td { padding: 0.75rem 1.2rem; border-bottom: 1px solid var(--border); }
.tableau tr:last-child td { border-bottom: 0; }
.tableau th:first-child, .tableau td:first-child { padding-left: 1.625rem; }
.tableau tbody tr:hover { background: var(--red-tint); }

/* ---------- Barre d'outils d'un espace ---------- */
.barre-outils { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--esp-4); }
.envoi, .recherche { display: flex; align-items: flex-end; gap: var(--esp-3); flex-wrap: wrap; margin: 0; }
.envoi .champ { width: 16rem; }
.recherche .champ { width: 18rem; }
.bouton-fichier { height: 44px; }
.recherche .button { height: 44px; }
@media (max-width: 640px) {
  .envoi, .recherche, .envoi .champ, .recherche .champ { width: 100%; }
  .bouton-fichier, .recherche .button { width: 100%; }
}

/* ---------- Segments ---------- */
.segments { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.segment {
  display: inline-flex; align-items: center; height: 38px; padding: 0 0.875rem;
  border-radius: var(--radius); color: var(--text-muted); font-weight: 500; font-size: 0.875rem;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.segment:hover, .segment:focus-visible { background: var(--paper-deep); color: var(--text); }
.segment.is-active { background: var(--red-tint); color: var(--red-ink); font-weight: 600; }

/* ---------- Galerie ---------- */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); gap: var(--pile); }
.fichier { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.apercu {
  position: relative; display: grid; place-items: center;
  aspect-ratio: 4 / 3; width: 100%;
  background: var(--paper-deep); color: var(--text-muted);
  border: 0; padding: 0; cursor: zoom-in; overflow: hidden;
}
a.apercu { cursor: pointer; }
.apercu img { width: 100%; height: 100%; object-fit: cover; transition: opacity 0.15s var(--ease); }
.apercu:hover img, .apercu:focus-visible img { opacity: 0.88; }
.apercu-document { display: flex; flex-direction: column; gap: var(--esp-2); font-weight: 600; font-size: 0.85rem; }
.apercu-document .icone { width: 2rem; height: 2rem; }
.apercu-document:hover, .apercu-document:focus-visible { color: var(--red-ink); }
.apercu-lecture {
  position: absolute; width: 3rem; height: 3rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--paper); color: var(--text);
}
.fichier-infos { padding: var(--esp-4) var(--esp-4) var(--esp-2); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fichier-infos strong { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fichier-infos small { color: var(--text-muted); font-size: 0.82rem; }
.puces { display: flex; flex-wrap: wrap; gap: var(--esp-1); margin-top: var(--esp-1); }
.puces:empty { display: none; }
.puce {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.125rem 0.6rem; border-radius: var(--radius-puce);
  font-size: 0.78rem; font-weight: 500; line-height: 1.5; white-space: nowrap;
}
.puce .icone { width: 0.8rem; height: 0.8rem; }
.puce-neutre { background: var(--neutral-bg); color: var(--neutral); }
.puce-attention { background: var(--warning-bg); color: var(--warning); }
.fichier-actions {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--esp-2);
  padding: var(--esp-2) var(--esp-3) var(--esp-3) var(--esp-4);
}
.fichier-actions form { margin: 0; }

/* ---------- États vides ---------- */
.vide { display: flex; flex-direction: column; align-items: center; gap: var(--esp-3); text-align: center; color: var(--text-muted); font-size: 0.9rem; padding: var(--esp-6) 0; }
.vide-symbole { opacity: 0.45; }

/* ---------- Clé ---------- */
.cle { display: flex; flex-wrap: wrap; align-items: center; gap: var(--esp-3); margin-top: var(--esp-4); }
.cle code {
  flex: 1 1 18rem; min-width: 0; overflow-wrap: anywhere;
  padding: 0.6rem 0.8rem; border-radius: var(--radius);
  background: var(--paper-deep); font-size: 0.9rem;
}

/* ---------- Réglages ---------- */
.reglages { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-4); flex-wrap: wrap; padding: var(--esp-3) 0; }
.reglages + .reglages { border-top: 1px solid var(--border); }
.reglages > div { flex: 1 1 20rem; min-width: 0; }
.reglages form { margin: 0; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-3); }

/* ---------- Fenêtres ---------- */
.voile {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: var(--voile);
  animation: fondu 0.18s var(--ease);
}
.voile[hidden] { display: none; }
.modale {
  width: min(30rem, 100%);
  background: var(--paper); border-radius: var(--radius-card);
  padding: 2rem 2.26667rem; box-shadow: var(--shadow-overlay);
  display: flex; flex-direction: column; gap: var(--esp-3);
  animation: apparait 0.22s var(--ease);
}
.modale-pied { display: flex; justify-content: flex-end; gap: var(--esp-2); margin-top: var(--esp-4); flex-wrap: wrap; }
@keyframes fondu { from { opacity: 0; } }
@keyframes apparait { from { opacity: 0; transform: translateY(6px); } }

.apercu-grand {
  width: min(64rem, 92vw); max-height: 92vh; padding: 0; border: 0;
  border-radius: var(--radius-card); background: var(--paper); color: var(--text);
  box-shadow: var(--shadow-overlay); overflow: hidden;
}
.apercu-grand::backdrop { background: var(--voile); }
.apercu-grand-entete { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-3); padding: var(--esp-2) var(--esp-2) var(--esp-2) var(--esp-6); }
.apercu-grand-entete p { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apercu-grand img { width: 100%; max-height: calc(92vh - 3.5rem); object-fit: contain; background: var(--paper-deep); }

/* ---------- Petits écrans ---------- */
@media (max-width: 640px) {
  .topbar { padding: 0 16px; min-height: 3.75rem; }
  .topbar .button span { display: none; }
  .topbar .button { width: var(--cible); height: var(--cible); padding: 0; }
  .logo img { height: 1.6rem; }
  .contenu { padding: var(--esp-5) 16px var(--esp-8); }
  .carte { padding: var(--esp-5); }
  .tableau-defile { margin: 0 calc(-1 * var(--esp-5)); }
  .tableau th:first-child, .tableau td:first-child { padding-left: var(--esp-5); }
  .connexion-carte { padding: var(--esp-6) var(--esp-5); }
  .modale { padding: var(--esp-6) var(--esp-5); }
  .galerie { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--esp-3); }
  .fichier-actions .button span { display: none; }
  .fichier-actions .button { width: 2.4rem; padding: 0; }
}

@media (pointer: coarse) {
  .button, .segment { min-height: var(--cible); }
  .icon-button { width: var(--cible); height: var(--cible); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.carte > .aide + form { margin-top: var(--esp-4); }
