/* =============================================================================
   KBM.Blazor.UI.MudBlazor: brand rules MudBlazor's theme cannot express.
   Load after MudBlazor.min.css and _content/KBM.Blazor.UI/css/kbm.css:
     <link href="_content/KBM.Blazor.UI.MudBlazor/css/kbm-mudblazor.css" rel="stylesheet" />
   Colors only via custom properties (no hex values): the light/dark palette comes from KbmTheme.
   ============================================================================= */

/* ---- Semantic roles of kbm.css follow the active MudBlazor palette (light/dark) ----
   :root:root wins over kbm.css' :root regardless of link order. */
:root:root {
  --kbm-text: var(--mud-palette-text-primary);
  --kbm-text-secondary: var(--mud-palette-text-secondary);
  --kbm-accent: var(--mud-palette-primary);
  --kbm-on-accent: var(--mud-palette-primary-text);
  --kbm-ground: var(--mud-palette-background);
  --kbm-panel: var(--mud-palette-background-gray);
  --kbm-line: var(--mud-palette-lines-default);
  /* --kbm-brand-surface stays KBM-Blau in both modes (app bar, table header) */
}

/* ---- Typography: what MudBlazor's Typography has no property for ---------------- */
.mud-typography-h6,
.mud-typography-caption {
  font-style: italic;
}

.mud-typography-h1,
.mud-typography-h2,
.mud-typography-overline {
  color: var(--mud-palette-primary);
}

.mud-typography-subtitle1,
.mud-typography-caption {
  color: var(--mud-palette-text-secondary);
}

/* On colored surfaces typography inherits the surface's text color */
:is(.mud-appbar, .mud-alert-filled, .mud-snackbar, .mud-tooltip, .mud-chip, .mud-button-root, .mud-table-head) .mud-typography {
  color: inherit;
}

/* ---- Alerts: no colored body text (Text/Outlined variants use *-darken as text in MudBlazor) ---- */
.mud-alert-text-primary, .mud-alert-outlined-primary,
.mud-alert-text-secondary, .mud-alert-outlined-secondary,
.mud-alert-text-tertiary, .mud-alert-outlined-tertiary,
.mud-alert-text-info, .mud-alert-outlined-info,
.mud-alert-text-success, .mud-alert-outlined-success,
.mud-alert-text-warning, .mud-alert-outlined-warning,
.mud-alert-text-error, .mud-alert-outlined-error,
.mud-alert-text-dark, .mud-alert-outlined-dark {
  color: var(--mud-palette-text-primary);
}

/* ---- Form fields ------------------------------------------------------------------
   MudBlazor sizes the input line for Roboto (1.1876em). Open Sans' descenders (g, p, q, y) reach lower and get
   clipped, so the line gets 1.4375em; the vertical padding shrinks by the same 4 px to keep every field's height. */
.mud-input {
  line-height: 1.4375em;
}

.mud-input > input.mud-input-root,
div.mud-input-slot.mud-input-root {
  padding: 4px 0 5px;
}

.mud-input > input.mud-input-root.mud-input-root-margin-dense,
div.mud-input-slot.mud-input-root.mud-input-root-margin-dense {
  padding-top: 1px;
}

.mud-input > input.mud-input-root.mud-input-root-filled,
div.mud-input-slot.mud-input-root.mud-input-root-filled {
  padding: 25px 12px 8px;
}

.mud-input > input.mud-input-root.mud-input-root-filled.mud-input-root-margin-dense,
div.mud-input-slot.mud-input-root.mud-input-root-filled.mud-input-root-margin-dense {
  padding-top: 21px;
  padding-bottom: 4px;
}

.mud-input > input.mud-input-root.mud-input-root-filled.mud-input-root-hidden-label,
div.mud-input-slot.mud-input-root.mud-input-root-filled.mud-input-root-hidden-label {
  padding-top: 16px;
  padding-bottom: 17px;
}

.mud-input > input.mud-input-root.mud-input-root-filled.mud-input-root-hidden-label.mud-input-root-margin-dense,
div.mud-input-slot.mud-input-root.mud-input-root-filled.mud-input-root-hidden-label.mud-input-root-margin-dense {
  padding-top: 8px;
  padding-bottom: 9px;
}

.mud-input > input.mud-input-root-outlined,
div.mud-input-slot.mud-input-root-outlined {
  padding: 16.5px 14px;
}

.mud-input > input.mud-input-root-outlined.mud-input-root-margin-dense,
div.mud-input-slot.mud-input-root-outlined.mud-input-root-margin-dense {
  padding-top: 8.5px;
  padding-bottom: 8.5px;
}

/* Labels use the input's own type (Body1) instead of Subtitle1 (1.125rem in KBM). Shrunk to 75 % they then match the
   0.75rem legend that cuts the notch into the outlined border, so the label no longer runs into the border. */
.mud-input-control > .mud-input-control-input-container > .mud-input-label-inputcontrol {
  font-family: var(--mud-typography-body1-family);
  font-size: var(--mud-typography-body1-size);
  font-weight: var(--mud-typography-body1-weight);
  letter-spacing: var(--mud-typography-body1-letterspacing);
}

/* The required label gets its "*" via ::after; the legend needs it too, or the notch is one character short */
.mud-input-control.mud-input-required .mud-input-outlined-border legend::after {
  content: "*";
}

/* ---- Navigation: Montserrat in the Button size (web type scale "Navigation / actions") ----
   MudNavLink inherits Body1 (1rem × 1.75 = 28 px line) and top-aligns its 24 px icon, so the text sat low.
   0.875rem × 1.75 gives a 24.5 px line, level with the icon. Weights stay MudBlazor's (400, active 500). */
.mud-nav-link {
  font-family: var(--mud-typography-button-family);
  font-size: var(--mud-typography-button-size);
  line-height: var(--mud-typography-button-lineheight);
}

.mud-nav-link .mud-nav-link-text {
  letter-spacing: var(--mud-typography-button-letterspacing);
}

/* MudTab: same style instead of MudBlazor's forced caps in the inherited Body1 font. Caps are reserved for the small
   tracked labels (overline, KPI label, table header). Weight stays MudBlazor's 500. */
.mud-tab {
  font-family: var(--mud-typography-button-family);
  font-size: var(--mud-typography-button-size);
  line-height: var(--mud-typography-button-lineheight);
  letter-spacing: var(--mud-typography-button-letterspacing);
  text-transform: var(--mud-typography-button-text-transform);
}

/* ---- Tables: header row KBM-Blau with white Open Sans Bold caps (+0.15em) in both modes ---- */
.mud-table .mud-table-root .mud-table-head .mud-table-cell,
.mud-simple-table.mud-simple-table table thead th {
  background-color: var(--kbm-brand-surface);
  color: var(--kbm-on-brand-surface);
  font-family: var(--kbm-font-body);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.mud-table-head :is(.mud-icon-button, .mud-table-sort-label, .mud-button-root) {
  color: inherit;
}

/* ---- KbmLayout ---------------------------------------------------------------------- */
/* Clear space ½ X (X = logo height, 32 px at the default 160 px width) */
.kbm-layout-home {
  display: flex;
  align-items: center;
  margin-inline: 16px;
}

/* With a drawer the logo heads the drawer: 16 px on all sides, left edge level with the nav link icons */
.kbm-layout-drawer-home {
  flex: none;
  align-self: flex-start;
  margin: 0;
  padding: 16px;
}

/* The title keeps showing on phones and is shortened with an ellipsis instead */
.kbm-layout-title {
  min-width: 0;
  font-family: var(--kbm-font-heading);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kbm-layout-menu-button + .kbm-layout-title {
  margin-inline-start: 12px;
}

.kbm-layout-content {
  padding-block: 2rem;
}

/* A link to a heading in the content (e.g. a section of a guide) scrolls it to just below the 64 px app bar */
.kbm-layout-main :is(h1, h2, h3, h4, h5, h6)[id] {
  scroll-margin-top: 80px;
}

/* ---- KbmLanguageSelector ----------------------------------------------------------- */
.kbm-language {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* 4:3 flag, 1px line so white flag parts (CH, FR, IT) stay visible on white and dark menus */
.kbm-flag {
  flex: none;
  width: 1.333em;
  height: 1em;
  outline: 1px solid var(--kbm-line);
}

.kbm-language-current {
  color: var(--kbm-accent);
}

/* ---- KbmSettingsMenu: overline headings, a hairline between the sections ------------ */
.kbm-settings-list {
  min-width: 240px;
}

.kbm-settings-heading.mud-typography {
  display: block;
  padding: 8px 16px 2px;
}

.kbm-settings-heading.mud-typography:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid var(--kbm-line);
}

.kbm-settings-divider {
  margin-block: 4px;
}

.kbm-settings-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.kbm-settings-label {
  flex: 1 1 auto;
}

/* The on/off switch is drawn as an icon: the whole entry is the control (menuitemcheckbox) */
.kbm-settings-toggle.mud-icon-root {
  font-size: 2rem;
  margin-block: -6px;
}

/* ---- Components -------------------------------------------------------------------- */
.kbm-info-box-icon {
  color: var(--kbm-accent);
}

/* ---- KbmPageHelp: a Hinweisbox whose header row opens and closes it ------------------ */
.kbm-page-help.kbm-info-box {
  padding: 0;
  margin-bottom: 1rem;
}

.kbm-page-help-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.kbm-page-help-header:focus-visible {
  outline: 2px solid var(--kbm-accent);
  outline-offset: -2px;
}

/* Montserrat like the title of a Hinweisbox, in the body size so the collapsed box stays one slim row */
.kbm-page-help-title {
  flex-grow: 1;
  font-family: var(--kbm-font-heading);
  font-weight: 600;
}

/* Aligned with the title, after the icon */
.kbm-page-help-body {
  padding: 0 12px 12px 40px;
}

.kbm-page-help-body ul {
  margin: 6px 0 0;
  font-size: 0.875rem;
  line-height: 1.43;
}

.kbm-page-help-body li + li {
  margin-top: 2px;
}

.kbm-page-help-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 8px;
  font-size: 0.875rem;
}

@media (max-width: 599.98px) {
  .kbm-page-help-body {
    padding-left: 12px;
  }
}

/* ---- KbmHelpTip ---------------------------------------------------------------------- */
.kbm-help-tip-root {
  vertical-align: middle;
}

.kbm-help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 2px;
  padding: 2px;
  border: none;
  background: none;
  color: inherit;
  cursor: help;
}

.kbm-help-tip:focus-visible {
  outline: 2px solid var(--kbm-accent);
}

/* MudBlazor sets "max-width: none" inline when it positions the popover, so the limit needs !important.
   KbmHelpTip measures the room where the tip opens and passes it as --kbm-help-tip-max-width. */
.kbm-help-tip-popover {
  max-width: min(var(--kbm-help-tip-max-width, 320px), calc(100vw - 32px)) !important;
  text-align: left;
  white-space: normal;
}

/* A field with a "?" after it: <div class="kbm-field-with-tip"><MudTextField … /><KbmHelpTip … /></div>.
   The "?" sits on the input line, not in the middle of the field and its helper text. */
.kbm-field-with-tip {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

.kbm-field-with-tip > :first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.kbm-field-with-tip > .kbm-help-tip-root {
  margin-top: 10px;
}
