/* ==========================================================================
   Composants du nouveau site, par-dessus css/theme.css (repris de Drupal) :
   on réutilise ses variables (--surface, --primary…), donc le mode sombre
   fonctionne sans rien ajouter.
   ========================================================================== */

.icon-svg { width: 1.15em; height: 1.15em; flex: none; }

/* --- En-tête de page : titre à gauche, actions à droite ------------------ */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 0 0 20px;
}
.page-head__text { min-width: 0; }
.page-head .page-title { margin: 0; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-head__actions .button { margin: 0; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
}
.back-link:hover { color: var(--primary); text-decoration: none; }

/* --- Boutons ------------------------------------------------------------- */
a.button.button--ghost, button.button.button--ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  min-height: 40px;
  padding: .45em 1em;
  font-size: .92rem;
}
a.button.button--ghost:hover { background: var(--surface-2); color: var(--text); }
a.button.button--danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
button.button.button--danger-solid { background: var(--danger); }
button.button.button--danger-solid:hover { background: var(--danger); filter: brightness(1.1); }

/* Bouton carré avec une icône seule (modifier, supprimer…). */
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
button.icon-button { border: 0; background: transparent; font: inherit; cursor: pointer; padding: 0; }
.icon-button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-button--danger:hover { background: var(--danger-soft); color: var(--danger); }

/* --- Liste de cartes (mes listes, éléments) ------------------------------ */
.cards { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }

.card-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 10px 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card-row__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text);
}
.card-row__main:hover { text-decoration: none; }
.card-row__title { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.card-row__meta { font-size: .85rem; color: var(--text-muted); }
.card-row__actions { display: flex; gap: 2px; flex: none; position: relative; z-index: 1; }

/* Lien « étendu » : son ::after couvre toute la carte, qui devient cliquable. */
.stretched::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card-row:has(.stretched):hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.card-row:has(.stretched):hover .card-row__title { color: var(--primary); }

/* Éléments : la description garde ses propres liens, la carte n'est pas cliquable. */
.card-row--item { align-items: flex-start; }
.item-description { line-height: 1.5; overflow-wrap: anywhere; }
.item-description a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

/* --- Formulaire d'ajout d'un élément ------------------------------------- */
.add-item { padding: 16px 18px; margin-bottom: 24px; }
.add-item__label { display: block; margin: 0 0 8px; font-weight: 700; }
.add-item textarea { min-height: 64px; resize: vertical; }
.add-item__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 10px;
}
.add-item__footer .button { margin: 0; }
.hint { font-size: .85rem; color: var(--text-muted); }

/* Champ + bouton sur une ligne (partage). */
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form .button { margin: 0; flex: none; }
.add-item .hint { margin: 10px 0 0; }

/* Pastille de nombre dans un bouton (« Partager 3 »). */
.button__count {
  display: inline-grid;
  place-items: center;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 .4em;
  border-radius: 999px;
  font-size: .8em;
  background: rgba(255, 255, 255, .25);
}

.section-title {
  margin: 0 0 10px;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--warning-soft);
  color: var(--warning);
}

/* --- Listes partagées (Les listes, page invité) --------------------------- */
.page-subtitle { margin: 2px 0 0; color: var(--text-muted); font-weight: 600; }
.page-head__actions form { margin: 0; }
.card-row__actions { align-items: center; }
.card-row__actions form { margin: 0; }
.card-row__owner {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
}

.year-filter { margin: 0; }
.year-filter select { min-height: 40px; width: auto; min-width: 0; padding: .4em 2.2em .4em .9em; font-size: .92rem; border-radius: 999px; }

/* Pastilles d'état et boutons Prendre / Libérer. */
.pill, .pill-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill { background: var(--surface-2); color: var(--text-muted); }
.pill--mine { background: var(--success-soft); color: var(--success); }
.pill-button { border: 0; cursor: pointer; background: var(--primary); color: var(--on-primary); transition: background .15s, filter .15s; }
.pill-button:hover { background: var(--primary-hover); }
.pill-button--mine { background: var(--success-soft); color: var(--success); }
/* Au survol, « Pris par vous » annonce ce que fait le clic : libérer. */
.pill-button--mine:hover { background: var(--danger-soft); color: var(--danger); }
.pill-button--mine:hover span { display: none; }
.pill-button--mine:hover::after { content: "Libérer"; }

.card-row.is-mine { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.card-row.is-taken .item-description { color: var(--text-muted); }
.card-row.is-taken { box-shadow: none; background: color-mix(in srgb, var(--surface) 60%, transparent); }

/* --- Ma sélection -------------------------------------------------------- */
/* Pastilles de filtre par statut, défilables horizontalement sur mobile. */
.chips {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 36px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
}
.chip:hover { text-decoration: none; border-color: var(--primary); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip__count {
  min-width: 1.6em;
  padding: 0 .4em;
  border-radius: 999px;
  font-size: .8em;
  text-align: center;
  background: var(--surface-2);
  color: var(--text-muted);
}
.chip.is-active .chip__count { background: rgba(255, 255, 255, .25); color: inherit; }

.card-row__owner a { color: inherit; }
.card-row--selection .card-row__main { gap: 4px; }
.card-row.is-removed .item-description { color: var(--text-muted); text-decoration: line-through; text-decoration-thickness: 1px; }

.status-form { display: flex; gap: 6px; }
/* La couleur du sélecteur reflète le statut (même code couleur que l'ancien site). */
select.status-select {
  width: auto;
  min-width: 0;   /* le thème impose 22em aux <select> sur ordinateur */
  min-height: 38px;
  padding: .35em 2.2em .35em .9em;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 700;
  border-color: transparent;
  background-color: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
}
select.status-select--1, select.status-select--2, select.status-select--3 { background-color: var(--primary-soft); color: var(--primary); }
select.status-select--4 { background-color: var(--success-soft); color: var(--success); }

/* --- Mes emails ---------------------------------------------------------- */
.page-intro { margin: -8px 0 20px; max-width: 70ch; color: var(--text-muted); }
.card-row__title--email { overflow-wrap: anywhere; }
.pill--small { min-height: 22px; padding: 0 8px; font-size: .75rem; gap: 4px; }
.card-row__meta .pill { vertical-align: middle; }
.cards + .add-item { margin-top: 8px; }

/* --- Formulaires simples et confirmation --------------------------------- */
.form-card { max-width: 640px; padding: 20px; }
.form-card .form-actions { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.form-card .form-actions .button { margin: 0; }
.confirm-card__question { margin: 0 0 6px; font-size: 1.1rem; font-weight: 700; }
.confirm-card__detail { margin: 0 0 18px; color: var(--text-muted); white-space: pre-line; }

/* --- État vide ----------------------------------------------------------- */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state p { margin: 0 0 8px; }
.empty-state__icon { width: 40px; height: 40px; color: var(--primary); opacity: .7; }

/* --- Mobile -------------------------------------------------------------- */
@media (max-width: 39.99em) {
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head__actions { width: 100%; }
  .card-row { padding-left: 14px; }
  .add-item__footer .button { width: 100%; }
  .inline-form { flex-direction: column; }
  /* Éléments : le bouton Prendre passe sous la description, pleine largeur. */
  .card-row--item { flex-wrap: wrap; padding-right: 14px; }
  .card-row--item .card-row__actions { width: 100%; }
  .card-row--item .card-row__actions form, .card-row--item .pill-button, .card-row--item .pill { width: 100%; justify-content: center; }
  .card-row--item .card-row__actions:has(.icon-button) { width: auto; }
  .status-form select.status-select { flex: 1; }
}

/* Pot de miel du formulaire d'inscription : hors écran plutôt que display:none
   (certains robots ignorent les champs en display:none). */
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Nom de l'utilisateur dans le menu : simple libellé, aligné sur les liens voisins
   (même hauteur et même taille de texte que .header-nav a). */
.header-nav ul { align-items: center; }
.menu-user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: .45em .9em;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}
.menu-user .icon-svg { color: var(--text-muted); }
.sidebar .menu-user { min-height: 42px; padding: .45em .8em; }

/* --- Barre d'édition (Trix) ---------------------------------------------- */
/* La barre elle-même (boutons utiles, en français) est dans components/rich-editor. */
trix-toolbar .trix-button-row { justify-content: flex-start; gap: 6px; overflow-x: auto; }
trix-toolbar .trix-button-group {
  margin: 0 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
trix-toolbar .trix-button { border: 0; border-left: 1px solid var(--border); background: transparent; color: var(--text); }
trix-toolbar .trix-button:first-child { border-left: 0; }
trix-toolbar .trix-button:not(:disabled):hover { background: var(--surface-2); }
trix-toolbar .trix-button.trix-active { background: var(--primary-soft); }
trix-toolbar .trix-button--icon::before { opacity: .75; }
trix-toolbar .trix-button.trix-active::before { opacity: 1; }
/* Les icônes de Trix sont noires : on les inverse en mode sombre. */
:root[data-theme="dark"] trix-toolbar .trix-button--icon::before { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) trix-toolbar .trix-button--icon::before { filter: invert(1); }
}

/* Fenêtre « lien » de la barre. */
trix-toolbar .trix-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
trix-toolbar .trix-dialog .trix-input--dialog { min-height: 38px; margin-right: 8px; }
trix-toolbar .trix-dialog .trix-button--dialog { min-height: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Zone de saisie : même allure que les autres champs. */
trix-editor.rich-editor {
  min-height: 80px;
  padding: .6em .85em;
  font-size: 16px;   /* évite le zoom automatique sur iOS */
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
trix-editor.rich-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
trix-editor.rich-editor.error { border-color: var(--danger); }
trix-editor.rich-editor:empty:not(:focus)::before { color: var(--text-muted); }
trix-editor.rich-editor a, .item-description a { color: var(--primary); }
.form-item__label { display: block; margin: 0 0 6px; font-weight: 600; font-size: .95rem; }

/* Mise en forme des descriptions affichées. */
.item-description ul, .item-description ol { margin: 4px 0; padding-left: 1.4em; }
.item-description li { margin: 0; }

/* Explication d'un filtre (page Utilisateurs), avec son action groupée. */
.filter-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; }
.filter-note p { margin: 0; color: var(--text-muted); }
.filter-note .button { margin: 0; }
