@font-face {
  font-family: 'Formular';
  src: url('../fonts/formular-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Formular';
  src: url('../fonts/formular-medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Formular';
  src: url('../fonts/formular-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Keycloak can't load the web apps' stylesheets, so these copy the dark theme in
   apps/portal-web-ui/src/styles/globals.css by hand: bg is --background, fg
   --foreground, muted --muted-foreground, border --border, input --input,
   radius --radius (rounded-lg). input-bg is --input at 30%, as the portal's
   dark inputs and outline buttons render it. The status colours are the
   library's dark --success, --warning, --info and their --*-text shades. The
   shared source these should track once the portal theme is the library default
   is libs/web/components/src/styles/globals.css. */
:root {
  --enapi-bg: oklch(0.145 0 0);
  --enapi-fg: oklch(0.985 0 0);
  --enapi-muted: oklch(0.708 0 0);
  --enapi-primary: oklch(0.586 0.224 264.376);
  --enapi-primary-fg: oklch(0.97 0.014 254.604);
  --enapi-border: oklch(1 0 0 / 10%);
  --enapi-input: oklch(1 0 0 / 15%);
  --enapi-input-bg: oklch(1 0 0 / 4.5%);
  --enapi-radius: 0.625rem;
  --enapi-success: oklch(0.723 0.2 149.579);
  --enapi-success-text: oklch(0.78 0.17 149.579);
  --enapi-warning: oklch(0.828 0.168 84.429);
  --enapi-warning-text: oklch(0.85 0.149 84.429);
  --enapi-info: oklch(0.746 0.152 232.661);
  --enapi-info-text: oklch(0.79 0.128 232.661);
  --enapi-destructive-text: oklch(0.78 0.127 22.216);
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--enapi-bg) !important;
  color: var(--enapi-fg);
  font-family:
    'Formular',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Layout: centered single column (fits a popup window) ---- */
.pf-v5-c-login {
  min-height: 100vh;
  background: var(--enapi-bg) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  max-width: none !important;
}

.pf-v5-c-login__container {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 350px !important;
  margin: 0 auto !important;
  padding: 2rem 1.5rem !important;
}

.pf-v5-c-login__main,
.pf-v5-c-login__main-header,
.pf-v5-c-login__main-body,
.pf-v5-c-login__main-footer {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.pf-v5-c-login__main {
  display: grid;
  gap: 1.5rem;
  /* Fill the column; left to its content width, pages without a wide element
     (the one-time-code page) render narrower than the password page. */
  width: 100%;
}

/* ---- Header: replace realm name with logo ---- */
#kc-header {
  margin: 0 0 1.5rem 0 !important;
  padding: 0 !important;
  background: transparent !important;
}
#kc-header-wrapper,
#kc-header-wrapper.pf-v5-c-brand {
  display: block !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
  height: 1.5rem !important;
  width: 7rem !important;
  padding: 0 !important;
  margin: 0 !important;
  background-image: url('../img/enapi-logo.svg') !important;
  background-repeat: no-repeat !important;
  background-position: left center !important;
  background-size: contain !important;
}

/* ---- Title ---- */
#kc-page-title,
.pf-v5-c-title,
.pf-v5-c-title.pf-m-3xl {
  color: var(--enapi-fg) !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  margin: 0 0 0.5rem 0 !important;
  font-family: inherit !important;
}

/* ---- Labels ---- */
.pf-v5-c-form__label,
.pf-v5-c-form__label-text {
  color: var(--enapi-fg) !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
}

/* .pf-v5-c-form is a grid whose row gap already spaces the groups, so a per-group
   margin would stack on top of it — rely on the gap alone. */
.pf-v5-c-form {
  gap: 1rem !important;
}
.pf-v5-c-form__group {
  margin: 0 !important;
}
/* The identity-first template double-wraps the username group; flatten the wrapper
   so it doesn't consume its own gap row above the Sign-In button. */
.pf-v5-c-form__group:has(> .pf-v5-c-form__group) {
  display: contents !important;
}

/* The identity-first template also emits an empty form group before the button;
   hide childless groups so they add no gap row (:not(:has(*)) not :empty — the
   group holds whitespace). */
.pf-v5-c-form__group:not(:has(*)) {
  display: none !important;
}

/* ---- Inputs: PF v5 wraps <input> in a <span class="pf-v5-c-form-control"> ---- */
.pf-v5-c-form-control {
  position: relative;
  background: var(--enapi-input-bg) !important;
  border: 1px solid var(--enapi-input) !important;
  border-radius: var(--enapi-radius) !important;
  width: 100% !important;
  padding: 0 !important;
  box-shadow: none !important;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
/* Kill PF v5's underline pseudo-elements so only our border shows */
.pf-v5-c-form-control::before,
.pf-v5-c-form-control::after {
  display: none !important;
  border: none !important;
  background: none !important;
}
.pf-v5-c-form-control input,
.pf-v5-c-form-control input[type='text'],
.pf-v5-c-form-control input[type='email'],
.pf-v5-c-form-control input[type='password'] {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: var(--enapi-fg) !important;
  padding: 0.5rem 0.75rem !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  width: 100% !important;
  box-shadow: none !important;
}
/* Focus rings stay primary: the web apps' grey ring falls below 3:1 contrast. */
.pf-v5-c-form-control:focus-within {
  border-color: var(--enapi-primary) !important;
  box-shadow: 0 0 0 3px
    color-mix(in oklch, var(--enapi-primary) 25%, transparent) !important;
}
.pf-v5-c-form-control input::placeholder {
  color: var(--enapi-muted) !important;
}

/* Input group (password + eye toggle) — make eye button blend in */
.pf-v5-c-input-group {
  display: flex !important;
  gap: 0.5rem;
  align-items: stretch;
}
/* PF's separator between touching items; with our gap it shows as a stray line */
.pf-v5-c-input-group__item {
  border: none !important;
}
.pf-v5-c-input-group__item.pf-m-fill {
  flex: 1;
}
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 2.75rem;
  background: var(--enapi-input-bg) !important;
  border: 1px solid var(--enapi-input) !important;
  border-radius: var(--enapi-radius) !important;
  color: var(--enapi-muted) !important;
  padding: 0 0.75rem !important;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    color 0.15s ease;
}
/* PF's control-button frame is square and ignores our radius */
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control::before,
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control::after {
  display: none !important;
  content: none !important;
  border: none !important;
}
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control:hover {
  color: var(--enapi-fg) !important;
  border-color: var(--enapi-primary) !important;
}
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control:focus-visible {
  outline: none !important;
  border-color: var(--enapi-primary) !important;
  box-shadow: 0 0 0 3px
    color-mix(in oklch, var(--enapi-primary) 25%, transparent) !important;
}

/* The restart-login button already carries the label as its aria-label; the
   visible tooltip text would overflow the icon-sized button. */
.kc-login-tooltip .kc-tooltip-text {
  display: none !important;
}

/* ---- Second-factor choice list (select-authenticator) ---- */
.select-auth-container {
  display: grid !important;
  gap: 0.75rem;
  list-style: none;
  margin: 1.5rem 0 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
}
.select-auth-container > .pf-v5-c-data-list__item {
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
.select-auth-container > .pf-v5-c-data-list__item::before,
.select-auth-container > .pf-v5-c-data-list__item::after {
  display: none !important;
}
.select-auth-container .select-auth-box-parent {
  display: flex !important;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem !important;
  background: var(--enapi-input-bg) !important;
  border: 1px solid var(--enapi-border) !important;
  border-radius: var(--enapi-radius) !important;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.select-auth-container .select-auth-box-parent:hover {
  background: oklch(1 0 0 / 8%) !important;
}
.select-auth-container .select-auth-box-parent:focus-visible {
  outline: none;
  border-color: var(--enapi-primary) !important;
  box-shadow: 0 0 0 3px
    color-mix(in oklch, var(--enapi-primary) 25%, transparent) !important;
}
/* Icon beside the heading, description under the heading. */
.select-auth-container .pf-v5-c-data-list__item-content {
  display: grid !important;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.25rem;
  flex: 1;
  min-width: 0;
  padding: 0 !important;
  margin: 0 !important;
}
.select-auth-container .pf-v5-c-data-list__cell {
  padding: 0 !important;
  margin: 0 !important;
}
.select-auth-container .pf-v5-c-data-list__cell.pf-m-icon {
  grid-column: 1;
  grid-row: 1;
  justify-content: center;
  color: var(--enapi-muted);
  font-size: 1rem;
}
.select-auth-container .select-auth-box-headline {
  margin: 0 !important;
  color: var(--enapi-fg) !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  line-height: 1.3 !important;
}
.select-auth-container .select-auth-box-desc {
  grid-column: 2;
  color: var(--enapi-muted) !important;
  font-size: 0.8125rem !important;
  line-height: 1.4 !important;
}
.select-auth-container .pf-v5-c-data-list__item-action {
  display: flex !important;
  align-items: center;
  padding: 0 !important;
  margin: 0 !important;
  color: var(--enapi-muted);
}

/* ---- Primary submit button ---- */
.pf-v5-c-button.pf-m-primary,
.pf-v5-c-button.pf-m-block.pf-m-primary,
input[type='submit'].pf-v5-c-button {
  width: 100% !important;
  padding: 0.625rem 1rem !important;
  border: none !important;
  border-radius: var(--enapi-radius) !important;
  background: var(--enapi-primary) !important;
  color: var(--enapi-primary-fg) !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition: background 0.15s ease;
}
.pf-v5-c-button.pf-m-primary:hover,
input[type='submit'].pf-v5-c-button:hover {
  background: color-mix(
    in oklab,
    var(--enapi-primary) 80%,
    transparent
  ) !important;
}

/* ---- Account-linking choice buttons (first-broker-login "Account already exists") ----
   These are generic pf-m-block buttons with no primary/secondary modifier, so they fall
   back to PatternFly's grey block. Space the pair, and give the choices a visual hierarchy:
   "Add to existing account" as the primary accent action, "Review profile" as a neutral
   bordered button matching our inputs and social sign-in buttons. */
.pf-v5-c-form__group:has(> #updateProfile):has(> #linkAccount) {
  display: grid !important;
  gap: 0.75rem !important;
}
.pf-v5-c-button.pf-m-block#linkAccount {
  width: 100% !important;
  padding: 0.625rem 1rem !important;
  border: none !important;
  border-radius: var(--enapi-radius) !important;
  background: var(--enapi-primary) !important;
  color: var(--enapi-primary-fg) !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition: background 0.15s ease;
}
.pf-v5-c-button.pf-m-block#linkAccount:hover {
  background: color-mix(
    in oklab,
    var(--enapi-primary) 80%,
    transparent
  ) !important;
}
.pf-v5-c-button.pf-m-block#updateProfile {
  width: 100% !important;
  padding: 0.625rem 1rem !important;
  background: var(--enapi-input-bg) !important;
  border: 1px solid var(--enapi-input) !important;
  border-radius: var(--enapi-radius) !important;
  color: var(--enapi-fg) !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
.pf-v5-c-button.pf-m-block#updateProfile:hover {
  background: oklch(1 0 0 / 7.5%) !important;
}

/* ---- Links (Forgot password, Register, etc.) ---- */
.pf-v5-c-helper-text__item a,
#kc-info a,
#kc-registration a,
a.pf-v5-c-button.pf-m-link {
  color: var(--enapi-primary) !important;
  text-decoration: none;
  font-size: 0.875rem;
}
/* PF spaces the action row with negative outer and positive child margins; a
   plain gap keeps every button flush with the column. */
.pf-v5-c-form__actions {
  margin: 0 !important;
  gap: 0.75rem;
}
.pf-v5-c-form__actions > * {
  margin: 0 !important;
}
/* Secondary actions (back links under the submit button, "Try another way"):
   bordered buttons matching our inputs and the second-factor choice cards. */
.pf-v5-c-form__actions a.pf-v5-c-button.pf-m-link,
#try-another-way.pf-v5-c-button {
  display: block;
  width: 100% !important;
  margin: 0 !important;
  padding: 0.625rem 1rem !important;
  text-align: center;
  background: var(--enapi-input-bg) !important;
  border: 1px solid var(--enapi-input) !important;
  border-radius: var(--enapi-radius) !important;
  color: var(--enapi-fg) !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
.pf-v5-c-form__actions a.pf-v5-c-button.pf-m-link::after,
#try-another-way.pf-v5-c-button::after {
  display: none !important;
}
.pf-v5-c-form__actions a.pf-v5-c-button.pf-m-link:hover,
#try-another-way.pf-v5-c-button:hover {
  background: oklch(1 0 0 / 7.5%) !important;
}
.pf-v5-c-form__actions a.pf-v5-c-button.pf-m-link:focus-visible,
#try-another-way.pf-v5-c-button:focus-visible {
  outline: none;
  border-color: var(--enapi-primary) !important;
  box-shadow: 0 0 0 3px
    color-mix(in oklch, var(--enapi-primary) 25%, transparent) !important;
}

/* Error-page actions use the same blue primary and dark back button as the login form. */
#kc-error-message .enapi-error-actions {
  display: grid !important;
  gap: 0.75rem;
  margin-top: 1.5rem !important;
}
#kc-error-message .enapi-error-actions a.pf-m-primary:focus-visible {
  outline: 2px solid var(--enapi-fg);
  outline-offset: 3px;
}
#kc-select-try-another-way-form {
  margin-top: 0.75rem;
}
.pf-v5-c-helper-text__item a:hover,
#kc-info a:hover,
#kc-registration a:hover {
  text-decoration: underline;
}

/* ---- Helper / info area ---- */
#kc-info,
#kc-registration {
  text-align: center;
  margin-top: 1rem;
  color: var(--enapi-muted);
  font-size: 0.875rem;
}

/* ---- Alerts ---- */
.pf-v5-c-alert {
  border-radius: var(--enapi-radius) !important;
  background: oklch(1 0 0 / 5%) !important;
  border: 1px solid var(--enapi-border) !important;
  color: var(--enapi-fg) !important;
}
.pf-v5-c-alert.pf-m-danger {
  background: oklch(0.3 0.1 27 / 30%) !important;
  border-color: oklch(0.55 0.2 27 / 50%) !important;
}
/* PatternFly colours each status title and icon with a dark shade meant for a
   light background, which is unreadable on this one. */
.pf-v5-c-alert.pf-m-danger .pf-v5-c-alert__icon,
.pf-v5-c-alert.pf-m-danger .pf-v5-c-alert__title {
  color: var(--enapi-destructive-text) !important;
}
.pf-v5-c-alert.pf-m-success {
  background: color-mix(
    in oklch,
    var(--enapi-success) 20%,
    transparent
  ) !important;
  border-color: color-mix(
    in oklch,
    var(--enapi-success) 30%,
    transparent
  ) !important;
}
.pf-v5-c-alert.pf-m-success .pf-v5-c-alert__icon,
.pf-v5-c-alert.pf-m-success .pf-v5-c-alert__title {
  color: var(--enapi-success-text) !important;
}
.pf-v5-c-alert.pf-m-warning {
  background: color-mix(
    in oklch,
    var(--enapi-warning) 20%,
    transparent
  ) !important;
  border-color: color-mix(
    in oklch,
    var(--enapi-warning) 30%,
    transparent
  ) !important;
}
.pf-v5-c-alert.pf-m-warning .pf-v5-c-alert__icon,
.pf-v5-c-alert.pf-m-warning .pf-v5-c-alert__title {
  color: var(--enapi-warning-text) !important;
}
.pf-v5-c-alert.pf-m-info {
  background: color-mix(
    in oklch,
    var(--enapi-info) 20%,
    transparent
  ) !important;
  border-color: color-mix(
    in oklch,
    var(--enapi-info) 30%,
    transparent
  ) !important;
}
.pf-v5-c-alert.pf-m-info .pf-v5-c-alert__icon,
.pf-v5-c-alert.pf-m-info .pf-v5-c-alert__title {
  color: var(--enapi-info-text) !important;
}

/* ---- Create-password intro line (first-time setup only) ---- */
#kc-create-password-message {
  color: var(--enapi-muted) !important;
  font-size: 0.875rem !important;
  line-height: 1.4 !important;
  margin: 0 0 1rem 0 !important;
}

/* ---- Social identity-provider sign-in (Google, etc.) ---- */
.pf-v5-c-login__main-footer-band {
  margin-top: 0.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--enapi-border);
  text-align: center;
}
.pf-v5-c-login__main-footer-band-item {
  color: var(--enapi-muted) !important;
  font-size: 0.875rem !important;
}

#kc-social-providers ul {
  list-style: none;
  margin: 1rem 0 0 0 !important;
  padding: 0 !important;
}
#kc-social-providers li {
  margin: 0 0 0.75rem 0 !important;
  padding: 0 !important;
}

/* Override PatternFly's pf-m-secondary (blue outline) to match our dark inputs. */
#kc-social-providers .pf-v5-c-button.pf-m-secondary {
  position: relative;
  width: 100% !important;
  padding: 0.625rem 1rem !important;
  justify-content: center !important;
  background: var(--enapi-input-bg) !important;
  border: 1px solid var(--enapi-input) !important;
  border-radius: var(--enapi-radius) !important;
  color: var(--enapi-fg) !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
#kc-social-providers .pf-v5-c-button.pf-m-secondary:hover {
  background: oklch(1 0 0 / 7.5%) !important;
  border-color: var(--enapi-input) !important;
}

/* The parent theme emits the provider logo as an inline <svg> with no intrinsic
   size, so unconstrained it expands to fill the button. Cap it and pin it left. */
#kc-social-providers .pf-v5-c-button svg {
  position: absolute;
  left: 1rem;
  width: 1.25rem !important;
  height: 1.25rem !important;
  flex: none;
}

/* Parent applies m-auto to the label; neutralise it so justify-content centres it. */
#kc-social-providers .pf-v5-c-button .pf-v5-u-m-auto {
  margin: 0 !important;
}

/* ---- "Sign out from other devices" checkbox (reset only) ---- */
/* The base PatternFly checkbox label is muted/near-black — unreadable on our dark
   background; force the foreground colour and brand the checkbox accent. */
.enapi-logout-sessions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.enapi-logout-sessions input[type='checkbox'] {
  accent-color: var(--enapi-primary);
  width: 1rem;
  height: 1rem;
  margin: 0;
  cursor: pointer;
}
.enapi-logout-sessions label {
  color: var(--enapi-fg) !important;
  font-size: 0.875rem !important;
  font-weight: 400 !important;
  cursor: pointer;
}

/* ---- Password error placement ---- */
/* The parent macro emits "Forgot password?" before the error container. */
.pf-v5-c-form__group:has(> #input-error-container-password) {
  display: flex !important;
  flex-direction: column;
}
.pf-v5-c-form__group:has(> #input-error-container-password)
  > .pf-v5-c-form__helper-text {
  order: 1;
}

/* ---- Known email (login_hint) ---- */
/* The parent template's attempted-username box; scoped so the OTP and recovery-code steps keep it. */
body:has(#kc-login-identity) .pf-v5-c-form:has(#kc-attempted-username) {
  display: none !important;
}
#kc-login-identity .kc-login-identity-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
#kc-login-identity-email {
  flex: 1;
  min-width: 0;
  appearance: none;
  background: transparent !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  color: var(--enapi-fg) !important;
  font-family: inherit !important;
  font-size: 0.875rem !important;
  line-height: inherit;
  cursor: default;
  text-overflow: ellipsis;
}
#kc-login-identity-change {
  color: var(--enapi-primary) !important;
  font-size: 0.8125rem;
  text-decoration: none;
  white-space: nowrap;
}
#kc-login-identity-change:hover {
  text-decoration: underline;
}
