/*
 * ATF look for Keycloak's v2 login pages. The layout (template.ftl) is the console's sign-in card; this file gives it and
 * Keycloak's form controls the console's shadcn "Lyra" styling: tokens from atf-ui packages/ui/src/styles/globals.css,
 * sizes and spacing from the shadcn components the console uses (Card, Input, Button, Badge, Alert, Checkbox).
 * Light by default; dark follows the operating system (Keycloak adds .pf-v5-theme-dark). Keep it in step with the console.
 */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --atf-background: oklch(1 0 0);
  --atf-foreground: oklch(0.145 0 0);
  --atf-card: oklch(1 0 0);
  --atf-primary: oklch(0.205 0 0);
  --atf-primary-foreground: oklch(0.985 0 0);
  --atf-muted: oklch(0.97 0 0);
  --atf-muted-foreground: oklch(0.45 0 0);
  --atf-border: oklch(0.922 0 0);
  --atf-input: oklch(0.922 0 0);
  --atf-ring: oklch(0.708 0 0);
  --atf-destructive: oklch(0.577 0.245 27.325);
  --atf-loss-bg: oklch(0.96 0.03 25);
  --atf-warn: oklch(0.48 0.12 70);
  --atf-warn-bg: oklch(0.96 0.06 90);
  --atf-gain: oklch(0.45 0.14 150);
  --atf-gain-bg: oklch(0.96 0.04 150);
  --atf-info: oklch(0.45 0.15 255);
  --atf-info-bg: oklch(0.96 0.02 255);
  --atf-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --atf-font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.pf-v5-theme-dark {
  --atf-background: oklch(0.145 0 0);
  --atf-foreground: oklch(0.985 0 0);
  --atf-card: oklch(0.205 0 0);
  --atf-primary: oklch(0.922 0 0);
  --atf-primary-foreground: oklch(0.205 0 0);
  --atf-muted: oklch(0.269 0 0);
  --atf-muted-foreground: oklch(0.708 0 0);
  --atf-border: oklch(1 0 0 / 10%);
  --atf-input: oklch(1 0 0 / 15%);
  --atf-ring: oklch(0.556 0 0);
  --atf-destructive: oklch(0.704 0.191 22.216);
  --atf-loss-bg: oklch(0.3 0.09 25 / 0.5);
  --atf-warn: oklch(0.8 0.14 85);
  --atf-warn-bg: oklch(0.3 0.07 85 / 0.5);
  --atf-gain: oklch(0.78 0.17 150);
  --atf-gain-bg: oklch(0.3 0.07 150 / 0.5);
  --atf-info: oklch(0.75 0.13 255);
  --atf-info-bg: oklch(0.3 0.07 255 / 0.5);
}

/* ---- Page and card: app/(auth)/login/page.tsx ---------------------------------------------------------------------- */
html.login-pf, body.atf-page {
  background: var(--atf-background) !important;
  color: var(--atf-foreground);
  font-family: var(--atf-font);
  -webkit-font-smoothing: antialiased;
}
/* PatternFly's own fonts and corners inside the forms */
.atf-page {
  --pf-v5-global--FontFamily--text: var(--atf-font);
  --pf-v5-global--FontFamily--heading: var(--atf-font);
  --pf-v5-global--BorderRadius--sm: 0;
  --pf-v5-global--BorderRadius--lg: 0;
  --pf-v5-global--Color--100: var(--atf-foreground);
  --pf-v5-global--Color--200: var(--atf-muted-foreground);
  --pf-v5-global--BackgroundColor--100: var(--atf-card);
  --pf-v5-global--link--Color: var(--atf-foreground);
  --pf-v5-global--link--Color--hover: var(--atf-foreground);
  --pf-v5-global--danger-color--100: var(--atf-destructive);
}
/* flex min-h-screen w-screen items-center justify-center p-4 */
.atf-shell {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
/* Card: w-full max-w-sm rounded-none border bg-card shadow-2xl ring-1 ring-foreground/10 */
.atf-card {
  width: 100%;
  max-width: 24rem;
  background: var(--atf-card);
  color: var(--atf-foreground);
  border: 1px solid var(--atf-border);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25), 0 0 0 1px color-mix(in oklch, var(--atf-foreground) 10%, transparent);
}
/* CardHeader: border-b px-6 py-5, logo size-8 bg-primary, gap-3.5 */
.atf-card-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--atf-border);
}
.atf-logo {
  display: flex;
  width: 2rem;
  height: 2rem;
  flex: none;
  align-items: center;
  justify-content: center;
  background: var(--atf-primary);
  color: var(--atf-primary-foreground);
}
/* CardTitle: font-mono text-base font-bold tracking-tight uppercase */
.atf-card-title {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-transform: uppercase;
}
/* CardDescription: mt-0.5 font-mono text-xs text-muted-foreground */
.atf-card-description {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--atf-muted-foreground);
}
/* CardContent: p-6 */
.atf-card-content {
  padding: 1.5rem;
}
.atf-page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.atf-page-title {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  color: var(--atf-foreground);
}
/* CardFooter: border-t bg-muted/20 px-6 py-3, the protocol label and an outline badge */
.atf-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--atf-border);
  background: color-mix(in oklch, var(--atf-muted) 20%, transparent);
}
.atf-footer-label {
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--atf-muted-foreground);
}
/* Badge variant=outline: px-1.5 py-0 text-[11px] */
.atf-badge {
  padding: 0 0.375rem;
  border: 1px solid var(--atf-border);
  font-size: 0.6875rem;
  line-height: 1.125rem;
  text-transform: uppercase;
  color: var(--atf-muted-foreground);
}
.atf-login-footer:empty {
  display: none;
}

/* ---- Forms: space-y-4 between fields, space-y-1.5 between label and input ----------------------------------------- */
.atf-card-body .pf-v5-c-form,
.atf-card-body form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.atf-card-body .pf-v5-c-form__group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin: 0;
}
.atf-card-body .pf-v5-c-form__group-label {
  padding: 0 !important;
}
/* Label: block text-[11px] font-semibold tracking-widest text-muted-foreground uppercase */
.atf-card-body .pf-v5-c-form__label,
.atf-card-body .pf-v5-c-form__label-text {
  font-size: 0.6875rem;
  line-height: 1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--atf-muted-foreground);
}
.pf-v5-c-form__label-required, .required {
  color: var(--atf-destructive);
}
.atf-card-body .subtitle, .atf-card-body .pf-v5-c-helper-text__item-text {
  font-size: 0.75rem;
  color: var(--atf-muted-foreground);
}

/* Input: h-10 rounded-none border border-input bg-transparent px-3 font-mono text-sm; dark:bg-input/30;
   focus-visible: border-ring ring-[3px] ring-ring/50; aria-invalid: border-destructive ring-destructive/20 */
.atf-card-body .pf-v5-c-form-control {
  --pf-v5-c-form-control--BorderRadius: 0;
  --pf-v5-c-form-control--before--BorderColor: transparent;
  --pf-v5-c-form-control--after--BorderColor: transparent;
  --pf-v5-c-form-control--BackgroundColor: transparent;
  min-height: 2.5rem;
  border: 1px solid var(--atf-input);
  background: transparent;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: color 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.pf-v5-theme-dark .atf-card-body .pf-v5-c-form-control {
  background: color-mix(in oklch, var(--atf-input) 30%, transparent);
}
.atf-card-body .pf-v5-c-form-control::before,
.atf-card-body .pf-v5-c-form-control::after {
  display: none;
}
.atf-card-body .pf-v5-c-form-control > input,
.atf-card-body .pf-v5-c-form-control > select {
  height: 2.5rem;
  padding: 0 0.75rem;
  font-family: var(--atf-font);
  font-size: 0.875rem;
  color: var(--atf-foreground);
  background: transparent;
  outline: none;
}
.atf-card-body .pf-v5-c-form-control > input::placeholder {
  color: var(--atf-muted-foreground);
}
.atf-card-body .pf-v5-c-form-control:focus-within {
  border-color: var(--atf-ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--atf-ring) 50%, transparent);
}
.atf-card-body .pf-v5-c-form-control.pf-m-error {
  border-color: var(--atf-destructive);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--atf-destructive) 20%, transparent);
}
.atf-card-body .pf-v5-c-form-control__utilities {
  display: none;
}
/* Field errors only; an alert's text takes its alert's colour */
.atf-card-body .pf-v5-c-helper-text__item.pf-m-error,
.atf-card-body .pf-v5-c-helper-text__item-text.pf-m-error {
  font-size: 0.75rem;
  color: var(--atf-destructive);
}
.atf-card-body .pf-v5-c-alert .kc-feedback-text {
  color: var(--pf-v5-c-alert__title--Color, var(--atf-foreground));
  font-weight: 500;
}
/* Autofill keeps the input's own colours */
.atf-card-body input:-webkit-autofill,
.atf-card-body input:-webkit-autofill:hover,
.atf-card-body input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--atf-foreground);
  -webkit-box-shadow: 0 0 0 1000px var(--atf-card) inset;
  caret-color: var(--atf-foreground);
  transition: background-color 9999s;
}
/* Password with the show button inside: relative input, ghost icon-sm button at the right (login-form.tsx) */
.atf-card-body .pf-v5-c-input-group {
  position: relative;
  display: block;
}
.atf-card-body .pf-v5-c-input-group > .pf-v5-c-input-group__item:not(.pf-m-fill) {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  transform: translateY(-50%);
}
.atf-card-body .pf-v5-c-input-group .pf-v5-c-form-control > input {
  padding-right: 2.5rem;
}
.atf-card-body .pf-v5-c-button.pf-m-control {
  --pf-v5-c-button--m-control--BackgroundColor: transparent;
  --pf-v5-c-button--m-control--after--BorderColor: transparent;
  --pf-v5-c-button--m-control--hover--BackgroundColor: var(--atf-muted);
  --pf-v5-c-button--m-control--Color: var(--atf-muted-foreground);
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 0;
}
.atf-card-body .pf-v5-c-button.pf-m-control::after {
  display: none;
}

/* ---- Buttons ---------------------------------------------------------------------------------------------------- */
/* Button (default): h-10 w-full rounded-none font-mono text-xs font-bold tracking-wider uppercase bg-primary */
.atf-card-body .pf-v5-c-button {
  --pf-v5-c-button--BorderRadius: 0;
  font-family: var(--atf-font);
}
.atf-card-body .pf-v5-c-button.pf-m-primary,
.atf-card-body .pf-v5-c-button.pf-m-secondary {
  display: inline-flex;
  width: 100%;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none !important;
  transition: background-color 0.15s, border-color 0.15s;
}
.atf-card-body .pf-v5-c-button.pf-m-primary {
  --pf-v5-c-button--m-primary--BackgroundColor: var(--atf-primary);
  --pf-v5-c-button--m-primary--hover--BackgroundColor: color-mix(in oklch, var(--atf-primary) 90%, transparent);
  --pf-v5-c-button--m-primary--focus--BackgroundColor: color-mix(in oklch, var(--atf-primary) 90%, transparent);
  --pf-v5-c-button--m-primary--active--BackgroundColor: color-mix(in oklch, var(--atf-primary) 90%, transparent);
  --pf-v5-c-button--m-primary--Color: var(--atf-primary-foreground);
  --pf-v5-c-button--m-primary--hover--Color: var(--atf-primary-foreground);
  --pf-v5-c-button--m-primary--focus--Color: var(--atf-primary-foreground);
  --pf-v5-c-button--m-primary--active--Color: var(--atf-primary-foreground);
}
/* Button variant=outline: border bg-background hover:bg-accent; dark:border-input dark:bg-input/30 */
.atf-card-body .pf-v5-c-button.pf-m-secondary {
  --pf-v5-c-button--m-secondary--Color: var(--atf-foreground);
  --pf-v5-c-button--m-secondary--hover--Color: var(--atf-foreground);
  --pf-v5-c-button--m-secondary--focus--Color: var(--atf-foreground);
  --pf-v5-c-button--m-secondary--BackgroundColor: var(--atf-background);
  --pf-v5-c-button--m-secondary--hover--BackgroundColor: var(--atf-muted);
  --pf-v5-c-button--m-secondary--focus--BackgroundColor: var(--atf-muted);
  --pf-v5-c-button--m-secondary--after--BorderColor: var(--atf-border);
  --pf-v5-c-button--m-secondary--hover--after--BorderColor: var(--atf-border);
  --pf-v5-c-button--m-secondary--focus--after--BorderColor: var(--atf-border);
  --pf-v5-c-button--m-secondary--active--after--BorderColor: var(--atf-border);
  --pf-v5-c-button--after--BorderWidth: 1px;
}
.pf-v5-theme-dark .atf-card-body .pf-v5-c-button.pf-m-secondary {
  --pf-v5-c-button--m-secondary--BackgroundColor: color-mix(in oklch, var(--atf-input) 30%, transparent);
  --pf-v5-c-button--m-secondary--after--BorderColor: var(--atf-input);
}
.atf-card-body .pf-v5-c-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--atf-ring) 50%, transparent);
}
/* Action rows: full-width buttons stacked with space-y-4 */
.atf-card-body #kc-form-buttons,
.atf-card-body .pf-v5-c-form__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0.25rem 0 0;
}
.atf-card-body .pf-v5-c-form__actions > * {
  margin: 0 !important;
}

/* ---- Links, checkbox, options ----------------------------------------------------------------------------------- */
/* Button variant=link: text-foreground underline-offset-4 hover:underline */
.atf-card-body a:not(.pf-v5-c-button),
.atf-card-body .pf-v5-c-button.pf-m-link {
  color: var(--atf-foreground);
  font-size: 0.75rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.atf-card-body a:not(.pf-v5-c-button):hover {
  color: var(--atf-muted-foreground);
}
.atf-card-body #kc-form-options,
.atf-card-body .pf-v5-c-login__main-footer-band-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}
/* Checkbox: size-4 rounded-none border-input, checked bg-primary */
.atf-card-body .pf-v5-c-check {
  align-items: center;
  gap: 0.5rem;
}
.atf-card-body .pf-v5-c-check__input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--atf-primary);
}
.atf-card-body .pf-v5-c-check__label {
  font-size: 0.75rem;
  color: var(--atf-foreground);
}
/* "New user? Register" and the page's notes: a muted line under the form, like a form description */
.atf-card-body .pf-v5-c-login__main-footer-band {
  margin: 1rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--atf-border);
  background: none;
  font-size: 0.75rem;
  color: var(--atf-muted-foreground);
  text-align: center;
}
.atf-card-body .pf-v5-c-login__main-footer-band-item {
  justify-content: center;
  gap: 0.25rem;
}
.atf-card-body #kc-info-wrapper, .atf-card-body #kc-info-wrapper p {
  font-size: 0.75rem;
  color: var(--atf-muted-foreground);
}
.atf-card-body .pf-v5-c-login__main-footer:empty {
  display: none;
}

/* ---- Alert: rounded-none font-mono, destructive / warning / success / info tints ---------------------------------- */
.atf-card-body .pf-v5-c-alert {
  --pf-v5-c-alert--BoxShadow: none;
  --pf-v5-c-alert--BorderTopWidth: 0;
  --pf-v5-c-alert--BackgroundColor: var(--atf-card);
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--atf-border);
  border-radius: 0;
  font-size: 0.75rem;
}
.atf-card-body .pf-v5-c-alert.pf-m-danger {
  --pf-v5-c-alert__title--Color: var(--atf-destructive);
  --pf-v5-c-alert__icon--Color: var(--atf-destructive);
  border-color: color-mix(in oklch, var(--atf-destructive) 50%, transparent);
}
.atf-card-body .pf-v5-c-alert.pf-m-warning {
  --pf-v5-c-alert--BackgroundColor: var(--atf-warn-bg);
  --pf-v5-c-alert__title--Color: var(--atf-warn);
  --pf-v5-c-alert__icon--Color: var(--atf-warn);
}
.atf-card-body .pf-v5-c-alert.pf-m-success {
  --pf-v5-c-alert--BackgroundColor: var(--atf-gain-bg);
  --pf-v5-c-alert__title--Color: var(--atf-gain);
  --pf-v5-c-alert__icon--Color: var(--atf-gain);
}
.atf-card-body .pf-v5-c-alert.pf-m-info {
  --pf-v5-c-alert--BackgroundColor: var(--atf-info-bg);
  --pf-v5-c-alert__title--Color: var(--atf-info);
  --pf-v5-c-alert__icon--Color: var(--atf-info);
}

/* ---- Identity providers (Sign in with Google) ---------------------------------------------------------------------- */
/* The button is the outline button above (pf-m-secondary); here only its list and the icon: size-4, in the text colour. */
/* At the top of the card: the providers, then the "or" divider, then the page's heading and form. */
.atf-card-body.atf-social-top:empty {
  display: none;
}
.atf-card-body.atf-social-top {
  padding-bottom: 0;
}
.atf-card-body .atf-social {
  margin: 0;
}
.atf-card-body .atf-social-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.atf-card-body .atf-social-button .atf-social-icon {
  width: 1rem;
  height: 1rem;
  flex: none;
}
.atf-card-body .atf-social-button[aria-disabled="true"],
.atf-card-body .atf-social-button.pf-m-aria-disabled {
  opacity: 0.5;
  pointer-events: none;
}
