/* Portail clients — ce qui est propre au produit.
   Toutes les valeurs viennent des jetons du kit (public/charte) : aucune
   couleur, aucune graisse, aucun rayon posé à la main ici. */

/* Les composants du kit fixent leur `display` : l'attribut hidden doit gagner. */
[hidden] { display: none !important; }

/* Un portail peut porter le design system de son client (public/themes/). Tant
   que la page ne sait pas lequel, elle ne montre rien, sur le fond commun à
   tous : aucun éclair de la charte avant le thème d'un client (page.js). */
:root[data-theme-pending] { background: var(--bg); }
:root[data-theme-pending] body { visibility: hidden; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Portail : canevas gris chaud, surfaces blanches (le style Comète). */
body { background: var(--bg-alt); min-height: 100vh; display: flex; flex-direction: column; }
/* `main.pn-wrap` : le kit pose `padding: 0 …` sur .pn-wrap, il faut passer devant. */
main.pn-wrap { flex: 1; width: 100%; padding-top: var(--sp-8); padding-bottom: var(--sp-8); }
h1 { margin: var(--sp-3) 0 var(--sp-4); }
.pn-lead { margin-bottom: var(--sp-6); }

/* Le kit colore tous les liens (repos, survol, visité) : un bouton ou une
   carte posés sur un lien gardent leur propre encre. */
a.pn-btn--primary:hover, a.pn-btn--primary:visited { color: var(--on-accent); }

/* ---------- Barre ---------- */
/* Un nom de portail long cède la place : il se tronque, le reste de la barre ne bouge pas. */
.bar__home { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; color: var(--fg); font-weight: var(--fw-demi); white-space: nowrap; }
.bar__home svg { flex: none; }
.bar__home span { overflow: hidden; text-overflow: ellipsis; }
.bar__home:visited, .bar__home:hover { color: var(--fg); }
.bar__end { margin-left: auto; display: flex; align-items: center; gap: var(--sp-4); flex: none; font-size: var(--fs-sm); }
.bar__who { max-width: 28ch; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__link, .bar__link:visited { color: var(--fg); font-weight: var(--fw-demi); }
.bar__link:hover { color: var(--accent-press); }
/* Le logo du client, à la hauteur du signe Plan.Net. Il n'existe que si le
   thème en apporte le fichier : trois jetons (image, proportions, affichage). */
.bar__client {
  display: var(--client-logo-display, none);
  flex: none;
  height: 30px;
  aspect-ratio: var(--client-logo-ratio, 1);
  background: var(--client-logo, none) center / contain no-repeat;
}

/* ---------- Portail ---------- */
.hub-draft { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--fg-muted); margin-bottom: var(--sp-5); }
/* Les onglets défilent à l'horizontale sur un écran étroit. Le défilement est
   porté par l'enveloppe : posé sur .pn-tabs, il couperait le filet de l'onglet actif. */
.filters { margin-bottom: var(--sp-5); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.filters .pn-tabs { min-width: max-content; }
.filters .pn-tab { white-space: nowrap; }

.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-5); }

.hub-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 216px;
  padding: var(--sp-6);
  background: var(--bg);
  color: var(--fg);
  border-bottom: var(--border-w-bold) solid transparent;
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.hub-card:visited { color: var(--fg); }
.hub-card:hover, .hub-card:focus-visible { color: var(--fg); border-bottom-color: var(--accent); box-shadow: var(--shadow-sm); }
.hub-card--portal { min-height: 152px; }
.hub-card__name { font-size: var(--fs-h4); line-height: var(--lh-h4); }
.hub-card__text { margin: 0; font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--fg-muted); }
.hub-card__foot { margin-top: auto; padding-top: var(--sp-4); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-xs); }
.hub-card__signin { color: var(--fg-muted); }
.hub-card__open { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); font-weight: var(--fw-demi); color: var(--accent); white-space: nowrap; }

.hub-contact { margin: var(--sp-7) 0 0; font-size: var(--fs-sm); color: var(--fg-muted); }

/* ---------- Administration ---------- */
.surface { background: var(--bg); padding: var(--sp-6); }

.admin-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.admin-notice { margin: 0; font-size: var(--fs-sm); color: var(--fg-muted); }
/* minmax(0, 1fr) : sans lui, un tableau large élargit la grille et toute la page avec. */
.admin-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
.admin-h2 { font-size: var(--fs-h3); line-height: var(--lh-h3); margin: var(--sp-8) 0 var(--sp-2); }
.admin-note { max-width: 62ch; margin-bottom: var(--sp-4); }

.portal { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
.portal__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-4); }
.portal__title { display: flex; align-items: center; gap: var(--sp-3); }
.portal__name { font-size: var(--fs-h4); line-height: var(--lh-h4); }
.portal__actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.portal__meta, .portal__empty { margin: 0; }
a.pn-btn--ghost, a.pn-btn--ghost:visited { color: var(--accent); }

/* Un tableau large défile dans son conteneur, jamais la page. `position: relative` :
   sans lui, un libellé .sr-only (positionné en absolu) échappe au conteneur et élargit la page. */
.table-scroll { position: relative; overflow-x: auto; }
.row-order, .row-actions { white-space: nowrap; }
.row-actions { text-align: right; }
.row-card { min-width: 240px; }
.row-url { display: block; overflow-wrap: anywhere; }
/* Les actions d'une ligne restent à l'encre : le rouge est réservé à l'action principale. */
.row-btn { padding: var(--sp-1) var(--sp-2); background: none; border: none; font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: var(--fw-demi); color: var(--fg); cursor: pointer; }
.row-btn:hover { color: var(--accent-press); }
.icon-btn { display: inline-flex; padding: var(--sp-1); background: none; border: none; color: var(--fg); cursor: pointer; }
.icon-btn:hover:not(:disabled) { color: var(--accent-press); }
.icon-btn:disabled { color: var(--fg-subtle); cursor: not-allowed; }

/* ---------- Fenêtres de saisie ---------- */
.dialog {
  width: min(560px, calc(100vw - 2 * var(--sp-4)));
  max-height: calc(100vh - 2 * var(--sp-4));
  overflow-y: auto;
  padding: var(--sp-6);
  border: none;
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: color-mix(in srgb, var(--pn-blackest-black) 55%, transparent); }
.dialog h2 { font-size: var(--fs-h4); line-height: var(--lh-h4); margin-bottom: var(--sp-5); }
.dialog .pn-label { margin-top: var(--sp-4); }
.dialog h2 + .pn-label { margin-top: 0; }
.dialog .pn-hint, .dialog .pn-error { margin-bottom: 0; }
.dialog .pn-error { margin-top: var(--sp-4); }
.dialog .pn-error:empty { display: none; }
.check { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-5); font-size: var(--fs-sm); }
.check input { accent-color: var(--fg); } /* sinon le bleu du navigateur, hors charte */
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--sp-3); margin-top: var(--sp-6); }

.foot { padding: var(--sp-5) var(--sp-6); font-size: var(--fs-xs); color: var(--fg-muted); }

@media (max-width: 600px) {
  main.pn-wrap, .pn-toolbar, .foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  main.pn-wrap { padding-top: var(--sp-7); }
  .bar__who { display: none; }
  /* Avec le lien d'administration, la barre ne tient plus : le signe seul suffit,
     et le logo du client cède la place. */
  .pn-toolbar:has(.bar__link:not([hidden])) .bar__home span { display: none; }
  .pn-toolbar:has(.bar__link:not([hidden])) .bar__client { display: none; }
  h1 { font-size: var(--fs-h2); line-height: var(--lh-h2); }
  .surface { padding: var(--sp-5) var(--sp-4); }
}
