/* ============================================================
   Custom app-side CSS.

   Kept OUT of the designer's Sass token file
   (`ambre-bootstrap-theme.sass`): that file holds Bootstrap
   *variables* only. Component rules that the maquette needs but
   Bootstrap has no class for live here instead.
   ============================================================ */

/* --- Nunito web font ----------------------------------------
   Loads the locally-bundled Nunito referenced by the theme's
   `font-family`. Two variable fonts cover every weight. The
   `../fonts/` path resolves from this stylesheet (served at
   `www/`) up to the `fonts` resource path at the app root, so it
   also works behind a proxy prefix.
   ------------------------------------------------------------ */
@font-face {
  font-family: "Nunito";
  src: url("../fonts/Nunito-VariableFont_wght.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  src: url("../fonts/Nunito-Italic-VariableFont_wght.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* --- Locked / disabled-looking button ------------------------
   Grey filled button for a locked option (e.g. the forced
   "Déterministe" mode in the simulation modal). Colours come from
   the theme's grey scale (no hardcoded values). The `.btn.`
   selector wins over the base `.btn-*` set by `bs_button()`.

   (The maquette's orange trash / prev-next buttons need no custom
   CSS: they use the theme-generated `.btn-secondary-dark` /
   `.btn-outline-secondary-dark` classes directly.)
   ------------------------------------------------------------ */
.btn.btn-ambre-locked {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--bs-gray-500);
  --bs-btn-border-color: var(--bs-gray-500);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--bs-gray-600);
  --bs-btn-hover-border-color: var(--bs-gray-600);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--bs-gray-600);
  --bs-btn-active-border-color: var(--bs-gray-600);
}

/* --- Sticky sidebar ------------------------------------------
   Keep the step navigation pinned to the top of the viewport while
   the main content scrolls. `align-self: flex-start` stops the flex
   row from stretching the column to full height (which would make it
   as tall as the scroll container and defeat `position: sticky`);
   the fixed viewport height + internal scroll handles a nav taller
   than the screen.
   ------------------------------------------------------------ */
.ambre-sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  /* Maquette drop shadow (Figma: 4px 4px 4.3px 0 primary-dark). primary-dark is
     mapped to $primary, i.e. --bs-primary. z-index lifts the shadow above the
     adjacent main content. */
  box-shadow: 4px 4px 4.3px 0 var(--bs-primary);
  z-index: 1;
}

/* --- Sidebar navigation bullets ------------------------------
   A coloured dot before each step (gold inactive; dark-teal on a
   light-teal pill when active). The pseudo-element dot and the
   active-state override can't be Bootstrap utility classes, so
   they live here. The item's layout is utilities on the element
   itself — see step_nav().
   ------------------------------------------------------------ */
.ambre-sidebar .list-group-item::before {
  content: "";
  flex: 0 0 auto;
  width: .9rem;
  height: .9rem;
  border-radius: 50%;
  background-color: var(--bs-secondary);
}
/* Unselected items carry no background — the neutral (#f8f9f9) sidebar shows
   through, both at rest and on hover; only the active/visited item gets the
   blue pill. Overriding the list-group CSS variables (rather than the default
   white item bg / grey hover) keeps that clean. */
.ambre-sidebar .list-group {
  --bs-list-group-bg: transparent;
  --bs-list-group-action-hover-bg: transparent;
  --bs-list-group-action-active-bg: transparent;
}
.ambre-sidebar .list-group-item.active {
  background-color: var(--bs-primary-light);
  color: var(--bs-primary);
  font-weight: 600;
}
.ambre-sidebar .list-group-item.active::before {
  background-color: var(--bs-primary);
}
/* Locked steps (`disabled` in step_nav()): the bullet becomes the padlock from
   `www/lock.png` (the url is relative to this stylesheet, so it also works
   behind a proxy prefix) and the label keeps the normal dark text --
   Bootstrap's greyed-out `.disabled` colours read as "broken" here, the padlock
   alone carries the meaning.

   Keyed on `:disabled` -- the attribute step_nav() sets, and the only signal
   for that state (it does not carry Bootstrap's `.disabled` class). Drop the
   attribute and every rule below stops applying, so the item is back to the
   plain gold-bullet look with nothing left to clean up. */
.ambre-sidebar .list-group-item:disabled {
  background-color: transparent;
  color: var(--bs-dark);
  opacity: 1;
}
.ambre-sidebar .list-group-item:disabled::before {
  border-radius: 0;
  background: url("lock.png") center / contain no-repeat;
}

/* --- Step screens: Shiny input plumbing ----------------------
   Drop the input containers' bottom margin and hide their empty
   labels so table/grid rows line up. These target Shiny-generated
   wrappers that the module code can't put a class on.
   ------------------------------------------------------------ */
.mod-pathogenes .shiny-input-container,
.mod-exposition .shiny-input-container,
.mod-mesures .shiny-input-container,
.mod-supplementaires .shiny-input-container,
.sim-header .shiny-input-container {
  margin-bottom: 0;
}
.mod-pathogenes .shiny-label-null,
.mod-exposition .shiny-label-null,
.mod-mesures .shiny-label-null,
.mod-supplementaires .shiny-label-null,
.sim-header .shiny-label-null {
  display: none;
}

/* --- Sub-tab pills (mesures + supplementaires) ---------------
   Inactive pills: light-teal fill, dark text. Active pill: teal +
   white, i.e. Bootstrap's own nav-pills values, re-asserted here.
   They have to be: `.nav-pills .nav-link` (ours) and
   `.nav-pills .nav-link.active` (Bootstrap's) weigh the same, and
   this stylesheet is served after bootstrap.min.css, so without
   the rule below the inactive fill wins on the active pill too and
   the two tabs become indistinguishable. Reading the values off the
   theme's variables keeps the colours the theme's business.
   ------------------------------------------------------------ */
.mod-mesures .nav-pills,
.mod-supplementaires .nav-pills {
  gap: 0.5rem;
}
.mod-mesures .nav-pills .nav-link,
.mod-supplementaires .nav-pills .nav-link {
  color: var(--bs-dark);
  background-color: var(--bs-primary-light);
}
.mod-mesures .nav-pills .nav-link.active,
.mod-supplementaires .nav-pills .nav-link.active {
  color: var(--bs-nav-pills-link-active-color);
  background-color: var(--bs-nav-pills-link-active-bg);
}

/* --- Scenario folder-tabs (supplementaires) ------------------
   Gold inactive tabs; the active tab is teal so it blends into
   the title banner below. Folder-tab shaping + active-state
   colouring of Shiny-generated tabs can't be utility classes.
   ------------------------------------------------------------ */
.mod-supplementaires .nav-tabs,
.mod-evaluation .nav-tabs {
  border-bottom: 0;
  gap: 0.25rem;
  padding: 0 1rem;
}
.mod-supplementaires .nav-tabs .nav-link,
.mod-evaluation .nav-tabs .nav-link {
  border: 0;
  border-radius: 0.5rem 0.5rem 0 0;
  color: var(--bs-dark);
  background-color: var(--bs-secondary);
}
.mod-supplementaires .nav-tabs .nav-link:hover,
.mod-evaluation .nav-tabs .nav-link:hover {
  color: var(--bs-dark);
}
.mod-supplementaires .nav-tabs .nav-link.active,
.mod-evaluation .nav-tabs .nav-link.active {
  color: var(--bs-dark);
  font-weight: 600;
  background-color: var(--bs-primary-light);
}

/* --- Tooltips ------------------------------------------------
   Maquette look: a pale-teal rounded pill with dark body text,
   instead of Bootstrap's default black box. Bootstrap 5.3 exposes
   the whole component through CSS variables, so setting them on
   `.tooltip` restyles every tooltip in the app (bs_tooltip() and
   the avatars alike) without touching the component's markup.
   Colours are theme tokens: `--bs-body-bg` is the maquette's
   "Body Background" (#d9e9e9), `--bs-body-color` its body text.
   The pill is fully opaque and carries a soft shadow so it stays
   readable over same-coloured surfaces.
   Two Bootstrap defaults are neutralised so the pill reads as a
   clean rounded shape:
     - the arrow is dropped (zeroed `--bs-tooltip-arrow-*` plus
       `display: none`), otherwise its triangle pokes out of one
       edge and eats the rounding of the nearest corner;
     - the theme shadow (`--bs-box-shadow`, offset 4px / blur
       7.5px) is replaced by a wider, softer one: on a wide pill
       the tight blur draws a hairline under the bottom edge that
       reads as a dotted rule.
   ------------------------------------------------------------ */
.tooltip {
  --bs-tooltip-bg: var(--bs-body-bg);
  --bs-tooltip-color: var(--bs-body-color);
  --bs-tooltip-opacity: 1;
  --bs-tooltip-border-radius: var(--bs-border-radius-lg);
  --bs-tooltip-padding-x: 1.25rem;
  --bs-tooltip-padding-y: 0.5rem;
  --bs-tooltip-font-size: 1rem;
  --bs-tooltip-max-width: 22rem;
  --bs-tooltip-arrow-width: 0;
  --bs-tooltip-arrow-height: 0;
}
.tooltip .tooltip-arrow {
  display: none;
}
.tooltip .tooltip-inner {
  border-radius: var(--bs-tooltip-border-radius);
  box-shadow: 0 0.25rem 1.25rem rgba(46, 46, 46, 0.18);
  font-weight: 500;
  text-align: center;
}

/* --- Design-system inline SVG icons -------------------------
   Icons injected by `ambre_icon()` (R/fct_icons.R). Inlined
   rather than <img> so they inherit the surrounding text
   colour: each SVG paints with `currentColor` (fill for the
   solid glyphs, stroke for the outline ones), which picks up
   `.text-primary`, `.btn-warning`, etc. We only size them here
   (do NOT force `fill`, or the stroke-based icons fill solid).
   Default size is 1em (matches text); `.ambre-icon-lg` is the
   larger glyph used in the choice cards on the start-up screen.
   ------------------------------------------------------------ */
.ambre-icon {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}
.ambre-icon svg {
  width: 1em;
  height: 1em;
}
.ambre-icon-lg svg {
  width: 3.25rem;
  height: 3.25rem;
}

/* --- Full-height start-up screen ----------------------------
   The main content column already stretches to the viewport
   (the app container is min-vh-100 with a flex-grow row). These
   rules carry that height down through the tabset wrapper to the
   "demarrage" step so its footer sits at the very bottom
   (mt-auto). Scoped with `>` to the MAIN tabset and to the
   demarrage pane, so the nested tabsets of other steps and the
   other (taller, scrolling) steps are left untouched.
   ------------------------------------------------------------ */
.ambre-main {
  min-height: 0;
}
/* Content cards default to the neutral (#f8f9f9) background, like the sidebar.
   Cards with an explicit bg-* utility (info panels, coloured step cards) keep
   their colour — the utility's !important beats the card variable. */
.ambre-main .card {
  --bs-card-bg: var(--bs-light);
}
.ambre-main > .bootstrict-tabset,
.ambre-main > .bootstrict-tabset > .tab-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.ambre-main .tab-pane[data-value="demarrage"].active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.ambre-main .tab-pane[data-value="demarrage"] > .vstack {
  flex: 1 1 auto;
}

/* --- Notifications (e.g. the "Calculer" success toast) -------
   Shiny stacks notifications bottom-right by default. Center the
   panel near the top, and give the success one (type = "message",
   the only message-type toast in the app) a green "success" look.
   ------------------------------------------------------------ */
#shiny-notification-panel {
  top: 1.5rem;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  width: auto;
  max-width: min(90vw, 34rem);
}
.shiny-notification-message {
  background-color: var(--bs-success-bg-subtle, #d1e7dd);
  color: var(--bs-success-text-emphasis, #0a3622);
  border: 1px solid var(--bs-success-border-subtle, #a3cfbb);
  font-weight: 600;
  text-align: center;
}

/* --- Result tables (the two regulation matrices) -------------
   They carry one column per selected pathogen, so they outgrow
   the cell holding them as soon as a few are selected — and the
   Évaluation, Comparaison and Situation initiale screens all show
   two of them side by side, i.e. in half a screen each. Scroll the
   cell rather than clip it: the table keeps its own width and can
   be read end to end, whatever the number of pathogens.
   The table itself must not be stretched to the cell (Bootstrap's
   `.table` is width: 100%), or the columns would be squeezed back
   into the cell instead of scrolling.
   ------------------------------------------------------------ */
.ambre-result-table {
  overflow-x: auto;
}
.ambre-result-table table {
  width: auto;
  min-width: 100%;
}