/* SafePII sign-in: Keycloak's login pages in the app's own world.

   Mirrors webui/static/theme.css (tokens, faces, controls); change that file
   first and copy here. It is the only stylesheet on these pages: PatternFly is
   dropped in theme.properties, so the class names the stock templates emit
   (pf-c-*, kc-*, login-pf-*, Bootstrap columns) are styled here or not at all.
   The faces are served from this theme, never a font CDN. */

@font-face { font-family: "Source Serif 4"; src: url("../fonts/source-serif-4.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("../fonts/hanken-grotesk.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Red Hat Mono"; src: url("../fonts/red-hat-mono.woff2") format("woff2"); font-weight: 400 600; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #faf9f5; --surface: #ffffff; --surface-2: #f6f5f0; --surface-3: #eceae2;
  --border: #e5e2d8; --border-strong: #d3cfc3;
  --text: #1f1e1d; --text-2: #4f4c45; --text-3: #6e6a60;
  --accent: #2b6e62; --accent-hover: #225a50; --accent-ink: #1f5a4f; --accent-soft: #e4efeb; --on-accent: #ffffff;
  --ring: rgba(43, 110, 98, .32);
  --ok: #2b6e62; --ok-bg: #e4efeb; --ok-bd: #b9d6cd;
  --warn: #8f5310; --warn-bg: #fbf0dc; --warn-bd: #ecd09c;
  --bad: #b0281d; --bad-bg: #fbeae6; --bad-bd: #f0c2b9;
  --info: #3e5c89; --info-bg: #eaeff7; --info-bd: #c7d4ea;
  --shadow-sm: 0 1px 2px rgba(31, 30, 29, .05);
  --shadow-md: 0 1px 2px rgba(31, 30, 29, .05), 0 2px 6px rgba(31, 30, 29, .05);
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Red Hat Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #262624; --surface: #30302e; --surface-2: #2b2a28; --surface-3: #3a3936;
    --border: #3d3c38; --border-strong: #4f4d48;
    --text: #f5f4ee; --text-2: #c9c6bc; --text-3: #aba89e;
    --accent: #7cc3b1; --accent-hover: #93d1c1; --accent-ink: #8fd0bf; --accent-soft: #263b36; --on-accent: #10201c;
    --ring: rgba(124, 195, 177, .32);
    --ok: #8fd0bf; --ok-bg: #263b36; --ok-bd: #3a5f56;
    --warn: #e8b766; --warn-bg: #3a2f1d; --warn-bd: #5e4a26;
    --bad: #f08a7e; --bad-bg: #3d2421; --bad-bd: #67352f;
    --info: #9db6dc; --info-bg: #263042; --info-bd: #3c4a64;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .25), 0 2px 8px rgba(0, 0, 0, .25);
  }
}

/* ---- base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--sans); font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, p, ul, ol, form, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; }
a { color: var(--accent-ink); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only, .pf-screen-reader { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.clearfix::after { content: ""; display: table; clear: both; }
code, pre, #kc-totp-secret-key, #kc-recovery-codes-list { font-family: var(--mono); }

/* ---- the page: a quiet column, the mark above a single card ----------------- */
.login-pf-page {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: max(9vh, 40px) 16px 40px;
}
#kc-header { margin-bottom: 22px; }
#kc-header-wrapper {
  display: flex; align-items: center; gap: 11px;
  font: 600 24px/1 var(--serif); letter-spacing: -.012em; color: var(--text);
}
#kc-header-wrapper .sp-mark { width: 36px; height: 36px; display: block; }
.card-pf {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-md); padding: 30px 30px 26px;
  animation: sp-rise .45s var(--ease) both;
}
@keyframes sp-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.login-pf-header { margin-bottom: 20px; }
#kc-page-title {
  font: 500 24px/1.25 var(--serif); letter-spacing: -.012em; color: var(--text); text-wrap: balance;
}
.subtitle { font-size: 13px; color: var(--text-3); }
.required { color: var(--bad); }
.sp-foot { margin-top: 18px; max-width: 420px; text-align: center; font-size: 13px; color: var(--text-3); }

/* the attempted username, with a way back to change it */
#kc-username { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 8px 8px 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; }
#kc-attempted-username { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#reset-login { color: var(--text-3); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; }
#reset-login:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.kc-login-tooltip { position: relative; display: grid; place-items: center; }
.kc-tooltip-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- forms -------------------------------------------------------------------- */
#kc-content-wrapper { display: flex; flex-direction: column; gap: 18px; }
form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.pf-c-form__label, .control-label, label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.pf-c-form__label-text { display: inline; }
.pf-c-form-control, .form-control, input[type=text], input[type=email], input[type=password], input[type=tel], select, textarea {
  width: 100%; height: 42px; padding: 0 13px; font: 15px var(--sans); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
textarea.form-control, textarea { height: auto; min-height: 90px; padding: 10px 13px; }
select { padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6a60' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 14px; }
.pf-c-form-control::placeholder, input::placeholder { color: var(--text-3); opacity: 1; }
.pf-c-form-control:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.pf-c-form-control[aria-invalid=true], input[aria-invalid=true] { border-color: var(--bad); }
.pf-c-form-control[aria-invalid=true]:focus { box-shadow: 0 0 0 3px rgba(176, 40, 29, .2); }
input:-webkit-autofill { -webkit-box-shadow: 0 0 0 40px var(--surface) inset; -webkit-text-fill-color: var(--text); }

/* password with its show/hide control sitting inside the field */
.pf-c-input-group { position: relative; display: flex; }
.pf-c-input-group .pf-c-form-control { padding-right: 46px; }
.pf-c-input-group .pf-c-button.pf-m-control {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px;
  display: grid; place-items: center; padding: 0; background: none; border: 0; border-radius: 8px;
  color: var(--text-3); cursor: pointer;
}
.pf-c-input-group .pf-c-button.pf-m-control:hover { color: var(--text); background: var(--surface-3); }

.pf-c-form__helper-text { font-size: 13px; color: var(--text-3); }
.pf-c-form__helper-text.pf-m-error, .kc-feedback-text.required, span[id^=input-error] { color: var(--bad); font-size: 13px; }

/* remember me and forgot password, on one line */
.login-pf-settings, #kc-form-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
#kc-form-options .checkbox label, .checkbox label, .pf-c-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; color: var(--text-2); cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.pf-c-check__label, .pf-c-radio__label { font-weight: 500; }
.login-pf-settings a, #kc-form-options a { font-weight: 600; font-size: 14px; }

/* ---- buttons ------------------------------------------------------------------ */
.pf-c-button, .btn, input[type=submit], button[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; font: 600 15px var(--sans); border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: background .15s, border-color .15s, transform .08s; text-decoration: none !important; -webkit-appearance: none;
}
.pf-c-button:hover, .btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.pf-c-button:active, .btn:active, input[type=submit]:active { transform: translateY(1px); }
.pf-c-button.pf-m-primary, .btn-primary, input[type=submit].pf-m-primary, #kc-login {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm);
}
.pf-c-button.pf-m-primary:hover, .btn-primary:hover, #kc-login:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.pf-c-button:disabled, input[type=submit]:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.pf-m-block, .btn-block { width: 100%; }
.pf-c-button.pf-m-link { background: none; border-color: transparent; color: var(--accent-ink); padding: 0 6px; height: auto; }
#kc-form-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
#kc-form-buttons > div, #kc-form-buttons .pf-c-form__actions, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#kc-form-buttons > input, #kc-form-buttons > button { flex: none; width: 100%; }
#kc-form-buttons > div input, #kc-form-buttons > div button, .form-actions input, .form-actions button { flex: 1 1 140px; }
/* Keycloak keeps the options row when remember-me and reset are both off; drop it then. */
.login-pf-settings:not(:has(input, a)) { display: none; }

/* ---- alerts -------------------------------------------------------------------- */
.pf-c-alert, .alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: 10px; font-size: 14px;
  background: var(--info-bg); border: 1px solid var(--info-bd); color: var(--text);
}
.pf-c-alert__icon { color: var(--info); padding-top: 2px; display: flex; }
.pf-c-alert.pf-m-danger, .alert-error { background: var(--bad-bg); border-color: var(--bad-bd); }
.pf-c-alert.pf-m-danger .pf-c-alert__icon, .alert-error .pf-c-alert__icon { color: var(--bad); }
.pf-c-alert.pf-m-warning, .alert-warning { background: var(--warn-bg); border-color: var(--warn-bd); }
.pf-c-alert.pf-m-warning .pf-c-alert__icon, .alert-warning .pf-c-alert__icon { color: var(--warn); }
.pf-c-alert.pf-m-success, .alert-success { background: var(--ok-bg); border-color: var(--ok-bd); }
.pf-c-alert.pf-m-success .pf-c-alert__icon, .alert-success .pf-c-alert__icon { color: var(--ok); }
.pf-c-alert__title { font-weight: 500; }

/* ---- below the form: sign-up, try another way, info and error pages ----------- */
#kc-info { margin-top: 4px; padding-top: 18px; border-top: 1px solid var(--border); text-align: center; font-size: 14px; color: var(--text-2); }
#kc-registration span a, #kc-info a { font-weight: 600; }
#try-another-way { font-weight: 600; font-size: 14px; }
.instruction, #kc-info-message p, #kc-error-message p { font-size: 15px; color: var(--text-2); }
#kc-info-message, #kc-error-message { display: flex; flex-direction: column; gap: 14px; }
#kc-error-message .instruction { color: var(--text); }

/* ---- identity providers ------------------------------------------------------- */
#kc-social-providers { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; border-top: 1px solid var(--border); }
#kc-social-providers h2 { font-size: 13px; font-weight: 500; color: var(--text-3); text-align: center; }
.kc-social-links, .kc-social-grid { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.kc-social-item { width: 100%; }
.kc-social-provider-name { font-weight: 600; }
.sp-idp-logo { display: none; }

/* ---- choose an authenticator / OTP device -------------------------------------- */
.select-auth-container { display: flex; flex-direction: column; gap: 8px; }
.select-auth-box-parent { display: flex; align-items: center; gap: 14px; padding: 14px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.select-auth-box-parent:hover { border-color: var(--accent-line, var(--accent)); background: var(--surface-2); }
.select-auth-box-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); flex: none; }
.select-auth-box-headline { font-weight: 600; font-size: 15px; }
.select-auth-box-desc { font-size: 13px; color: var(--text-3); }
.pf-m-fill { flex: 1; }
.select-auth-box-arrow { color: var(--text-3); }
.pf-c-tile { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 0 8px 8px 0; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; }
.pf-c-tile__input { position: absolute; opacity: 0; }
.pf-c-tile__input:checked + .pf-c-tile { border-color: var(--accent); background: var(--accent-soft); }
.pf-c-tile__title { font-weight: 600; }

/* OTP setup */
#kc-totp-settings { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--text-2); }
#kc-totp-secret-qr-code { border-radius: 10px; border: 1px solid var(--border); background: #fff; padding: 6px; }
#kc-totp-supported-apps { padding-left: 18px; }

/* ---- language menu ------------------------------------------------------------ */
#kc-locale { float: right; position: relative; margin: -8px -8px 6px 0; }
#kc-current-locale-link { font: 500 13px var(--sans); color: var(--text-2); background: none; border: 1px solid transparent; border-radius: 8px; padding: 5px 9px; cursor: pointer; }
#kc-current-locale-link:hover { background: var(--surface-2); border-color: var(--border); }
#kc-locale ul { display: none; position: absolute; right: 0; top: 100%; z-index: 5; min-width: 160px; list-style: none; margin: 4px 0 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); }
#kc-locale-dropdown:hover ul, #kc-locale ul[aria-expanded=true], #kc-current-locale-link[aria-expanded=true] + ul { display: block; }
#kc-locale ul a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 14px; }
#kc-locale ul a:hover { background: var(--surface-2); text-decoration: none; }

/* ---- icons: the app's drawn set, as masks so they take the text colour --------- */
.sp-ic { display: inline-block; width: 18px; height: 18px; flex: none; background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.select-auth-box-icon .sp-ic { width: 20px; height: 20px; }
.sp-ic-alert { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m10.29 3.86-8.47 14.14A2 2 0 0 0 3.53 21h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.sp-ic-check { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8 12 3 3 5-6'/%3E%3C/svg%3E"); }
.sp-ic-info { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E"); }
.sp-ic-edit { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E"); width: 16px; height: 16px; }
.sp-ic-eye { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.sp-ic-eye-off { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.9 4.24A9 9 0 0 1 12 4c6.5 0 10 8 10 8a17.6 17.6 0 0 1-2.16 3.19M6.6 6.6A17.4 17.4 0 0 0 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M2 2l20 20M14.1 14.1a3 3 0 1 1-4.2-4.2'/%3E%3C/svg%3E"); }
.sp-ic-chevron { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E"); }
.sp-ic-key { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7.5' cy='15.5' r='5.5'/%3E%3Cpath d='m21 2-9.6 9.6M15.5 7.5l3 3L22 7l-3-3'/%3E%3C/svg%3E"); }
.sp-ic-lock { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E"); }
.sp-ic-phone { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='2' width='12' height='20' rx='2.5'/%3E%3Cpath d='M11 18h2'/%3E%3C/svg%3E"); }

/* ---- small screens -------------------------------------------------------------- */
@media (max-width: 480px) {
  .login-pf-page { padding-top: 32px; }
  .card-pf { padding: 24px 20px 22px; border-radius: 14px; }
  #kc-page-title { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
