/* ── Lejer login theme (from Team Ledger) ──────────────────────────────────────────────────
   Restyles the classic Keycloak login page to match the app. Tokens here are
   mirrored from apps/web/lib/tokens.ts / apps/web/app/globals.css. Loaded last
   in theme.properties so these rules override PatternFly + the base login.css.

   Login happens before we know the user's role, so we use the app's DEFAULT
   accent (green / manager), matching --accent in globals.css. */

@import url("https://fonts.googleapis.com/css2?family=Familjen+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

/* Lejer: the card is a sheet of paper on the green desk (DESIGN-SYSTEM-LEJER.md §1).
   Variable names are Team Ledger's so the rules below carry over unchanged. */
:root {
  --page-bg: #0F2E24;
  --surface: #F7F3E9;
  --input-bg: #EFEADC;
  --on-accent: #F7F3E9;
  --text: #3B3A32;
  --muted: #6B6855;       /* 5.1:1 on the paper card (WCAG 2.2 AA) */
  --muted-on-desk: rgba(247, 243, 233, .7);
  --hairline: #E5DFCE;
  --border: #E5DFCE;
  --accent: #0F2E24;
  --accent-hover: #1B4636;
  --red-text: #A8413B;
  --red-soft-bg: #F9E9E5;
  --red-soft-border: #EBC4BB;
  --amber: #8A5A10;
  --amber-soft-bg: #FBF0DC;
  --green-soft-bg: #E4F1E7;
  --green-soft-border: #CBE3D2;
  --font-sans: "Familjen Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Familjen Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;
  --font-size-micro: 0.68rem;
  --font-size-xs: 0.72rem;
  --font-size-sm: 0.76rem;
  --font-size-body: 0.85rem;
  --font-size-base: 0.9rem;
  --font-size-heading: 0.95rem;
  --font-size-auth-brand: 1.7rem;
  --font-size-page-title: 2rem;
  --radius-input: 11px;
  --radius-button: 11px;
  --radius-card: 16px;
  --shadow-card: 0 14px 30px -12px rgba(0, 0, 0, 0.5);
}

/* The brand above the card sits on the desk: paper-coloured, set in the voice font. */
#kc-header-wrapper { color: #F7F3E9 !important; font-weight: 600 !important; letter-spacing: -0.01em; }


/* ── Page canvas ─────────────────────────────────────────────────────────────
   Kill PatternFly's dark hero/background image; use the warm app canvas. */
html {
  background: var(--page-bg);
}
body.login-pf,
.login-pf body {
  background: var(--page-bg);
}
.login-pf-page {
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  padding-top: 7vh;
  padding-bottom: 6vh;
  /* The app's gutters: on a phone the card keeps 16px from each edge, as every screen of the app does. */
  padding-left: 16px;
  padding-right: 16px;
  box-sizing: border-box;
}
/* PatternFly paints a full-bleed background image on this pseudo element. */
.login-pf body::before,
.login-pf-page::before {
  background: none !important;
  content: none !important;
}

/* ── Brand header (realm display name) ───────────────────────────────────────
   Rendered above the card. Presented as the app's serif wordmark. */
#kc-header {
  width: min(100%, 460px);
  margin: 0 auto 18px;
  padding: 0 4px;
}
#kc-header-wrapper {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--font-size-auth-brand);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  text-align: left;
  padding: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

/* ── Card ────────────────────────────────────────────────────────────────────*/
.login-pf-page .card-pf {
  width: min(100%, 460px);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 30px 32px 32px;
}
@media (max-width: 480px) {
  .login-pf-page .card-pf { padding: 24px 20px 26px; }
}

/* ── Card title / eyebrow ────────────────────────────────────────────────────*/
#kc-content-wrapper {
  margin-top: 0;
}
#kc-page-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--font-size-page-title);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 20px;
  text-align: left;
}
/* "Sign in to your account" area / username hint above the form. */
#kc-username,
#kc-username .kc-login-tooltip {
  color: var(--muted);
}

/* ── Labels ──────────────────────────────────────────────────────────────────*/
.login-pf-page label,
.login-pf-page .control-label {
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  margin-bottom: 6px;
}

/* ── Inputs ──────────────────────────────────────────────────────────────────*/
.login-pf-page input[type="text"],
.login-pf-page input[type="email"],
.login-pf-page input[type="password"],
.login-pf-page input[type="number"],
.login-pf-page .form-control {
  height: auto;
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-heading);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 10px 12px;
  box-shadow: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.login-pf-page input::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}
.login-pf-page input:focus,
.login-pf-page .form-control:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: none;
}
.login-pf-page .form-group {
  margin-bottom: 18px;
}

/* Password reveal button — inside the field: one region, one outline, the
   eye at its end (PatternFly draws the control's own borders with ::after). */
.login-pf-page .pf-c-input-group,
.login-pf-page .pf-v5-c-input-group {
  align-items: stretch;
}
.login-pf-page .pf-c-input-group > input,
.login-pf-page .pf-v5-c-input-group > input {
  border-right: none;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.login-pf-page .kc-login-tooltip,
.login-pf-page button.pf-c-button.pf-m-control {
  color: var(--muted);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-input) var(--radius-input) 0;
  padding: 0 14px;
}
.login-pf-page button.pf-c-button.pf-m-control::after {
  border: none;
}
/* Focused, the field and its eye are outlined as one. */
.login-pf-page .pf-c-input-group:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: var(--radius-input);
}
.login-pf-page .pf-c-input-group > input:focus {
  outline: none;
}
.login-pf-page .pf-c-input-group:focus-within > input,
.login-pf-page .pf-c-input-group:focus-within > button.pf-c-button.pf-m-control {
  border-color: var(--accent);
}

/* ── Primary button ──────────────────────────────────────────────────────────*/
.login-pf-page #kc-form-buttons {
  margin-top: 22px;
}
.login-pf-page .btn-primary,
.login-pf-page input[type="submit"].btn-primary,
.login-pf-page #kc-login {
  width: 100%;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--on-accent);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--font-size-base);
  line-height: 1.2;
  border-radius: var(--radius-button);
  padding: 11px 16px;
  box-shadow: none;
  text-shadow: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.login-pf-page .btn-primary:hover,
.login-pf-page #kc-login:hover,
.login-pf-page .btn-primary:focus,
.login-pf-page #kc-login:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}

/* Secondary / default buttons (e.g. "Cancel", "Back"). */
.login-pf-page .btn-default,
.login-pf-page .btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-button);
  font-weight: 600;
  box-shadow: none;
}
.login-pf-page .btn-default:hover,
.login-pf-page .btn-secondary:hover {
  border-color: var(--text);
}

/* ── Checkbox: "Remember me" ─────────────────────────────────────────────────*/
.login-pf-page .checkbox {
  color: var(--muted);
  font-size: var(--font-size-body);
}
.login-pf-page .checkbox input[type="checkbox"] {
  accent-color: var(--accent);
}
#kc-form-options {
  margin-top: 4px;
}

/* ── Links ───────────────────────────────────────────────────────────────────*/
.login-pf-page a,
.login-pf-page #kc-registration a,
.login-pf-page #kc-info-wrapper a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.login-pf-page a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Alerts / messages ───────────────────────────────────────────────────────*/
.login-pf-page .alert,
.login-pf-page .pf-c-alert {
  border-radius: var(--radius-button);
  font-size: var(--font-size-body);
  border: 1px solid transparent;
  box-shadow: none;
}
.login-pf-page .alert-error,
.login-pf-page .pf-m-danger {
  background: var(--red-soft-bg);
  border-color: var(--red-soft-border);
  color: var(--red-text);
}
.login-pf-page .alert-warning {
  background: var(--amber-soft-bg);
  border-color: color-mix(in srgb, var(--amber) 35%, var(--amber-soft-bg));
  color: var(--amber);
}
.login-pf-page .alert-success {
  background: var(--green-soft-bg);
  border-color: var(--green-soft-border);
  color: var(--accent);
}
.login-pf-page .alert a {
  color: inherit;
  text-decoration: underline;
}

/* ── Footer / info area under the card ───────────────────────────────────────*/
#kc-info {
  width: min(100%, 460px);
  margin: 16px auto 0;
}
#kc-info-wrapper {
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--font-size-body);
  text-align: center;
}

/* Language selector, if enabled, stays subdued. */
#kc-locale ul {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-button);
}
#kc-locale a {
  color: var(--muted-on-desk);
}
#kc-locale ul a {
  color: var(--muted);
}

/* Monospace numerals utility, mirroring the app (used if codes/OTP appear). */
.login-pf-page .mono,
.login-pf-page input[name="totp"],
.login-pf-page #kc-otp-login-form input {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
