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

:root {
  --nuggy-cream: #fffdf6;
  --nuggy-graphite: #222222;
  --nuggy-green: #006644;
  --nuggy-green-hover: #005238;
  --nuggy-muted: #5a6662;
  --nuggy-border: #d9d3c6;
  --nuggy-focus: #008456;
  --nuggy-warn: #eeaf00;
  --nuggy-ui: Urbanist, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --nuggy-heading: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --nuggy-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

html,
body.login-pf {
  min-height: 100%;
  font-family: var(--nuggy-ui);
}

body.login-pf button,
body.login-pf input,
body.login-pf select,
body.login-pf textarea {
  font-family: var(--nuggy-ui);
}

.login-pf-page {
  min-height: 100vh;
  display: grid;
  padding: 0;
  background: #fffdf6;
  color: var(--nuggy-graphite);
  font-family: var(--nuggy-ui);
}

body.login-pf {
  background: var(--nuggy-cream);
  color: var(--nuggy-graphite);
}

#kc-header {
  display: none;
}

.login-pf-header,
.login-pf-signup {
  display: none !important;
}

#kc-info:empty,
#kc-info-wrapper:empty {
  display: none !important;
}

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

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

.login-pf-page .card-pf {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

/* Keycloak 26 often has no #kc-form-wrapper; form lives in #kc-content-wrapper. */
.login-pf-page .card-pf #kc-form-wrapper,
.login-pf-page .card-pf #kc-content-wrapper {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 54px 52px 52px;
  box-sizing: border-box;
}

/* Split layout: leave the narrow wrapper so the grid is full-width (original nuggy behavior). */
.login-pf-page .card-pf #kc-form-wrapper:has(.nuggy-login-layout),
.login-pf-page .card-pf #kc-content-wrapper:has(.nuggy-login-layout) {
  max-width: none;
  margin: 0;
  padding: 0;
}

#kc-content:has(.nuggy-login-layout) {
  justify-content: stretch;
}

/* Use % and fr — not 100vw/50vw — so the page does not gain a horizontal scrollbar. */
.nuggy-login-layout {
  width: 100%;
  min-height: 100vh;
  background: transparent;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  box-sizing: border-box;
}

.nuggy-auth-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 16px;
  padding: 54px 52px 52px;
  background: #fffdf6;
  max-width: 520px;
  width: 100%;
  justify-self: center;
  min-height: 100vh;
  box-sizing: border-box;
}

@media (min-width: 901px) {
  .nuggy-auth-panel .nuggy-back-home {
    order: -1;
    align-self: flex-start;
    margin-bottom: 4px;
  }

  .nuggy-logo,
  .nuggy-welcome {
    align-self: flex-start;
  }

  .nuggy-welcome {
    font-size: 24px;
  }

  .nuggy-mobile-help {
    display: none;
  }
}

.nuggy-back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--nuggy-muted);
  text-decoration: none;
  font-size: 14px;
}

.nuggy-back-home:hover {
  text-decoration: underline;
}

.nuggy-back-icon {
  flex: 0 0 auto;
}

.nuggy-logo {
  width: 132px;
  height: auto;
  display: block;
  margin: 0;
}

.nuggy-welcome {
  margin: 0;
  font-family: var(--nuggy-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--nuggy-graphite);
}

.nuggy-reset-hint {
  margin: -4px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--nuggy-muted);
}

.nuggy-logout-hint {
  margin: -4px 0 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--nuggy-muted);
}

input.nuggy-button[type="submit"] {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 14px;
}

.nuggy-mobile-help {
  display: none;
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--nuggy-muted);
}

.nuggy-mobile-help a {
  color: var(--nuggy-green);
  text-decoration: none;
}

.nuggy-mobile-help a:hover {
  text-decoration: underline;
}

.nuggy-login-form {
  display: grid;
  gap: 14px;
  margin-top: 0;
}

.nuggy-field-group {
  display: grid;
  gap: 6px;
}

.nuggy-password-row {
  position: relative;
}

.nuggy-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--nuggy-border);
  border-radius: 12px;
  background: #fff;
  color: var(--nuggy-graphite);
  padding: 10px 12px;
  font-size: 14px;
}

.nuggy-password-row .nuggy-input {
  padding-right: 74px;
}

.nuggy-input:focus {
  outline: 2px solid var(--nuggy-focus);
  outline-offset: 1px;
  border-color: var(--nuggy-focus);
}

.nuggy-password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--nuggy-green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.nuggy-password-toggle:hover {
  text-decoration: underline;
}

.nuggy-checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--nuggy-muted);
}

.nuggy-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--nuggy-green);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.nuggy-button:hover {
  background: var(--nuggy-green-hover);
}

.nuggy-button:focus-visible {
  outline: 2px solid var(--nuggy-focus);
  outline-offset: 2px;
}

.nuggy-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.nuggy-links a {
  color: var(--nuggy-green);
  text-decoration: none;
}

.nuggy-links a:hover {
  text-decoration: underline;
}

.nuggy-links--single {
  justify-content: center;
}

.nuggy-button--secondary {
  background: transparent;
  color: var(--nuggy-green);
  border: 1px solid var(--nuggy-border);
}

.nuggy-button--secondary:hover {
  background: rgba(0, 102, 68, 0.06);
}

.nuggy-login-form #kc-form-options {
  margin: 0;
}

.nuggy-login-form #kc-form-options .checkbox label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--nuggy-muted);
  cursor: pointer;
}

.nuggy-error {
  color: #9d2a2a;
  font-size: 12px;
}

/* In-column realm messages (replaces default Keycloak alerts above the split layout). */
.nuggy-flash {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.nuggy-flash--success {
  background: rgba(0, 102, 68, 0.1);
  color: var(--nuggy-green);
  border: 1px solid rgba(0, 102, 68, 0.2);
}

.nuggy-flash--error {
  background: rgba(157, 42, 42, 0.08);
  color: #9d2a2a;
  border: 1px solid rgba(157, 42, 42, 0.2);
}

.nuggy-flash--warning {
  background: rgba(238, 175, 0, 0.12);
  color: #6b5200;
  border: 1px solid rgba(238, 175, 0, 0.45);
}

.nuggy-flash--info {
  background: rgba(0, 102, 68, 0.06);
  color: var(--nuggy-graphite);
  border: 1px solid var(--nuggy-border);
}

.nuggy-text-block {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--nuggy-graphite);
}

.nuggy-text-block + .nuggy-text-block {
  margin-top: 12px;
}

.nuggy-info-body .nuggy-links {
  margin-top: 8px;
}

.nuggy-verify-email-followup {
  margin-top: 4px;
}

.nuggy-trace-id {
  font-family: var(--nuggy-mono);
  font-size: 13px;
  color: var(--nuggy-muted);
}

body.login-pf h1.nuggy-welcome {
  font-family: var(--nuggy-heading);
}

#kc-content .alert,
.pf-c-alert,
.kc-feedback-text {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
}

#kc-content .alert-success,
.pf-c-alert.pf-m-success {
  background: rgba(0, 102, 68, 0.1);
  color: var(--nuggy-green);
  border: 1px solid rgba(0, 102, 68, 0.2);
}

#kc-content .alert-error,
#kc-content .alert-warning,
.pf-c-alert.pf-m-danger,
.pf-c-alert.pf-m-warning {
  background: rgba(157, 42, 42, 0.08);
  color: #9d2a2a;
  border: 1px solid rgba(157, 42, 42, 0.2);
}

/* Fallback when Keycloak default reset markup renders without custom classes */
#kc-reset-password-form,
#kc-passwd-update-form {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

#kc-reset-password-form label,
#kc-passwd-update-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--nuggy-graphite);
}

#kc-reset-password-form input[type="text"],
#kc-reset-password-form input[type="password"],
#kc-passwd-update-form input[type="password"],
#kc-reset-password-form input[type="submit"],
#kc-passwd-update-form input[type="submit"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--nuggy-border);
  border-radius: 12px;
  background: #fff;
  color: var(--nuggy-graphite);
  padding: 10px 12px;
  font-size: 14px;
}

#kc-reset-password-form input[type="submit"],
#kc-passwd-update-form input[type="submit"] {
  border: 0;
  background: var(--nuggy-green);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

#kc-form-options a,
#kc-reset-password-form a {
  color: var(--nuggy-green);
  text-decoration: none;
  font-size: 13px;
}

#kc-form-options a:hover,
#kc-reset-password-form a:hover {
  text-decoration: underline;
}

.nuggy-visual-panel {
  min-width: 0;
  background-color: #006644;
  background-image: url("../img/background_login.png");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  min-height: 100vh;
}

@media (max-width: 900px) {
  .login-pf-page {
    padding: 0;
  }

  .login-pf-page .card-pf {
    width: 100%;
    max-width: none;
  }

  #kc-content {
    align-items: stretch;
  }

  .nuggy-login-layout {
    width: 100%;
    min-height: 100dvh;
    min-height: 100vh;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
    display: block;
    overflow: visible;
    background: #fffdf6;
  }

  .nuggy-auth-panel {
    box-sizing: border-box;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
    min-height: 100dvh;
    min-height: 100vh;
    justify-content: center;
    align-items: center;
    gap: 20px;
  }

  .nuggy-logo {
    width: 148px;
    margin: 0 auto;
  }

  .nuggy-welcome {
    width: 100%;
    max-width: 360px;
    text-align: center;
    font-size: 32px;
    font-weight: 700;
  }

  .nuggy-flash {
    text-align: center;
    max-width: 360px;
    width: 100%;
    align-self: center;
  }

  .nuggy-info-body {
    width: 100%;
    max-width: 360px;
    text-align: center;
  }

  .nuggy-info-body .nuggy-text-block {
    text-align: center;
  }

  .nuggy-login-form {
    width: 100%;
    max-width: 360px;
    gap: 16px;
  }

  .nuggy-field-group {
    width: 100%;
  }

  .nuggy-input {
    border-radius: 10px;
    font-size: 16px;
  }

  .nuggy-button {
    border-radius: 10px;
    font-size: 16px;
  }

  .nuggy-checkline {
    justify-content: center;
    width: 100%;
  }

  .nuggy-links {
    justify-content: space-between;
    width: 100%;
    max-width: 360px;
  }

  .nuggy-back-home {
    justify-content: center;
    width: 100%;
    margin-top: 4px;
    font-size: 15px;
  }

  .nuggy-mobile-help {
    display: block;
    width: 100%;
    max-width: 360px;
  }

  .nuggy-reset-hint {
    text-align: center;
    max-width: 360px;
    width: 100%;
  }

  .nuggy-logout-hint {
    text-align: center;
    max-width: 360px;
    width: 100%;
  }

  .nuggy-visual-panel {
    display: none;
  }
}
