/* ==========================================================================
   ToulBox — design-system layer (release v3, 2026-11)
   --------------------------------------------------------------------------
   Plain CSS, loaded LAST in the `toul_box_theme/global` library (theme weight).
   Why plain CSS and not SCSS: css/ and scss/ have drifted (some compiled CSS
   was edited by hand), so re-running gulp would silently revert fixes.
   This file only ADDS rules on top of the existing theme; delete its line in
   toul_box_theme.libraries.yml to roll back. See docs/UX_AUDIT.md.

   Sections
     1. Tokens (extends --tb-* from css/base/variables.css)
     2. Base: typography, links, focus, motion
     3. App shell (logged-in pages): background, header, sidebar
     4. Surfaces: cards, exposed filters, tables, pager
     5. Forms
     6. Buttons
     7. Status tags (order-status / justificatif-*)
     8. Accessible colour utilities
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Brand — the raw brand colours are kept for large shapes and icons.
     The *-strong variants reach WCAG AA 4.5:1 for text on white. */
  --tb-primary: #85224C;            /* 9.0:1 on white */
  --tb-primary-hover: #6E1C3F;
  --tb-primary-subtle: #F7EEF2;
  --tb-primary-border-subtle: #E6CAD6;
  --tb-secondary: #EC4D22;          /* 3.7:1 — decoration / large text only */
  --tb-secondary-strong: #C2381A;   /* 5.4:1 */
  --tb-success: #8DC63F;            /* 2.0:1 — decoration only */
  --tb-success-strong: #3F7A1C;     /* 5.2:1 */
  --tb-danger: #F05353;             /* 3.5:1 — decoration only */
  --tb-danger-strong: #C42B2B;      /* 5.6:1 */
  --tb-info-strong: #0B5ED7;        /* 5.8:1 with white */

  /* Neutrals */
  --tb-text: #231F20;               /* 16.3:1 */
  --tb-text-muted: #5C5658;         /* 7.2:1 on white, 6.6:1 on app bg */
  --tb-bg-app: #F6F4F5;             /* page background behind cards */
  --tb-surface: #FFFFFF;
  --tb-surface-sunken: #FAF8F9;
  --tb-border: #E3DFE1;             /* decorative separators */
  --tb-border-strong: #8A8A8A;      /* form controls, 3.4:1 (WCAG 1.4.11) */

  /* Status tags (soft): background / text / border — text ≥ 6:1 */
  --tb-tag-orange-bg: #FCEBE5;  --tb-tag-orange-fg: #A3300F;  --tb-tag-orange-bd: #F4C3B3;
  --tb-tag-grey-bg:   #EFEDEE;  --tb-tag-grey-fg:   #4A4547;  --tb-tag-grey-bd:   #D6D1D3;
  --tb-tag-blue-bg:   #E8F0FE;  --tb-tag-blue-fg:   #0B4FB3;  --tb-tag-blue-bd:   #BCD3FA;

  /* Elevation (Open Props-like scale, tinted with the body colour) */
  --tb-shadow-1: 0 1px 2px rgba(35, 31, 32, .05), 0 1px 3px rgba(35, 31, 32, .07);
  --tb-shadow-2: 0 2px 4px rgba(35, 31, 32, .05), 0 6px 16px rgba(35, 31, 32, .08);
  --tb-shadow-3: 0 10px 30px rgba(35, 31, 32, .14);

  /* Radii and spacing (4px grid) */
  --tb-radius-xl: 0.75rem;          /* 12px — cards */
  --tb-radius-pill: 999px;
  --tb-space-1: .25rem; --tb-space-2: .5rem; --tb-space-3: .75rem;
  --tb-space-4: 1rem;   --tb-space-5: 1.5rem; --tb-space-6: 2rem;

  /* Focus: 2px solid outline (9:1) + soft halo */
  --tb-focus-ring: 0 0 0 4px rgba(133, 34, 76, .18);

  /* Bootstrap runtime variables that are read at use time */
  --bs-body-color: var(--tb-text);
  --bs-secondary-color: var(--tb-text-muted);
  --bs-border-color: var(--tb-border);
  --bs-link-color: var(--tb-primary);
  --bs-link-color-rgb: 133, 34, 76;
  --bs-link-hover-color: var(--tb-primary-hover);
  --bs-link-hover-color-rgb: 110, 28, 63;
}

/* 2. Base ------------------------------------------------------------------ */
html { scroll-padding-top: 9rem; }          /* WCAG 2.4.11 — sticky header on node pages */
body { color: var(--tb-text); text-rendering: optimizeLegibility; }

/* Content links (.layout-content--node a, a.action): fixed at the source in
   css/base/elements.css (#EC4D22 → #C2381A) to keep their cascade position;
   component-specific link colours (offer cards, footer…) are untouched. */

/* Keyboard focus: keep the theme's 2px outline and add a halo so it reads on
   coloured surfaces too. */
:focus-visible { outline: 2px solid var(--tb-primary); outline-offset: 2px; }
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible { box-shadow: var(--tb-focus-ring); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 3. App shell — logged-in pages (container has .layout-container, nodes don't) */
.layout-container {
  background-color: var(--tb-bg-app);
  min-height: 100vh;
}

/* Header: white bar with a hairline and light elevation. */
.layout-container > header[role="banner"] {
  background: var(--tb-surface);
  border-bottom: 1px solid var(--tb-border);
  box-shadow: var(--tb-shadow-1);
  margin-inline: calc(var(--bs-gutter-x, 1.5rem) * -.5);
  padding-inline: calc(var(--bs-gutter-x, 1.5rem) * .5);
  position: relative;
  z-index: 5;
}
@media (min-width: 992px) {
  .layout-container .region-header { height: 96px; }
}

/* Page titles: one clear H1, calmer H2. */
.layout-container .layout-content h1 {
  font-size: clamp(1.625rem, 1.25rem + 1.2vw, 2.125rem);
  letter-spacing: -.01em;
  margin-bottom: var(--tb-space-5);
}
.layout-container .layout-content h1.welcome {
  font-size: clamp(1.375rem, 1.1rem + .8vw, 1.75rem);
  margin-bottom: var(--tb-space-4);
}
.layout-container .layout-content h2 { font-size: clamp(1.375rem, 1.15rem + .7vw, 1.75rem); }
.layout-container .layout-content .region-content { padding-top: var(--tb-space-5); padding-bottom: 4rem; }

/* Sidebar: white rail, items aligned to the top instead of floating mid-page. */
@media (min-width: 992px) {
  .layout-container .layout-sidebar-first {
    background: var(--tb-surface);
    border-right: 1px solid var(--tb-border);
  }
  .layout-container .region-sidebar-first {
    align-items: start;
    align-content: start;
    padding-top: var(--tb-space-5);
  }
  .layout-container #block-menuclient,
  .layout-container #block-menubeneficiaire { margin-top: 0; }
}
/* Menu entries (beneficiaire / client / operateur blocks render .btn links).
   Expanded sections stay filled burgundy (block.css); others get a soft
   primary hover instead of the flat #EBEBEB grey. */
.layout-sidebar-first .menu-client-block > .btn {
  border-radius: var(--tb-radius-md, .5rem);
  box-shadow: none;
  font-weight: 400;          /* Book: the 220px buttons were sized for it */
  height: auto;              /* grow instead of clipping long labels (EN) */
  min-height: 50px;
  align-items: center;
  transition: background-color var(--tb-t-fast, .15s ease), color var(--tb-t-fast, .15s ease);
}
.layout-sidebar-first .menu-client-block > .btn:not([aria-expanded="true"]):hover,
.layout-sidebar-first .menu-client-block > .btn:not([aria-expanded="true"]):focus-visible {
  background-color: var(--tb-primary-subtle);
  border-color: var(--tb-primary-subtle);
  color: var(--tb-primary);
}
.layout-sidebar-first .blockSousMenuMesCommandes a,
.layout-sidebar-first .blockSousMenuBeneficiare a {
  display: inline-block;
  padding: .125rem 0;
}
.layout-sidebar-first .blockSousMenuMesCommandes a:hover,
.layout-sidebar-first .blockSousMenuBeneficiare a:hover { text-decoration: underline; }

/* 4. Surfaces -------------------------------------------------------------- */
/* Exposed filters → a card. */
.layout-container .layout-content .view-filters {
  background: var(--tb-surface);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-xl);
  box-shadow: var(--tb-shadow-1);
  padding: var(--tb-space-4) var(--tb-space-5);
  margin-bottom: var(--tb-space-5);
}

/* Listing tables → a card with a sunken header row and row separators. */
.layout-container .layout-content table.views-view-table,
.layout-container .layout-content .view-content > table.table {
  --bs-table-bg: var(--tb-surface);
  background: var(--tb-surface);
  border: 1px solid var(--tb-border);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--tb-radius-xl);
  box-shadow: var(--tb-shadow-1);
}
/* Rounded corners on the corner cells (no overflow:hidden, which would crop
   wide tables such as the operator list). */
.layout-container .layout-content table.views-view-table > thead > tr:first-child > th:first-child { border-top-left-radius: var(--tb-radius-xl); }
.layout-container .layout-content table.views-view-table > thead > tr:first-child > th:last-child { border-top-right-radius: var(--tb-radius-xl); }
.layout-container .layout-content table.views-view-table > tbody > tr:last-child > td:first-child { border-bottom-left-radius: var(--tb-radius-xl); }
.layout-container .layout-content table.views-view-table > tbody > tr:last-child > td:last-child { border-bottom-right-radius: var(--tb-radius-xl); }
/* Below 992px wide tables scroll horizontally inside their card. */
@media (max-width: 991.98px) {
  .layout-container .layout-content table.views-view-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
.layout-container .layout-content table.views-view-table > thead > tr > th {
  background: var(--tb-surface-sunken);
  border-bottom: 1px solid var(--tb-border);
  color: var(--tb-text-muted);
  font-size: var(--tb-fs-xs, .75rem);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding-top: var(--tb-space-3);
  padding-bottom: var(--tb-space-3);
}
.layout-container .layout-content table.views-view-table > thead > tr > th a {
  color: inherit;
  text-decoration: none;
}
.layout-container .layout-content table.views-view-table > thead > tr > th a:hover,
.layout-container .layout-content table.views-view-table > thead > tr > th.is-active a { color: var(--tb-primary); text-decoration: underline; }
.layout-container .layout-content table.views-view-table > tbody > tr > td {
  border-bottom: 1px solid var(--tb-border);
  padding-top: var(--tb-space-3);
  padding-bottom: var(--tb-space-3);
}
.layout-container .layout-content table.views-view-table > tbody > tr:last-child > td { border-bottom: 0; }
/* Zebra: the #F8F8F8 rows (1.06:1) become a faint warm tint + separators,
   with a primary hover. Contextual Bootstrap rows (.table-danger…) keep their colour. */
.layout-container .layout-content table.views-view-table > tbody > tr:not(.table-active):not(.table-danger):not(.table-warning):not(.table-success):not(.table-info):not(.table-secondary) > td {
  background-color: var(--tb-surface);
}
.layout-container .layout-content table.views-view-table > tbody > tr:nth-child(even):not(.table-active):not(.table-danger):not(.table-warning):not(.table-success):not(.table-info):not(.table-secondary) > td {
  background-color: var(--tb-surface-sunken);
}
.layout-container .layout-content table.views-view-table > tbody > tr:hover > td {
  background-color: var(--tb-primary-subtle);
}
/* Sortable headers: core only draws an arrow on the column already sorted,
   so nothing showed the other labels were clickable. Every sortable header
   gets a neutral ▲▼ pair; the sorted one (aria-sort — .tablesort--asc/desc
   name the NEXT order) highlights its direction. Drawn as the link's
   background so it stays on the label's last line and is never underlined. */
.layout-container .layout-content table.views-view-table > thead > tr > th a[href*="order="] {
  padding-right: .875rem;
  background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3e%3cpath fill='%238A8A8A' d='M4 0l4 5H0z'/%3e%3cpath fill='%238A8A8A' d='M4 12L0 7h8z'/%3e%3c/svg%3e") no-repeat right center / .5rem .75rem;
}
.layout-container .layout-content table.views-view-table > thead > tr > th:not([aria-sort]) a[href*="order="]:hover,
.layout-container .layout-content table.views-view-table > thead > tr > th:not([aria-sort]) a[href*="order="]:focus-visible {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3e%3cpath fill='%2385224C' d='M4 0l4 5H0z'/%3e%3cpath fill='%2385224C' d='M4 12L0 7h8z'/%3e%3c/svg%3e");
}
.layout-container .layout-content table.views-view-table > thead > tr > th[aria-sort="ascending"] a[href*="order="] {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3e%3cpath fill='%2385224C' d='M4 0l4 5H0z'/%3e%3cpath fill='%23D6D1D3' d='M4 12L0 7h8z'/%3e%3c/svg%3e");
}
.layout-container .layout-content table.views-view-table > thead > tr > th[aria-sort="descending"] a[href*="order="] {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3e%3cpath fill='%23D6D1D3' d='M4 0l4 5H0z'/%3e%3cpath fill='%2385224C' d='M4 12L0 7h8z'/%3e%3c/svg%3e");
}
/* Core's grey twistie gives way to the pair above. The indicator is an empty
   inline span (theme's tablesort-indicator.html.twig, label in aria-label),
   so it cannot push the icon onto a line of its own. */
.layout-container .layout-content table.views-view-table > thead > tr > th .tablesort {
  display: inline;
  background: none;
}
/* Bulk-select column (operator, provider and client lists): room around the
   checkbox, which sat 4px from the card edge (table-sm). On clickable rows
   the padded cell toggles the checkbox (commande-offcanvas.js). */
.layout-container .layout-content table.views-view-table > thead > tr > th:first-child:has(input[type="checkbox"]),
.layout-container .layout-content table.views-view-table > tbody > tr > td:first-child:has(input[type="checkbox"]) {
  padding-left: var(--tb-space-4);
  padding-right: var(--tb-space-3);
}

/* Pager: real targets (≥ 32px) and a clear current page. */
.pager__items { gap: var(--tb-space-1); }
.pager__item,
.pager__item:not(.pager__item--next):not(.pager__item--last):not(.pager__item--previous):not(.pager__item--first) {
  height: auto;
  width: auto;
  font-size: var(--tb-fs-base, 1rem);
  border-radius: var(--tb-radius-md, .5rem);
}
.pager__item a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0 var(--tb-space-2);
  border-radius: var(--tb-radius-md, .5rem);
  color: var(--tb-primary);
}
.pager__item a:hover { background: var(--tb-primary-subtle); }
.pager__item.is-active { background-color: var(--tb-primary); }
.pager__item.is-active a { color: #fff; }

/* Dashboard order cards (benef-commande-section) — lift them off the page. */
.layout-container .benef-commande-section {
  background: var(--tb-surface);
  border-radius: var(--tb-radius-xl);
  box-shadow: var(--tb-shadow-2);
}

/* Header chips on the prune gradient: keep the white chip, but orange text at
   12-13px needs the strong orange (module CSS uses !important). */
.benef-commande-header .benef-commande-header__status,
.benef-commande-header .benef-commande-header__number {
  color: var(--tb-secondary-strong) !important;
  border-color: var(--tb-secondary-strong) !important;
}

/* Order wizard stepper: labels were 11-12px #ADB5BD (2.1:1). */
.commande-steps .step__label { font-size: var(--tb-fs-sm, .8125rem); color: var(--tb-text-muted); }
.commande-steps .step--done .step__label { color: var(--tb-secondary-strong); }
.commande-steps .step--active .step__label { color: var(--tb-primary); font-weight: 600; }

/* Service detail "Voir détails" (modal and full page, operator and
   beneficiary): the description was white-on-white text floating between the
   toggle and "Votre critère". It is now a tinted card. No padding/margin on
   or inside the .collapse (it would jump while animating): spacing comes from
   the toggle row and the heading. The toggle no longer wraps in its col-sm-2. */
.see-more.row { margin-bottom: var(--tb-space-3); }
.see-more.row > .col-sm-10:empty { display: none; }
.see-more.row > .col-sm-2 {
  flex: 0 0 auto;
  width: auto;
  margin-left: auto;
}
.see-more.row .pack-list-btn { white-space: nowrap; }
.see-more.row + .detail-pack {
  padding: 0;
  background: transparent;
}
.see-more.row + .detail-pack > .description-plus {
  padding: var(--tb-space-4) var(--tb-space-5);
  background: var(--tb-primary-subtle);
  border: 1px solid var(--tb-primary-border-subtle);
  border-radius: var(--tb-radius-md, .5rem);
  color: var(--tb-text);
}
.see-more.row + .detail-pack > .description-plus > :last-child { margin-bottom: 0; }
/* "Votre critère" (operator) or the criteria form (beneficiary). */
.see-more.row + .detail-pack + * { margin-top: var(--tb-space-5); }

/* 5. Forms ----------------------------------------------------------------- */
/* Inputs were #F8F8F8 without border (1.06:1): now white with a 3.4:1 border. */
.form-control,
.form-select,
.form-textarea,
input.form-text,
input.form-email,
input.form-tel,
input.form-number,
input.form-date,
select.form-select {
  background-color: var(--tb-surface);
  border: 1px solid var(--tb-border-strong);
  border-radius: var(--tb-radius-md, .5rem);
  color: var(--tb-text);
}
.form-control:hover,
.form-select:hover { border-color: var(--tb-text-muted); }
/* Profile and filter fields are wrapped in .blockElementProfil, whose block.css
   rule (specificity 0-3-1) forces #F8F8F8 on background and border. */
.blockElementProfil select,
.blockElementProfil input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]) {
  background-color: var(--tb-surface);
  border: 1px solid var(--tb-border-strong);
  border-radius: var(--tb-radius-md, .5rem);
}
.blockElementProfil select:focus,
.blockElementProfil input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):focus {
  border-color: var(--tb-primary);
  box-shadow: var(--tb-focus-ring);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--tb-primary);
  box-shadow: var(--tb-focus-ring);
}
.form-control::placeholder { color: #767676; opacity: 1; } /* 4.5:1 */
.form-control:disabled,
.form-select:disabled,
.form-control[readonly] { background-color: var(--tb-surface-sunken); }
.form-item > label,
.form-label,
.form-item__label,
fieldset > legend { font-weight: 500; color: var(--tb-text); }
.form-item--error-message,
.invalid-feedback { color: var(--tb-danger-strong); }
.form-control.error,
.form-select.error,
.form-control.is-invalid { border-color: var(--tb-danger-strong); }

/* 6. Buttons --------------------------------------------------------------- */
/* Bootstrap was compiled with absurd paddings (.btn-sm 60px, .btn-lg 119px). */
.btn { font-weight: 500; }
.btn-sm { --bs-btn-padding-x: .875rem; --bs-btn-padding-y: .375rem; }
.btn-lg { --bs-btn-padding-x: 1.75rem; --bs-btn-padding-y: .75rem; }
.btn-primary {
  --bs-btn-hover-bg: var(--tb-primary-hover);
  --bs-btn-hover-border-color: var(--tb-primary-hover);
  --bs-btn-active-bg: var(--tb-primary-hover);
  --bs-btn-active-border-color: var(--tb-primary-hover);
  box-shadow: var(--tb-shadow-1);
}
/* Orange outline buttons: text in brand orange was 3.7:1 → strong orange. */
.btn-outline-secondary {
  --bs-btn-color: var(--tb-secondary-strong);
  --bs-btn-border-color: var(--tb-secondary-strong);
  --bs-btn-hover-bg: var(--tb-secondary-strong);
  --bs-btn-hover-border-color: var(--tb-secondary-strong);
  --bs-btn-hover-color: #fff;
}
.btn-outline-primary {
  --bs-btn-hover-bg: var(--tb-primary-subtle);
  --bs-btn-hover-color: var(--tb-primary);
  --bs-btn-hover-border-color: var(--tb-primary);
}

/* 7. Status tags ----------------------------------------------------------- */
/* Text statuses (orange / grey / blue) → soft tags; the solid fills failed
   AA with white text (orange 3.7:1). Icon-only statuses (green ✓ / red ✕)
   stay solid with accessible fills. The dashboard header badge keeps its
   own white style (.benef-commande-header__status). */
.order-status:not(.benef-commande-header__status),
.justificatif-orange-dashboard,
.justificatif-grey-dashboard,
.justificatif-blue-dashboard,
.justificatif-green-dashboard,
.justificatif-red-dashboard {
  border: 1px solid transparent;
  border-radius: var(--tb-radius-md, .5rem);
  font-size: var(--tb-fs-sm, .8125rem);
  font-weight: 600;
  line-height: 1.25;
  min-height: 1.75rem;
  padding: .25rem .75rem;
}
.order-status.status-orange:not(.benef-commande-header__status),
.justificatif-orange-dashboard {
  background-color: var(--tb-tag-orange-bg);
  border-color: var(--tb-tag-orange-bd);
  color: var(--tb-tag-orange-fg);
}
.order-status.status-grey:not(.benef-commande-header__status),
.justificatif-grey-dashboard {
  background-color: var(--tb-tag-grey-bg);
  border-color: var(--tb-tag-grey-bd);
  color: var(--tb-tag-grey-fg);
}
.order-status.status-blue:not(.benef-commande-header__status),
.justificatif-blue-dashboard {
  background-color: var(--tb-tag-blue-bg);
  border-color: var(--tb-tag-blue-bd);
  color: var(--tb-tag-blue-fg);
}
.status-green,
.justificatif-green-dashboard { background-color: var(--tb-success-strong); color: #fff; }
.status-red,
.justificatif-red-dashboard { background-color: var(--tb-danger-strong); color: #fff; }

/* 8. Accessible colour utilities ------------------------------------------ */
.text-secondary { color: var(--tb-secondary-strong) !important; }
.text-success   { color: var(--tb-success-strong) !important; }
.text-danger    { color: var(--tb-danger-strong) !important; }
.text-muted     { color: var(--tb-text-muted) !important; }
