/*
 * This theme extends keycloak.v2. Keep generic controls in the parent theme so
 * Keycloak owns their sizing, focus appearance, accessibility, and upgrades.
 * The rules below are intentionally limited to Sevocity branding and markup
 * introduced by this theme's custom FreeMarker templates.
 */

:root {
  --sevocity-navy: #0b2f6b;
  --sevocity-blue: #0868c7;
  --sevocity-teal: #18bfd0;
  --sevocity-green: #67c644;
  --sevocity-ink: #17233a;
  --sevocity-muted: #62708a;
  --sevocity-surface-muted: #f6f9fc;
  --sevocity-border: #d9e2ee;
}

/* Brand the otherwise-neutral v2 page background with Sevocity's teal/green palette. */
body#keycloak-bg {
  color: var(--sevocity-ink);
  background:
    radial-gradient(circle at 18% 8%, rgb(24 191 208 / 14%), transparent 26rem),
    radial-gradient(circle at 84% 88%, rgb(103 198 68 / 12%), transparent 30rem),
    linear-gradient(145deg, #f8fbfe 0%, #edf3f8 100%);
}

/* Keep keycloak.v2's default card width; the wider 38rem override was intentionally removed. */

/* Build the horizontal Sevocity mark + lowercase wordmark from the stock v2 header slot. */
#kc-header-wrapper {
  display: block;
  width: min(100%, 40rem);
  min-height: 11rem;
  margin: 0 auto .5rem;
  padding: 1.05rem 0 0 12rem;
  color: var(--sevocity-navy) !important;
  font-size: clamp(3.5rem, 6vw, 4.8rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1;
  text-align: left;
  /* keycloak.v2 uppercases this slot; the registered Sevocity wordmark is lowercase. */
  text-transform: none;
  background: url("../img/sevocity-logo.png") left center / 10rem auto no-repeat;
}

/* The parent theme identifies Sevocity's platform; child themes replace this with their product name. */
#kc-header-wrapper::after {
  content: "CUSTOM EHR SOLUTIONS™";
  display: block;
  margin-top: .35rem;
  color: var(--sevocity-teal);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.4;
}

/* The message bundle supplies the registered mark; native superscript alignment keeps it close to the final letter. */
#kc-header-wrapper sup {
  margin-left: .06em;
  font-size: .38em;
  line-height: 0;
  vertical-align: super;
}

/* Use the Sevocity tri-color rule as the single brand accent on the v2 card. */
.pf-v5-c-login__main {
  position: relative;
  overflow: hidden;
  border: 1px solid rgb(217 226 238 / 88%);
  border-radius: 1rem;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 1.5rem 3.5rem rgb(15 38 70 / 13%);
}

.pf-v5-c-login__main::before {
  position: absolute;
  inset: 0 0 auto;
  height: .25rem;
  content: "";
  background: linear-gradient(90deg, var(--sevocity-navy) 0 58%, var(--sevocity-teal) 58% 78%, var(--sevocity-green) 78% 100%);
}

/* Compact the inherited v2 card around the wider Sevocity form, per the requested vertical rhythm. */
.pf-v5-c-login__main-header {
  display: block;
  padding: 2rem 3rem .4rem;
  border: 0;
}

#kc-page-title {
  color: var(--sevocity-ink);
  font-size: clamp(1.8rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1.15;
}

.pf-v5-c-login__main-header-utilities {
  margin-top: .75rem;
}

.pf-v5-c-login__main-body {
  padding: 1rem 3rem 1.75rem;
}

.pf-v5-c-form__group {
  margin-bottom: .85rem;
}

/* The requested 1rem labels improve readability without changing the v2 input control itself. */
.pf-v5-c-form__label-text {
  color: var(--sevocity-ink);
  font-size: 1rem;
  font-weight: 650;
}

/* Password rules are a list, not the parent theme's horizontal helper/action row. */
.sevocity-password-policy {
  display: grid;
  gap: .25rem;
  margin: .5rem 0 0;
  padding-left: 1.25rem;
  color: var(--sevocity-muted);
  font-size: .875rem;
  line-height: 1.5;
  list-style: disc;
}

/* Keycloak v2 renders this reset-navigation action as a secondary button; it is navigation, so present it as a link. */
#kc-reset-password-form .pf-v5-c-form__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}

#kc-reset-password-form .pf-v5-c-form__actions .pf-v5-c-button {
  width: 100%;
}

#kc-reset-password-form .pf-v5-c-form__actions .pf-v5-c-button.pf-m-secondary {
  width: auto;
  min-height: auto;
  padding: .25rem .5rem;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--sevocity-blue);
}

#kc-reset-password-form .pf-v5-c-form__actions .pf-v5-c-button.pf-m-secondary:hover {
  text-decoration: underline;
}

/* This helper is custom login.ftl content, not a v2 component; keep the clinic-assistance text legible and quiet. */
.sevocity-login-help {
  margin: 0 0 1rem;
  color: var(--sevocity-muted);
  font-size: 1rem;
  line-height: 1.5;
}

/* These classes belong to the custom authorization-picker templates and give grouped scopes a readable hierarchy. */
#kc-terms-text {
  display: grid;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.kc-scope-group {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--sevocity-border);
  border-radius: .75rem;
  background: var(--sevocity-surface-muted);
}

.kc-scope-group h3 {
  margin: 0 0 .35rem;
  color: var(--sevocity-navy);
  font-size: .9375rem;
}

.kc-scope-group p {
  margin: 0 0 .75rem;
  color: var(--sevocity-muted);
  font-size: .875rem;
  line-height: 1.45;
}

.kc-scope-option {
  margin: .6rem 0;
}

.kc-scope-option label,
.sevocity-choice {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  padding: .15rem 0;
  color: var(--sevocity-ink);
  line-height: 1.35;
}

.kc-scope-option input,
.sevocity-choice input {
  margin-top: .2rem;
  accent-color: var(--sevocity-blue);
}

/* The MFA method picker remains a normal form control while making its single choice easy to scan. */
.sevocity-mfa-picker {
  display: grid;
  gap: .75rem;
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
}

.sevocity-mfa-picker legend {
  margin-bottom: .5rem;
  color: var(--sevocity-ink);
  font-weight: 650;
}

.sevocity-mfa-method-card {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid var(--sevocity-border);
  border-radius: .75rem;
  background: var(--sevocity-surface-muted);
  color: var(--sevocity-ink);
  cursor: pointer;
}

.sevocity-mfa-method-card:has(input:focus-visible) {
  outline: 3px solid var(--sevocity-blue);
  outline-offset: 2px;
}

.sevocity-mfa-method-card input {
  margin-top: .25rem;
  accent-color: var(--sevocity-blue);
}

.sevocity-mfa-method-card span span {
  display: block;
  margin-top: .2rem;
  color: var(--sevocity-muted);
  line-height: 1.4;
}

/* Flatpickr makes its alternate DOB input readonly; retain a normal input surface so it does not look disabled. */
.flatpickr-input[readonly] {
  background-color: #fff;
}

@media (max-width: 480px) {
  /* The desktop wordmark uses a horizontal lockup; shrink it to avoid overflow on narrow screens. */
  #kc-header-wrapper {
    margin-bottom: .5rem;
    min-height: 7rem;
    padding: .65rem 0 0 7.25rem;
    font-size: clamp(2.25rem, 12vw, 3rem);
    background-size: 6rem auto;
  }

  #kc-header-wrapper::after {
    margin-top: .2rem;
    font-size: .875rem;
  }

  /* Preserve usable card padding after widening the desktop layout. */
  .pf-v5-c-login__main-header {
    padding: 1.5rem 1.25rem .25rem;
  }

  .pf-v5-c-login__main-body {
    padding: .75rem 1.25rem 1.25rem;
  }
}
