/*
 * Rezlient sign-in — restyles Keycloak's own login page to match the Fleet
 * Portal, so the hand-off from portal to identity system does not look like a
 * hand-off to a stranger.
 *
 * Colours are the portal's own (internal/portal/static/style.css): page
 * #f5f6fa, card white, header bar #1e2330, primary #2563eb.
 *
 * Restyling only. No Keycloak template is overridden anywhere in this theme,
 * so every screen this page can become — password, passkey, "Select login
 * method", Passkey Registration, every error — inherits the branding without
 * anyone having to remember to brand it.
 */

:root {
  --rez-bg: #f5f6fa;
  --rez-surface: #ffffff;
  --rez-border: #e2e6ea;
  --rez-header: #1e2330;
  --rez-header-border: #2d3548;
  --rez-text: #212529;
  --rez-text-muted: #5c636a;
  --rez-primary: #2563eb;
  --rez-primary-hover: #1d4ed8;
  --rez-danger: #dc2626;
}

/* ── The page ──────────────────────────────────────────────────────────────
   Keycloak ships a dark faceted photograph behind the card. Replace it with
   the portal's own flat background so the two products look like one. */
.pf-v5-c-background-image,
.pf-v5-c-background-image::before {
  background: var(--rez-bg) !important;
  background-image: none !important;
}

body,
.pf-v5-c-login,
.login-pf body {
  background: var(--rez-bg) !important;
  color: var(--rez-text);
}

/* ── The header: our logo, not the realm's name in capitals ────────────────
   Keycloak puts the realm display name here as text. On a client's fleet that
   is whatever the realm happens to be called, which is not a brand. The text
   is hidden and the logo takes its place — the logo is a background image so
   no template has to be overridden to insert an <img>. */
#kc-header,
.pf-v5-c-login__header {
  background: transparent !important;
  padding: 0 !important;
  /* PatternFly leaves a 48px gap under the header so its own logo floats above
     a separate card. Ours is the top of ONE card, so the gap has to go or the
     logo bar reads as an unrelated banner. */
  margin: 0 !important;
  width: 100% !important;
  max-width: none !important;
}

#kc-header-wrapper {
  /* Hide the realm name without removing it: screen readers still announce the
     page, and a realm whose logo fails to load is not left with a blank bar. */
  font-size: 0 !important;
  line-height: 0 !important;
  letter-spacing: 0 !important;
  color: transparent !important;
  margin: 0 !important;
  width: 100% !important;

  display: block;
  background-color: var(--rez-header) !important;
  background-image: url("../img/logo.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 240px auto;
  height: 132px;
  border: 1px solid var(--rez-header-border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 0 !important;
}

/* The master realm (and any realm whose displayNameHtml carries Keycloak's own
   .kc-logo-text block) paints the Keycloak logo as a BACKGROUND IMAGE on an
   inner div — the font-size:0 above hides text, not backgrounds, so the admin
   console's sign-in stacked Keycloak's logo on top of ours (seen live
   2026-08-25). Remove the image and collapse the box; the span inside is
   already display:none in the parent stylesheet. */
#kc-header-wrapper .kc-logo-text {
  background-image: none !important;
  height: 0 !important;
  width: 0 !important;
}

/* ── The card ─────────────────────────────────────────────────────────────── */
.pf-v5-c-login__main {
  padding: 0.5rem 0 1.5rem !important;
  background: var(--rez-surface) !important;
  border: 1px solid var(--rez-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  max-width: 480px;
  width: 100%;
}

/* PatternFly lays the login out as a grid sized for its own two-column
   marketing page, which squeezes our single card to ~280px and wraps the page
   title onto three lines. Collapse it to one block column at the card's width
   and let every child fill it. */
.pf-v5-c-login__container {
  display: block !important;
  width: min(480px, 100%) !important;
  max-width: 480px !important;
  margin: 0 auto !important;
  grid-template-columns: none !important;
  gap: 0 !important;
  /* PatternFly pads this container by 98px a side, which is what actually
     squeezed the form to ~186px and wrapped "Sign in to your account" onto
     three lines. The card supplies its own padding. */
  padding: 0 !important;
}

/* Card padding, replacing the parent's 48px-a-side inset. */
.pf-v5-c-login__main-header,
.pf-v5-c-login__main-body,
.pf-v5-c-login__main-footer {
  padding-left: 2rem !important;
  padding-right: 2rem !important;
}

.pf-v5-c-login__main-header {
  padding-top: 1.75rem !important;
  /* PatternFly lays this header out as a two-column grid (page title beside a
     language selector). With no language selector the title column is still
     only ~290px, which wraps "Sign in to your account" onto two lines inside
     our 480px card. One block column lets the title use the card's full width.
     Same class of trap as the container's 98px padding — see the README. */
  display: block !important;
}

.pf-v5-c-login__main-body {
  padding-bottom: 1.75rem !important;
}

.pf-v5-c-login__main,
.pf-v5-c-login__header,
.pf-v5-c-login__main-header,
.pf-v5-c-login__main-body,
.pf-v5-c-login__main-footer,
#kc-form,
#kc-form-wrapper,
#kc-content,
#kc-content-wrapper {
  width: 100% !important;
  max-width: none !important;
}

.pf-v5-c-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.pf-v5-c-login__main-header-desc,
.pf-v5-c-login__main-body,
.pf-v5-c-login__main-header {
  color: var(--rez-text);
}

#kc-page-title {
  color: var(--rez-text);
  font-weight: 600;
}

/* ── Fields ───────────────────────────────────────────────────────────────── */
.pf-v5-c-form-control,
.pf-v5-c-form-control input {
  background: var(--rez-surface) !important;
  color: var(--rez-text) !important;
  border-color: var(--rez-border) !important;
}

.pf-v5-c-form-control:focus-within {
  border-color: var(--rez-primary) !important;
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15) !important;
}

.pf-v5-c-form__label-text,
.pf-v5-c-form__label {
  color: var(--rez-text) !important;
  font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.pf-v5-c-button.pf-m-primary {
  background: var(--rez-primary) !important;
  border-color: var(--rez-primary) !important;
  color: #ffffff !important;
  font-weight: 600;
  border-radius: 6px;
}

.pf-v5-c-button.pf-m-primary:hover,
.pf-v5-c-button.pf-m-primary:focus {
  background: var(--rez-primary-hover) !important;
  border-color: var(--rez-primary-hover) !important;
}

/* "Try Another Way" and friends — the way to the passkey. It must read as a
   real, pressable control, not as fine print; on the default dark theme over a
   light card it can end up nearly invisible. */
.pf-v5-c-button.pf-m-secondary,
.pf-v5-c-button.pf-m-link {
  color: var(--rez-primary) !important;
  border-color: var(--rez-primary) !important;
  border-radius: 6px;
  font-weight: 600;
}

.pf-v5-c-button.pf-m-link:hover {
  color: var(--rez-primary-hover) !important;
}

a,
a:visited {
  color: var(--rez-primary);
}

/* ── The credential chooser ("Select login method") ────────────────────────
   This is where an operator picks Passkey, so its rows must look selectable. */
.pf-v5-c-login__main-body .select-auth-box-parent,
.select-auth-box-parent {
  background: var(--rez-surface) !important;
  border-color: var(--rez-border) !important;
  color: var(--rez-text) !important;
}

.select-auth-box-parent:hover {
  background: #f8fafc !important;
  border-color: var(--rez-primary) !important;
  cursor: pointer;
}

.select-auth-box-headline,
.select-auth-box-desc,
.select-auth-box-paragraph {
  color: var(--rez-text) !important;
}

.select-auth-box-desc,
.select-auth-box-paragraph {
  color: var(--rez-text-muted) !important;
}

.select-auth-box-icon,
.select-auth-box-icon-properties {
  color: var(--rez-primary) !important;
  fill: var(--rez-primary) !important;
}

/* ── Messages ─────────────────────────────────────────────────────────────── */
.pf-v5-c-alert.pf-m-danger,
.pf-v5-c-alert.pf-m-error,
#input-error,
.kc-feedback-text {
  color: var(--rez-danger) !important;
}

.pf-v5-c-helper-text__item-text {
  color: var(--rez-text-muted);
}

/* ── Small screens ────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  #kc-header-wrapper {
    height: 104px;
    background-size: 190px auto;
  }
}
