/*
 * Genworx Unified SSO — account console (post-login) styles.
 *
 * Keycloak 26's account console is a React + PatternFly 5 single-page app. We do not fork it: this
 * stylesheet re-maps PatternFly's design tokens onto the login theme's palette, so the two halves of
 * the product look like one product. Component-level variables that PatternFly computes from the
 * globals follow automatically; the handful that are baked to a literal colour are overridden below.
 *
 * Three schemes, same names and the same remembered choice as the login theme:
 *   Midnight (default) · Bright · White
 * Our selectors are :root[data-gx-scheme="…"], one step more specific than PatternFly's
 * html.pf-v5-theme-dark, so they win no matter which class the shell puts on <html>.
 */

/* ---- Fonts (self-hosted, SIL Open Font License — see ../fonts/OFL-*.txt) ---------------------- */
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/space-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/space-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }

/* ---- Scheme: Midnight (default) ----------------------------------------------------------------- */
:root {
  color-scheme: dark;
  --gx-bg: #061316;
  --gx-surface: #0a1e22;
  --gx-surface-2: #0b2125;
  --gx-rule: rgba(130, 200, 205, .18);
  --gx-text: #e8f1f2;
  --gx-muted: #a9c3c7;
  --gx-subtle: #7d989c;
  --gx-accent: #ec9132;
  --gx-accent-hover: #f29f48;
  --gx-accent-text: #1a0e02;
  --gx-link: #7fd3da;
  --gx-link-hover: #b5ecf0;
  --gx-focus: #4fc1c9;
  --gx-input: #071a1d;
  --gx-danger: #b42318;
  --gx-danger-hover: #96170f;

  /* PatternFly mappings */
  --pf-v5-global--FontFamily--text: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif;
  --pf-v5-global--FontFamily--heading: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif;
  --pf-v5-global--FontFamily--monospace: "IBM Plex Mono", ui-monospace, monospace;
  --pf-v5-global--BackgroundColor--100: var(--gx-bg);
  --pf-v5-global--BackgroundColor--200: var(--gx-surface);
  --pf-v5-global--BackgroundColor--300: var(--gx-surface-2);
  --pf-v5-global--BackgroundColor--400: var(--gx-surface-2);
  --pf-v5-global--BackgroundColor--150: var(--gx-surface);
  --pf-v5-global--BackgroundColor--dark-100: var(--gx-surface);
  --pf-v5-global--BackgroundColor--dark-200: var(--gx-surface);
  --pf-v5-global--BackgroundColor--dark-300: var(--gx-surface-2);
  /* dark-400 is what a selected vertical nav item resolves to; unmapped it stayed #4f5255 grey. */
  --pf-v5-global--BackgroundColor--dark-400: var(--gx-surface-2);
  --pf-v5-global--BackgroundColor--light-100: var(--gx-surface);
  --pf-v5-global--BackgroundColor--light-200: var(--gx-surface);
  --pf-v5-global--BackgroundColor--light-300: var(--gx-surface-2);
  --pf-v5-global--Color--100: var(--gx-text);
  --pf-v5-global--Color--200: var(--gx-muted);
  --pf-v5-global--Color--300: var(--gx-subtle);
  --pf-v5-global--primary-color--100: var(--gx-accent);
  --pf-v5-global--primary-color--200: var(--gx-accent-hover);
  --pf-v5-global--primary-color--300: var(--gx-accent-hover);
  --pf-v5-global--link--Color: var(--gx-link);
  --pf-v5-global--link--Color--hover: var(--gx-link-hover);
  --pf-v5-global--BorderColor--100: var(--gx-rule);
  --pf-v5-global--BorderColor--200: var(--gx-rule);
  --pf-v5-global--BorderColor--300: var(--gx-rule);
  --pf-v5-global--BorderColor--400: var(--gx-rule);
  /* These two are the light greys PatternFly uses for hairlines on dark surfaces (#d2d2d2/#b8bbbe),
     and they are what the nav, table and data-list borders actually resolve to. */
  --pf-v5-global--BorderColor--dark-100: var(--gx-rule);
  --pf-v5-global--BorderColor--light-100: var(--gx-rule);
  --pf-v5-global--Color--400: var(--gx-subtle);
  --pf-v5-global--Color--dark-100: var(--gx-text);
  --pf-v5-global--Color--dark-200: var(--gx-muted);
  --pf-v5-global--Color--light-100: var(--gx-text);
  --pf-v5-global--Color--light-200: var(--gx-muted);
  --pf-v5-global--danger-color--100: var(--gx-danger);
  --pf-v5-global--danger-color--200: var(--gx-danger-hover);
  --pf-v5-global--active-color--100: var(--gx-focus);

  /* Components PatternFly bakes to literals or to a variant we do not want */
  --pf-v5-c-masthead--BackgroundColor: var(--gx-surface);
  --pf-v5-c-masthead--m-light--BackgroundColor: var(--gx-surface);
  --pf-v5-c-page__sidebar--BackgroundColor: var(--gx-surface);
  --pf-v5-c-page__sidebar--m-light--BackgroundColor: var(--gx-surface);
  --pf-v5-c-page__main-section--BackgroundColor: var(--gx-bg);
  --pf-v5-c-page__main-section--m-light-100--BackgroundColor: var(--gx-bg);
  --pf-v5-c-nav__link--Color: var(--gx-muted);
  --pf-v5-c-nav__link--hover--Color: var(--gx-text);
  --pf-v5-c-nav__link--focus--Color: var(--gx-text);
  --pf-v5-c-nav__link--m-current--Color: var(--gx-text);
  --pf-v5-c-nav__link--m-current--BackgroundColor: var(--gx-surface-2);
  --pf-v5-c-nav__link--hover--BackgroundColor: var(--gx-surface-2);
  --pf-v5-c-button--m-primary--BackgroundColor: var(--gx-accent);
  --pf-v5-c-button--m-primary--hover--BackgroundColor: var(--gx-accent-hover);
  --pf-v5-c-button--m-primary--focus--BackgroundColor: var(--gx-accent-hover);
  --pf-v5-c-button--m-primary--active--BackgroundColor: var(--gx-accent-hover);
  --pf-v5-c-button--m-primary--Color: var(--gx-accent-text);
  --pf-v5-c-button--m-primary--hover--Color: var(--gx-accent-text);
  --pf-v5-c-button--m-primary--focus--Color: var(--gx-accent-text);
  --pf-v5-c-button--m-link--m-inline--hover--Color: var(--gx-link-hover);
  --pf-v5-c-chip--BackgroundColor: var(--gx-surface-2);
  --pf-v5-c-label--BackgroundColor: var(--gx-surface-2);
}

/* ---- Scheme: Bright ----------------------------------------------------------------------------- */
:root[data-gx-scheme="bright"] {
  color-scheme: dark;
  --gx-bg: #0c2b33;
  --gx-surface: #133a43;
  --gx-surface-2: #143c45;
  --gx-rule: rgba(160, 226, 232, .26);
  --gx-text: #f3fafb;
  --gx-muted: #bcd6d9;
  --gx-subtle: #93b4b8;
  --gx-accent: #f7a54e;
  --gx-accent-hover: #f9b468;
  --gx-accent-text: #1a0e02;
  --gx-link: #9aeaf0;
  --gx-link-hover: #d2f8fa;
  --gx-focus: #7fe0e8;
  --gx-input: #0e323b;
  --gx-danger: #b42318;
  --gx-danger-hover: #96170f;
}

/* ---- Scheme: White ------------------------------------------------------------------------------ */
:root[data-gx-scheme="white"] {
  color-scheme: light;
  --gx-bg: #f4f8f9;
  --gx-surface: #ffffff;
  --gx-surface-2: #eef4f5;
  --gx-rule: #dfe8ea;
  --gx-text: #0e2a2e;
  --gx-muted: #4f676b;
  --gx-subtle: #5c7478;
  --gx-accent: #ec9132;
  --gx-accent-hover: #e98523;
  --gx-accent-text: #1a0e02;
  --gx-link: #0e6e78;
  --gx-link-hover: #0a5259;
  --gx-focus: #1c9aa6;
  --gx-input: #f7fafa;
  --gx-danger: #b42318;
  --gx-danger-hover: #96170f;
}

/* ---- Page frame --------------------------------------------------------------------------------- */
html, body, #app { background: var(--gx-bg); color: var(--gx-text); }
body { font-family: var(--pf-v5-global--FontFamily--text); }

/* The shell's loading screen is inline-styled; keep it on-brand until the bundle paints. */
.keycloak__loading-container { background: var(--gx-bg) !important; color: var(--gx-muted) !important; }

/* Masthead: hide the SPA's logo <img> (its src is a relative path that 404s) and draw our wordmark
   from this theme's resources instead — the same approach as the account console. */
.pf-v5-c-masthead { border-bottom: 1px solid var(--gx-rule); box-shadow: none; }
.pf-v5-c-masthead__brand { display: flex; align-items: center; }
.keycloak__pageheader_brand { display: none; }
.pf-v5-c-masthead__brand::after {
  content: ""; display: block; width: 148px; height: 26px;
  background: url("../img/wordmark-dark.png") left center / contain no-repeat;
}
:root[data-gx-scheme="white"] .pf-v5-c-masthead__brand::after {
  background-image: url("../img/wordmark-light.png");
}

/* Sidebar + main content */
.pf-v5-c-page__sidebar,
.pf-v5-c-page__sidebar .pf-v5-c-page__sidebar-body { background-color: var(--gx-surface); border-right: 1px solid var(--gx-rule); }

/* Nav hairlines and the current-item marker (PatternFly draws them with pseudo-elements) */
.pf-v5-c-nav__item::before, .pf-v5-c-nav__item::after,
.pf-v5-c-nav__link::before, .pf-v5-c-nav__link::after,
.pf-v5-c-nav__section::before, .pf-v5-c-nav__section::after { border-color: var(--gx-rule); }
.pf-v5-c-nav__link.pf-m-current::after,
.pf-v5-c-nav__link.pf-m-current::before { border-color: var(--gx-accent); }
.pf-v5-c-nav__link:hover { background-color: var(--gx-surface-2); }

/* Secondary / tertiary buttons and menu toggles: hairline instead of PatternFly blue */
.pf-v5-c-button.pf-m-secondary::after,
.pf-v5-c-button.pf-m-tertiary::after { border-color: var(--gx-rule); }
.pf-v5-c-menu-toggle { border-color: var(--gx-rule); background-color: var(--gx-surface-2); color: var(--gx-text); }

/* Tables and lists */
.pf-v5-c-table, .pf-v5-c-table tr, .pf-v5-c-table td, .pf-v5-c-table th,
.pf-v5-c-table thead, .pf-v5-c-data-list__item, .pf-v5-c-data-list__item-row,
.pf-v5-c-data-list__item-content, .pf-v5-c-toolbar { border-color: var(--gx-rule); }
.pf-v5-c-table thead th { color: var(--gx-muted); }
.pf-v5-c-table tbody tr:hover { background-color: var(--gx-surface-2); }
.pf-v5-c-page__main-section { background: var(--gx-bg); }
.pf-v5-c-page__main-section.pf-m-light,
.pf-v5-c-page__main-section.pf-m-secondary { background: var(--gx-bg); }

/* Cards, panels and dividers */
.pf-v5-c-card, .pf-v5-c-panel, .pf-v5-c-data-list {
  background: var(--gx-surface);
  border-color: var(--gx-rule);
}
.pf-v5-c-card { border-radius: 14px; box-shadow: 0 18px 40px rgba(0, 0, 0, .18); }
.pf-v5-c-divider, .pf-v5-c-data-list__item { border-color: var(--gx-rule); }

/* Labels and chips (e.g. the domain chips on Organizations) — PatternFly fills these with a dark
   surface of their own, which stayed grey on the White scheme. */
.pf-v5-c-label, .pf-v5-c-label.pf-m-outline,
.pf-v5-c-chip, .pf-v5-c-chip.pf-m-overflow {
  background-color: var(--gx-surface-2);
  border-color: var(--gx-rule);
  color: var(--gx-text);
}
.pf-v5-c-label__content, .pf-v5-c-label__text,
.pf-v5-c-chip__content, .pf-v5-c-chip__text { color: var(--gx-text); }
.pf-v5-c-chip::before, .pf-v5-c-chip::after { border-color: var(--gx-rule); }

/* Type */
.pf-v5-c-title, .pf-v5-c-card__title-text, h1, h2, h3 { font-family: var(--pf-v5-global--FontFamily--heading); letter-spacing: -.01em; }
.pf-v5-c-form__label-text, .pf-v5-c-form__label { color: var(--gx-muted); }

/* Inputs */
.pf-v5-c-form-control {
  background-color: var(--gx-input);
  border-color: var(--gx-rule);
  color: var(--gx-text);
  border-radius: 10px;
}
.pf-v5-c-form-control::after, .pf-v5-c-form-control::before { border-color: var(--gx-rule); }
.pf-v5-c-form-control:focus-within,
.pf-v5-c-form-control:focus-within::after { border-color: var(--gx-focus); }
/* color-mix is Safari 16.2+/Chrome 111+; the plain rgba line is the fallback for older browsers
   (they simply keep the border change). */
.pf-v5-c-form-control:focus-within { box-shadow: 0 0 0 3px rgba(79, 193, 201, .25); }
.pf-v5-c-form-control:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--gx-focus) 25%, transparent); }
.pf-v5-c-form-control > input::placeholder { color: var(--gx-subtle); }

/* Buttons */
.pf-v5-c-button { border-radius: 10px; font-weight: 600; }
.pf-v5-c-button.pf-m-primary { color: var(--gx-accent-text); }
.pf-v5-c-button.pf-m-secondary { border-color: var(--gx-rule); color: var(--gx-text); }
.pf-v5-c-button.pf-m-link { color: var(--gx-link); }

/* Focus rings, everywhere */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--gx-focus);
  outline-offset: 2px;
}

/* ---- Colour-scheme switcher (mirrors the login theme's chip) ------------------------------------ */
.gx-account-switch {
  position: fixed; inset-block-end: 18px; inset-inline-start: 18px; z-index: 999;
  display: flex; align-items: center; gap: 6px;
  padding: 6px; border-radius: 999px;
  background: var(--gx-surface); border: 1px solid var(--gx-rule);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}
.gx-account-switch button {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 32px; padding: 0 12px; border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--gx-muted);
  font: inherit; font-size: 13px; cursor: pointer;
}
.gx-account-switch button:hover { color: var(--gx-text); }
.gx-account-switch button[aria-pressed="true"] {
  color: var(--gx-text); border-color: var(--gx-rule); background: var(--gx-surface-2);
}
.gx-account-switch .gx-swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--gx-rule); flex: none; }
.gx-swatch--midnight { background: linear-gradient(135deg, #061316 50%, #ec9132 50%); }
.gx-swatch--bright { background: linear-gradient(135deg, #1b5561 50%, #f7a54e 50%); }
.gx-swatch--white { background: linear-gradient(135deg, #f4f8f9 50%, #ec9132 50%); }
@media (max-width: 720px) {
  .gx-account-switch button span:not(.gx-swatch) { display: none; }
  .gx-account-switch button { padding: 0 9px; }
  /* Let the last field scroll clear of the floating switcher instead of sitting under it. */
  .pf-v5-c-page__main-section { padding-bottom: 88px; }
}

/* Windows High Contrast: keep boundaries visible */
@media (forced-colors: active) {
  .pf-v5-c-card, .pf-v5-c-form-control, .pf-v5-c-button, .gx-account-switch { border: 1px solid CanvasText; }
}
