/*
 * Giotto Keycloak Login Theme
 * Skinning-only override (no .ftl changes)
 *
 * Visual direction:
 * - shadcn/ui "Vega"
 * - Zinc base palette
 * - Light mode only
 *
 * Installed at:
 * keycloak/themes/giotto/login/resources/css/style.css
 * (mounted into the keycloak container as /opt/keycloak/themes/giotto)
 *
 * theme.properties (keycloak/themes/giotto/login/theme.properties):
 * parent=keycloak.v2
 * styles=css/styles.css css/style.css
 * darkMode=false
 *
 * IMPORTANT:
 * Keep this stylesheet LAST so it overrides the parent Keycloak theme.
 * The logo lives next to this file in ../img/giotto-logo.svg (vendored from the
 * marketing site's CDN so the login page has no third-party dependency).
 */

/* ==========================================================================
   1. Design tokens
   ========================================================================== */

:root {
  color-scheme: light;

  --giotto-background: #ffffff;
  --giotto-foreground: #18181b;

  --giotto-card: #ffffff;
  --giotto-card-foreground: #18181b;

  --giotto-primary: #161A23;
  --giotto-primary-hover: #202633;
  --giotto-primary-active: #2b3342;
  --giotto-primary-foreground: #fafafa;

  --giotto-secondary: #f4f4f5;
  --giotto-secondary-hover: #e4e4e7;
  --giotto-secondary-foreground: #18181b;

  --giotto-muted: #f4f4f5;
  --giotto-muted-foreground: #71717a;

  --giotto-accent: #f4f4f5;
  --giotto-accent-foreground: #18181b;

  --giotto-border: #e4e4e7;
  --giotto-input: #e4e4e7;
  --giotto-ring: #a1a1aa;

  --giotto-destructive: #dc2626;
  --giotto-destructive-bg: #fef2f2;
  --giotto-destructive-border: #fecaca;

  --giotto-success: #15803d;
  --giotto-success-bg: #f0fdf4;
  --giotto-success-border: #bbf7d0;

  --giotto-warning: #a16207;
  --giotto-warning-bg: #fefce8;
  --giotto-warning-border: #fef08a;

  --giotto-radius: 0.625rem;
  --giotto-radius-sm: 0.5rem;
  --giotto-radius-lg: 0.875rem;

  --giotto-shadow-sm:
    0 1px 2px 0 rgb(0 0 0 / 0.04),
    0 1px 1px -1px rgb(0 0 0 / 0.04);

  --giotto-shadow-card:
    0 1px 3px 0 rgb(0 0 0 / 0.06),
    0 1px 2px -1px rgb(0 0 0 / 0.06);

  --giotto-font:
    "Geist",
    "Inter",
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}


/* Keep dimensions predictable when PatternFly adds padding to its wrappers. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ========================================================================
   2. Page shell
   ========================================================================== */

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-width: 320px;
  overflow-x: hidden;
}

body,
.login-pf body,
.pf-v5-c-login,
.pf-c-login {
  background: var(--giotto-background) !important;
  color: var(--giotto-foreground);
  font-family: var(--giotto-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Remove the default Keycloak background image / gradients */
.login-pf body {
  background-image: none !important;
}

/* Newer PatternFly login shells */
.pf-v5-c-login__container,
.pf-c-login__container {
  grid-template-columns: minmax(0, 1fr) !important;
  min-height: 100vh;
}

/* Center the auth area on the viewport */
.login-pf-page,
#kc-content,
.pf-v5-c-login__main,
.pf-c-login__main {
  width: 100%;
}

.login-pf-page {
  padding: 48px 24px !important;
}

#kc-content {
  display: flex;
  justify-content: center;
}

#kc-content-wrapper {
  width: 100%;
  max-width: 400px;
}


/* ==========================================================================
   3. Brand / header
   ========================================================================== */

#kc-header,
.pf-v5-c-login__header,
.pf-c-login__header {
  text-align: center;
}

#kc-header {
  margin: 0 auto 28px !important;
  color: var(--giotto-foreground) !important;
}

#kc-header-wrapper {
  padding: 0 !important;
  color: var(--giotto-foreground) !important;
  font-family: var(--giotto-font) !important;
  font-size: 24px !important;
  line-height: 1 !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em;
  text-transform: none !important;
  text-shadow: none !important;
}

#kc-header-wrapper {
  width: 224px !important;
  height: 64px !important;
  margin: 0 auto;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
}

#kc-header-wrapper::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background-color: var(--giotto-primary);
  -webkit-mask: url("../img/giotto-logo.svg") center / contain no-repeat;
  mask: url("../img/giotto-logo.svg") center / contain no-repeat;
}


/* ==========================================================================
   4. Card
   ========================================================================== */

.card-pf,
.pf-v5-c-login__main,
.pf-c-login__main {
  background: var(--giotto-card) !important;
  color: var(--giotto-card-foreground) !important;
  border: 1px solid var(--giotto-border) !important;
  border-radius: var(--giotto-radius-lg) !important;
  box-shadow: var(--giotto-shadow-card) !important;
}

.card-pf {
  width: 100%;
  max-width: 400px;
  margin: 0 !important;
  padding: 32px !important;
}

/* PatternFly 4/5 */
.pf-v5-c-login__main,
.pf-c-login__main {
  max-width: 400px;
  overflow: hidden;
}

.pf-v5-c-login__main-header,
.pf-c-login__main-header,
.pf-v5-c-login__main-body,
.pf-c-login__main-body,
.pf-v5-c-login__main-footer,
.pf-c-login__main-footer {
  padding-left: 32px !important;
  padding-right: 32px !important;
}

.pf-v5-c-login__main-header,
.pf-c-login__main-header {
  padding-top: 32px !important;
  padding-bottom: 20px !important;
}

.pf-v5-c-login__main-body,
.pf-c-login__main-body {
  padding-bottom: 32px !important;
}


/* ==========================================================================
   5. Typography
   ========================================================================== */

#kc-page-title,
.login-pf-page .login-pf-header h1,
.pf-v5-c-title,
.pf-c-title {
  margin: 0 !important;
  color: var(--giotto-foreground) !important;
  font-family: var(--giotto-font) !important;
  font-size: 24px !important;
  line-height: 1.25 !important;
  font-weight: 600 !important;
  letter-spacing: -0.025em !important;
  text-align: left !important;
}

.login-pf-header {
  margin-bottom: 24px !important;
}

p,
.pf-v5-c-form__helper-text,
.pf-c-form__helper-text,
.instruction {
  color: var(--giotto-muted-foreground);
  font-size: 14px;
  line-height: 1.5;
}

label,
.pf-v5-c-form__label-text,
.pf-c-form__label-text {
  color: var(--giotto-foreground) !important;
  font-size: 14px !important;
  line-height: 1.25 !important;
  font-weight: 500 !important;
}


/* ==========================================================================
   6. Form spacing
   ========================================================================== */

#kc-form,
#kc-form-login,
#kc-register-form,
#kc-reset-password-form,
.pf-v5-c-form,
.pf-c-form {
  width: 100%;
}

.form-group,
.pf-v5-c-form__group,
.pf-c-form__group {
  margin-bottom: 18px !important;
}

.pf-v5-c-form__group-label,
.pf-c-form__group-label {
  margin-bottom: 8px !important;
  padding-bottom: 0 !important;
}

.pf-v5-c-form__group-label > label,
.pf-c-form__group-label > label {
  display: block;
}

/* Remove excess bottom gap on final form groups */
.form-group:last-child,
.pf-v5-c-form__group:last-child,
.pf-c-form__group:last-child {
  margin-bottom: 0 !important;
}


/* ==========================================================================
   7. Inputs
   ========================================================================== */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="number"],
select,
textarea,
.form-control {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px !important;

  background: var(--giotto-background) !important;
  color: var(--giotto-foreground) !important;

  border: 1px solid var(--giotto-input) !important;
  border-radius: var(--giotto-radius-sm) !important;
  box-shadow: var(--giotto-shadow-sm) !important;

  font-family: var(--giotto-font) !important;
  font-size: 14px !important;
  line-height: 1.4 !important;

  outline: none !important;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease;
}

/* PatternFly 5 renders the input inside a form-control wrapper. The wrapper
   must stay neutral so it does not create a second border around the input. */
.pf-v5-c-form-control,
.pf-c-form-control {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.pf-v5-c-form-control > input,
.pf-c-form-control > input {
  display: block;
  width: 100%;
  min-width: 0;
}

input::placeholder,
textarea::placeholder,
.form-control::placeholder {
  color: #a1a1aa !important;
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover,
.form-control:hover {
  border-color: #d4d4d8 !important;
}

input:focus,
input:focus-visible,
select:focus,
select:focus-visible,
textarea:focus,
textarea:focus-visible,
.form-control:focus,
.form-control:focus-visible {
  border-color: var(--giotto-ring) !important;
  box-shadow:
    0 0 0 3px rgb(161 161 170 / 0.18),
    var(--giotto-shadow-sm) !important;
}

/* Browser autofill */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--giotto-foreground);
  -webkit-box-shadow: 0 0 0 1000px var(--giotto-background) inset !important;
  transition: background-color 9999s ease-out 0s;
}


/* ==========================================================================
   8. Password visibility button
   ========================================================================== */

.pf-v5-c-input-group,
.pf-c-input-group {
  display: flex;
  width: 100%;
  min-width: 0;
  border-radius: var(--giotto-radius-sm);
}

.pf-v5-c-input-group__item,
.pf-c-input-group__item {
  min-width: 0;
}

.pf-v5-c-input-group__item.pf-m-fill,
.pf-c-input-group__item.pf-m-fill {
  flex: 1 1 auto;
}

.pf-v5-c-input-group .pf-v5-c-button,
.pf-c-input-group .pf-c-button {
  flex: 0 0 40px;
  width: 40px;
  min-height: 40px;
  padding: 0 !important;
  color: var(--giotto-muted-foreground);
  background: var(--giotto-background) !important;
  border-color: var(--giotto-input) !important;
}

.pf-v5-c-input-group .pf-v5-c-button:hover,
.pf-c-input-group .pf-c-button:hover {
  color: var(--giotto-foreground);
  background: var(--giotto-accent) !important;
}

.pf-v5-c-input-group .pf-v5-c-form-control > input,
.pf-c-input-group .pf-c-form-control > input {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

.password-toggle-icon {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* ==========================================================================
   9. Primary buttons
   ========================================================================== */

#kc-login,
#kc-register,
input[type="submit"],
button[type="submit"],
.btn-primary,
.pf-v5-c-button.pf-m-primary,
.pf-c-button.pf-m-primary {
  min-height: 40px;
  width: 100%;
  padding: 8px 16px !important;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  background: var(--giotto-primary) !important;
  color: var(--giotto-primary-foreground) !important;

  border: 1px solid var(--giotto-primary) !important;
  border-radius: var(--giotto-radius-sm) !important;
  box-shadow: var(--giotto-shadow-sm) !important;

  font-family: var(--giotto-font) !important;
  font-size: 14px !important;
  line-height: 1.25 !important;
  font-weight: 500 !important;

  text-shadow: none !important;
  cursor: pointer;

  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 80ms ease;
}

#kc-login:hover,
#kc-register:hover,
input[type="submit"]:hover,
button[type="submit"]:hover,
.btn-primary:hover,
.pf-v5-c-button.pf-m-primary:hover,
.pf-c-button.pf-m-primary:hover {
  background: var(--giotto-primary-hover) !important;
  border-color: var(--giotto-primary-hover) !important;
}

#kc-login:active,
#kc-register:active,
input[type="submit"]:active,
button[type="submit"]:active,
.btn-primary:active,
.pf-v5-c-button.pf-m-primary:active,
.pf-c-button.pf-m-primary:active {
  background: var(--giotto-primary-active) !important;
  transform: translateY(1px);
}

#kc-login:focus-visible,
#kc-register:focus-visible,
input[type="submit"]:focus-visible,
button[type="submit"]:focus-visible,
.btn-primary:focus-visible,
.pf-v5-c-button.pf-m-primary:focus-visible,
.pf-c-button.pf-m-primary:focus-visible {
  outline: none !important;
  box-shadow:
    0 0 0 3px rgb(161 161 170 / 0.28),
    var(--giotto-shadow-sm) !important;
}

button:disabled,
input:disabled,
.btn.disabled,
.pf-v5-c-button:disabled,
.pf-c-button:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  pointer-events: none;
}


/* ==========================================================================
   10. Secondary / Identity Provider button
   ========================================================================== */

#kc-social-providers a,
.zocial,
.pf-v5-c-button.pf-m-secondary,
.pf-v5-c-button.pf-m-control,
.pf-c-button.pf-m-secondary,
.pf-c-button.pf-m-control {
  min-height: 40px;
  width: 100%;
  padding: 8px 16px !important;

  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;

  background: var(--giotto-background) !important;
  color: var(--giotto-foreground) !important;

  border: 1px solid var(--giotto-border) !important;
  border-radius: var(--giotto-radius-sm) !important;
  box-shadow: var(--giotto-shadow-sm) !important;

  font-family: var(--giotto-font) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  text-shadow: none !important;

  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

#kc-social-providers a:hover,
.zocial:hover,
.pf-v5-c-button.pf-m-secondary:hover,
.pf-v5-c-button.pf-m-control:hover,
.pf-c-button.pf-m-secondary:hover,
.pf-c-button.pf-m-control:hover {
  background: var(--giotto-accent) !important;
  border-color: #d4d4d8 !important;
  color: var(--giotto-accent-foreground) !important;
}

#kc-social-providers a:focus-visible,
.zocial:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgb(161 161 170 / 0.18),
    var(--giotto-shadow-sm) !important;
}

#kc-social-providers ul,
#kc-social-providers .kc-social-links {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none;
}

#kc-social-providers li {
  margin: 0 !important;
}


/* ==========================================================================
   11. Social divider ("Or sign in with")
   ========================================================================== */

#kc-social-providers {
  margin-top: 24px !important;
}

#kc-social-providers h4,
#kc-social-providers .kc-social-provider-name + span {
  color: var(--giotto-muted-foreground);
}

#kc-social-providers h4 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px !important;

  color: var(--giotto-muted-foreground) !important;
  font-size: 12px !important;
  line-height: 1.25;
  font-weight: 400 !important;
  text-align: center;
  white-space: nowrap;
}

#kc-social-providers h4::before,
#kc-social-providers h4::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--giotto-border);
}


/* ==========================================================================
   12. Links
   ========================================================================== */

a,
#kc-form-options a,
#kc-registration a,
#kc-info a {
  color: var(--giotto-foreground) !important;
  font-weight: 500;
  text-decoration: none !important;
  text-underline-offset: 3px;
}

a:hover,
#kc-form-options a:hover,
#kc-registration a:hover,
#kc-info a:hover {
  color: var(--giotto-foreground) !important;
  text-decoration: underline !important;
}

a:focus-visible {
  outline: 2px solid var(--giotto-ring);
  outline-offset: 3px;
  border-radius: 2px;
}


/* ==========================================================================
   13. Remember me / form options
   ========================================================================== */

#kc-form-options {
  margin: 0 0 18px !important;
}

#kc-form-options,
#kc-form-options .checkbox,
#kc-form-options .pf-v5-c-check,
#kc-form-options .pf-c-check {
  color: var(--giotto-muted-foreground);
  font-size: 14px;
}

#kc-form-options .checkbox label,
#kc-form-options .pf-v5-c-check__label,
#kc-form-options .pf-c-check__label {
  color: var(--giotto-muted-foreground) !important;
  font-size: 14px !important;
  font-weight: 400 !important;
}

/* Native checkbox approximation of shadcn Checkbox */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0 8px 0 0 !important;
  padding: 0 !important;

  accent-color: var(--giotto-primary);
  vertical-align: -2px;

  border-radius: 4px;
  box-shadow: none !important;
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--giotto-ring) !important;
  outline-offset: 2px;
}


/* ==========================================================================
   14. Registration / footer info
   ========================================================================== */

#kc-info {
  margin: 24px 0 0 !important;
}

#kc-info-wrapper {
  margin: 0 !important;
  padding: 0 !important;

  background: transparent !important;
  color: var(--giotto-muted-foreground) !important;

  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

#kc-registration {
  margin: 0 !important;
}


/* ==========================================================================
   15. Alerts / validation / errors
   ========================================================================== */

.alert,
.pf-v5-c-alert,
.pf-c-alert {
  margin: 0 0 20px !important;
  padding: 12px 14px !important;

  border: 1px solid var(--giotto-border) !important;
  border-radius: var(--giotto-radius-sm) !important;
  box-shadow: none !important;

  font-size: 13px !important;
  line-height: 1.45 !important;
}

.alert-error,
.alert-danger,
.pf-v5-c-alert.pf-m-danger,
.pf-c-alert.pf-m-danger {
  background: var(--giotto-destructive-bg) !important;
  color: #991b1b !important;
  border-color: var(--giotto-destructive-border) !important;
}

.alert-success,
.pf-v5-c-alert.pf-m-success,
.pf-c-alert.pf-m-success {
  background: var(--giotto-success-bg) !important;
  color: var(--giotto-success) !important;
  border-color: var(--giotto-success-border) !important;
}

.alert-warning,
.pf-v5-c-alert.pf-m-warning,
.pf-c-alert.pf-m-warning {
  background: var(--giotto-warning-bg) !important;
  color: var(--giotto-warning) !important;
  border-color: var(--giotto-warning-border) !important;
}

.alert-info,
.pf-v5-c-alert.pf-m-info,
.pf-c-alert.pf-m-info {
  background: var(--giotto-secondary) !important;
  color: var(--giotto-foreground) !important;
  border-color: var(--giotto-border) !important;
}

/* Inline validation */
.has-error .form-control,
input[aria-invalid="true"],
.pf-v5-c-form-control[aria-invalid="true"],
.pf-c-form-control[aria-invalid="true"] {
  border-color: var(--giotto-destructive) !important;
}

.has-error .form-control:focus,
input[aria-invalid="true"]:focus,
input[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.14) !important;
}

.help-block,
.pf-v5-c-form__helper-text.pf-m-error,
.pf-c-form__helper-text.pf-m-error {
  color: var(--giotto-destructive) !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
}


/* ==========================================================================
   16. Registration form specifics
   ========================================================================== */

/* Keep registration readable even if there are many fields */
#kc-register-form .form-group,
#kc-register-form .pf-v5-c-form__group,
#kc-register-form .pf-c-form__group {
  margin-bottom: 16px !important;
}

/* Required marker */
.required,
.pf-v5-c-form__label-required,
.pf-c-form__label-required {
  color: var(--giotto-destructive) !important;
}


/* ==========================================================================
   17. Reset password / action pages
   ========================================================================== */

#kc-reset-password-form .instruction,
#kc-content-wrapper > .instruction,
#kc-content-wrapper > p {
  margin: 0 0 20px;
  color: var(--giotto-muted-foreground);
  font-size: 14px;
  line-height: 1.55;
}

/* Back-to-login links */
#kc-form-options + #kc-form-buttons,
#kc-content-wrapper .back-to-login {
  margin-top: 18px;
}


/* ==========================================================================
   18. Password policy / registration helper content
   ========================================================================== */

#kc-password-policy,
.kc-password-policy {
  margin-top: 8px;
  padding: 12px;

  background: var(--giotto-muted);
  color: var(--giotto-muted-foreground);
  border: 1px solid var(--giotto-border);
  border-radius: var(--giotto-radius-sm);

  font-size: 12px;
  line-height: 1.5;
}

#kc-password-policy ul,
.kc-password-policy ul {
  margin: 8px 0 0 18px;
  padding: 0;
}


/* ==========================================================================
   19. Terms / consent / generic list content
   ========================================================================== */

#kc-terms-text,
#kc-content-wrapper > ul {
  color: var(--giotto-muted-foreground);
  font-size: 14px;
  line-height: 1.55;
}

#kc-terms-text {
  max-height: 320px;
  overflow: auto;
  margin-bottom: 20px;
  padding-right: 8px;
}


/* ==========================================================================
   20. Language selector
   ========================================================================== */

#kc-locale {
  margin-bottom: 16px;
  text-align: right;
}

#kc-locale-dropdown a {
  color: var(--giotto-muted-foreground) !important;
  font-size: 13px;
}

#kc-locale ul {
  background: var(--giotto-background);
  border: 1px solid var(--giotto-border);
  border-radius: var(--giotto-radius-sm);
  box-shadow: var(--giotto-shadow-card);
}


/* ==========================================================================
   21. Accessibility
   ========================================================================== */

::selection {
  background: #e4e4e7;
  color: var(--giotto-foreground);
}

*:focus-visible {
  scroll-margin: 16px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* ==========================================================================
   22. Responsive
   ========================================================================== */

@media (max-width: 767px) {
  .login-pf-page {
    padding: 24px 16px !important;
  }

  #kc-header {
    margin-bottom: 22px !important;
  }

  .card-pf {
    padding: 24px !important;
    border-radius: var(--giotto-radius) !important;
  }

  .pf-v5-c-login__main-header,
  .pf-c-login__main-header,
  .pf-v5-c-login__main-body,
  .pf-c-login__main-body,
  .pf-v5-c-login__main-footer,
  .pf-c-login__main-footer {
    padding-left: 24px !important;
    padding-right: 24px !important;
  }

  #kc-page-title,
  .login-pf-page .login-pf-header h1,
  .pf-v5-c-title,
  .pf-c-title {
    font-size: 22px !important;
  }
}


/* ==========================================================================
   23. Large screens
   ========================================================================== */

@media (min-width: 1200px) {
  .login-pf-page {
    padding-top: 72px !important;
    padding-bottom: 72px !important;
  }
}


/* Preview-only fixes for the exact copied Keycloak DOM */
html, body {
  min-height: 100%;
}
body#keycloak-bg {
  margin: 0;
}
.pf-v5-c-login {
  min-height: 100vh;
}
.pf-v5-c-login__container {
  min-height: 100vh;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 48px 20px !important;
}
#kc-header {
  width: 100%;
}
.pf-v5-c-login__main {
  width: 100%;
  max-width: 400px;
}
.pf-v5-c-login__main-body {
  width: 100%;
}
.pf-v5-c-form-control {
  display: block;
}
.pf-v5-c-form-control > input {
  display: block;
}
.pf-v5-c-input-group {
  display: flex;
  width: 100%;
}
.pf-v5-c-input-group__item.pf-m-fill {
  flex: 1;
}
.pf-v5-c-input-group__item.pf-m-fill .pf-v5-c-form-control,
.pf-v5-c-input-group__item.pf-m-fill input {
  width: 100%;
}
.pf-v5-c-input-group .pf-v5-c-form-control > input {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}
.pf-v5-c-input-group [data-password-toggle],
#password-show-password,
#password-confirm-show-password {
  flex: 0 0 40px !important;
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}

.pf-v5-c-input-group [data-password-toggle] .password-toggle-icon {
  width: 18px !important;
  height: 18px !important;
}
.pf-v5-c-helper-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.pf-v5-c-check label,
label.pf-v5-c-check {
  display: inline-flex;
  align-items: center;
}
#kc-social-providers svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
#kc-social-providers,
#kc-social-providers ul,
#kc-social-providers li,
#kc-social-providers a {
  width: 100%;
}
#kc-social-providers ul {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}
#kc-social-providers a {
  position: relative;
}
#kc-social-providers a svg {
  position: absolute;
  left: 14px;
}
.pf-v5-c-login__main-footer-band {
  width: 100%;
  text-align: center;
}

.pf-v5-c-login__main-footer-band > span,
.pf-v5-c-login__main-footer-band > .pf-v5-c-login__main-footer-band-item {
  color: var(--giotto-muted-foreground) !important;
  font-size: 14px !important;
  line-height: 1.5;
}

.pf-v5-c-helper-text {
  min-width: 0;
  flex-wrap: wrap;
}

.pf-v5-c-helper-text__item {
  min-width: 0;
  margin-left: auto;
}

#kc-social-providers + #kc-info {
  margin-top: 16px !important;
}

/* The copied PatternFly social list carries its own 32px body inset. Extend
   the provider wrapper so its button lines up with the form controls above. */
#kc-social-providers {
  width: calc(100% + 64px) !important;
  margin-left: -32px !important;
  margin-right: -32px !important;
}
.pf-v5-c-login__main-footer {
  padding-left: 32px !important;
  padding-right: 32px !important;
  padding-top: 16px !important;
  padding-bottom: 0 !important;
}
.pf-v5-c-login__main,
.pf-v5-c-login__main-footer {
  min-height: 0 !important;
  height: auto !important;
}
.pf-v5-c-form__helper-text {
  margin-top: 8px !important;
}
.pf-v5-c-login__main-footer + .pf-v5-c-login__main-footer {
  display: none;
}
@media (max-width: 520px) {
  .pf-v5-c-login__container {
    justify-content: flex-start !important;
    padding: 28px 16px !important;
  }
  .pf-v5-c-login__main {
    max-width: 100%;
  }

  .pf-v5-c-login__main-header,
  .pf-v5-c-login__main-body,
  .pf-v5-c-login__main-footer {
    padding-left: 24px !important;
    padding-right: 24px !important;
  }

  .pf-v5-c-helper-text {
    align-items: flex-start;
    gap: 8px;
  }

  .pf-v5-c-helper-text__item {
    margin-left: 0;
  }

  #kc-social-providers {
    width: calc(100% + 48px) !important;
    margin-left: -24px !important;
    margin-right: -24px !important;
  }
}

/* Registration preview */
.registration-required {
  display: none;
  margin: 0 0 18px;
  color: var(--giotto-muted-foreground);
  font-size: 14px;
  line-height: 1.5;
}

.registration-required .pf-v5-c-form__label-required {
  margin-right: 4px;
}

.registration-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--giotto-foreground) !important;
  font-size: 14px !important;
  line-height: 1.45 !important;
  font-weight: 400 !important;
  cursor: pointer;
}

.registration-checkbox input[type="checkbox"] {
  flex: 0 0 16px;
  margin-top: 2px !important;
}

.registration-checkbox span {
  flex: 1;
  min-width: 0;
}

.registration-terms {
  margin: 2px 0 8px;
  color: var(--giotto-muted-foreground);
  font-size: 14px;
  line-height: 1.5;
}

.registration-terms p {
  margin: 0;
}

.registration-terms p + p {
  margin-top: 0;
}

.registration-terms strong {
  color: var(--giotto-foreground);
  font-weight: 600;
}

.registration-checkbox-group {
  margin-bottom: 18px;
}

#kc-form-buttons {
  margin-top: 8px;
}

.registration-back-to-login {
  margin-top: 18px;
  color: var(--giotto-muted-foreground);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

/* Forgot-password preview */
.forgot-password-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.forgot-password-actions > * {
  margin: 0 !important;
}

.forgot-password-footer {
  padding-top: 16px !important;
}

.forgot-password-footer #kc-info {
  margin: 0 !important;
}


/* ==========================================================================
   24. Keycloak 26.x (keycloak.v2 / PatternFly 5) DOM fixes
   Verified against quay.io/keycloak/keycloak:26.5.5. PatternFly 5 draws
   several borders with ::before/::after pseudo-elements and lays the card
   out with grid/flex, which the rules above cannot reach. Keep this section
   last.
   ========================================================================== */

/* Card centring on wide screens: at >= 1200px PF5 sets `align-self: start` on
   the card for its two-column grid. Inside the flex column used above that
   pins the card to the left edge while the logo stays centred. */
.pf-v5-c-login__main {
  align-self: center !important;
  justify-self: center !important;
}

/* Vertical budget: PF5 pads the outer .pf-v5-c-login by 24px top and bottom on
   top of the container's own padding, which alone pushes a registration form
   past a 900px viewport. Keep one set of paddings (the container's), slightly
   tighter on desktop; the <=520px rule above keeps 28px 16px on phones. */
.pf-v5-c-login {
  padding: 0 !important;
}

@media (min-width: 521px) {
  .pf-v5-c-login__container {
    padding: 40px 20px !important;
  }
}

/* Blue brand bar: PF5 puts a 4px primary border-top on the card header. */
.pf-v5-c-login__main-header {
  border-top: 0 !important;
}

/* Header layout: language selector on its own row (top-right), title below at
   full width. Mirrors the v1 layout this stylesheet was designed for, where
   #kc-locale sat above the title. */
.pf-v5-c-login__main-header {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 12px;
}

.pf-v5-c-login__main-header > .pf-v5-c-title {
  flex: 1 1 100%;
  order: 2;
}

.pf-v5-c-login__main-header-utilities {
  order: 1;
  margin: 0 0 16px auto;
}

/* Language selector: a native <select> plus a caret <span> inside a
   form-control wrapper. Keep them together as one compact control. */
.pf-v5-c-login__main-header-utilities .pf-v5-c-form-control {
  position: relative;
  display: inline-block;
  width: auto;
}

.pf-v5-c-login__main-header-utilities select {
  width: auto;
  min-height: 32px;
  padding: 6px 28px 6px 10px !important;
  color: var(--giotto-muted-foreground) !important;
  font-size: 13px !important;
  line-height: 1.25 !important;
  box-shadow: none !important;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.pf-v5-c-login__main-header-utilities .pf-v5-c-form-control__utilities {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  display: flex;
  color: var(--giotto-muted-foreground);
  pointer-events: none;
}

.pf-v5-c-login__main-header-utilities .pf-v5-c-form-control__toggle-icon svg {
  width: 10px;
  height: 10px;
}

/* Inputs: PF5 draws the (blue-on-focus) underline with ::after on the wrapper. */
.pf-v5-c-form-control::before,
.pf-v5-c-form-control::after {
  display: none !important;
  content: none !important;
}

/* Buttons: PF5 draws button borders with ::after. Our element borders replace them. */
.pf-v5-c-button::after {
  display: none !important;
  content: none !important;
}

.pf-v5-c-input-group .pf-v5-c-button {
  border: 1px solid var(--giotto-input) !important;
  border-radius: var(--giotto-radius-sm) !important;
}

/* Form groups: PF5 forms are grids with a 24px gap on top of our margins. */
.pf-v5-c-form {
  gap: 0 !important;
}

/* Footer (social providers, "New user?", reset-password instructions): PF5 makes
   it a centred flex box narrower than the body. Make it a plain full-width block
   so everything lines up with the form controls; this replaces the
   negative-margin hack in the preview section above. */
.pf-v5-c-login__main-footer {
  display: block !important;
  width: 100% !important;
  margin: 24px 0 0 !important;
  padding: 0 !important;
}

/* keycloak.v2 renders this footer inside the body, so it inherits the body's
   inset. A footer that is a direct child of the card needs its own. */
.pf-v5-c-login__main > .pf-v5-c-login__main-footer {
  margin-top: 0 !important;
  padding: 0 32px 32px !important;
}

/* The template also emits an empty trailing footer; it would only add space. */
.pf-v5-c-login__main-footer:not(:has(*)) {
  display: none !important;
}

#kc-social-providers {
  width: 100% !important;
  margin: 0 !important;
}

#kc-social-providers ul {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

#kc-social-providers li {
  padding: 0 0 10px !important;
}

#kc-social-providers a {
  width: 100% !important;
  justify-content: center !important;
}

/* Footer bands lose PF5's top rule; spacing comes from margins instead. */
.pf-v5-c-login__main-footer-band {
  border: 0 !important;
  padding: 0 !important;
}

.pf-v5-c-login__main-footer > #kc-info:first-child {
  margin-top: 0 !important;
}


/* "Or sign in with": the band right before the provider list becomes a text divider. */
.pf-v5-c-login__main-footer-band:has(+ #kc-social-providers) {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0 0 16px !important;
  white-space: nowrap;
}

.pf-v5-c-login__main-footer-band:has(+ #kc-social-providers)::before,
.pf-v5-c-login__main-footer-band:has(+ #kc-social-providers)::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--giotto-border);
}

.pf-v5-c-login__main-footer-band:has(+ #kc-social-providers) > span {
  font-size: 12px !important;
}

@media (max-width: 767px) {
  .pf-v5-c-login__main > .pf-v5-c-login__main-footer {
    padding: 0 24px 24px !important;
  }
}


/* ==========================================================================
   25. Card header: logo inside the card, centred title (all login pages)
   ========================================================================== */

#kc-header {
  display: none !important;
}

.pf-v5-c-login__main-header {
  justify-content: center;
  padding-top: 36px !important;
}

.pf-v5-c-login__main-header::before {
  content: "";
  flex: 0 0 100%;
  height: 76px;
  margin-bottom: 20px;
  background-color: var(--giotto-primary);
  -webkit-mask: url("../img/giotto-logo.svg") center / 76px 76px no-repeat;
  mask: url("../img/giotto-logo.svg") center / 76px 76px no-repeat;
}

/* #kc-page-title: the typography rule in §5 selects the title by id, so the centring must too. */
.pf-v5-c-login__main-header > #kc-page-title,
.pf-v5-c-login__main-header > .pf-v5-c-title {
  text-align: center !important;
  font-size: 30px !important;
  letter-spacing: -0.03em !important;
}

.pf-v5-c-login__main-header-utilities {
  margin: 0 auto 12px !important;
}

/* ==========================================================================
   26. Registration page (giotto/register.ftl + Keycloak 26.x DOM)
   ========================================================================== */

/* "* Required fields" helper line and its spacer wrapper (other pages still print it). */
.pf-v5-c-login__main-body .subtitle:has(> .pf-v5-c-helper-text__item-text > .pf-v5-c-form__label-required),
.pf-v5-c-login__main-body > .pf-v5-u-mb-md-on-md:has(> .subtitle:only-child) {
  display: none !important;
}

.pf-v5-c-form__label-required {
  margin-left: 4px !important;
}

.giotto-subtitle {
  margin: -6px 0 24px;
  text-align: center;
  color: var(--giotto-muted-foreground);
  font-size: 15px;
  line-height: 1.5;
}

/* Optional fields say so instead of required ones carrying an asterisk only. */
#kc-register-form .pf-v5-c-form__label:not(:has(.pf-v5-c-form__label-required)) .pf-v5-c-form__label-text::after {
  content: " (optional)";
  color: var(--giotto-muted-foreground);
  font-weight: 400;
}

.giotto-hint {
  margin-top: 8px;
  color: var(--giotto-muted-foreground);
  font-size: 13px;
  line-height: 1.5;
}

/* password-confirm is kept for Keycloak's validation but mirrored by script and hidden. */
.giotto-hidden {
  display: none !important;
}

/* Marketing consent: the option label is the whole story, drop the group label. */
#kc-register-form .pf-v5-c-form__group:has([name="marketingConsent"]) > .pf-v5-c-form__group-label {
  display: none !important;
}

/* Checkbox row (marketing consent): box left, hanging text right. */
#kc-register-form div:has(> input[type="checkbox"]) {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

#kc-register-form input[type="checkbox"] {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 2px 0 0 !important;
}

#kc-register-form input[type="checkbox"] + label {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--giotto-foreground) !important;
  font-size: 14px !important;
  line-height: 1.45 !important;
  font-weight: 400 !important;
  cursor: pointer;
}

#kc-register-form #kc-form-buttons {
  margin-top: 6px;
}

/* Legal notice under the button. */
.giotto-legal {
  margin: 14px 0 0;
  text-align: center;
  color: var(--giotto-muted-foreground);
  font-size: 13.5px;
  line-height: 1.55;
}

.giotto-legal a,
.giotto-register-footer a {
  color: var(--giotto-foreground) !important;
  font-weight: 500;
  text-decoration: underline !important;
  text-underline-offset: 3px;
}

/* "Already have an account? Log in", separated by a full-width rule. */
.giotto-register-footer {
  margin: 22px -32px 0;
  padding: 18px 32px 0;
  border-top: 1px solid var(--giotto-border);
  text-align: center;
  color: var(--giotto-muted-foreground);
  font-size: 14px;
  line-height: 1.5;
}

.giotto-register-footer a {
  margin-left: 4px;
}

@media (max-width: 767px) {
  .giotto-register-footer {
    margin: 20px -24px 0;
    padding: 16px 24px 0;
  }
}
