html,
body {
  background-image: url("../img/logo.svg");
  background-size: 65%;
  background-position: center;
  background-repeat: no-repeat;
  height: 100%;
  font-family: "Numans", sans-serif;
  /* Scale down on smaller panels; 18px at ~4K, 14px at 1280px and below */
  font-size: clamp(14px, calc(14px + 4 * (100vw - 1280px) / 2560), 18px);
}

/* Keep background logo from shrinking too much on narrow screens: fixed width per breakpoint */
@media (max-width: 2000px) {
  html,
  body {
    background-size: 1500px auto !important;
  }
}

@media (max-width: 600px) {
  html,
  body {
    background-size: 360px auto !important;
  }
}

@media (max-width: 400px) {
  html,
  body {
    background-size: 300px auto !important;
  }
}

/* Card wraps all login content (header, form, social, registration) */
body > div:first-child {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 320px;
  max-width: min(520px, 92vw);
  width: 90%;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 14px;
  padding: clamp(1.25rem, 4vw, 3rem);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.14);
}

body > div:first-child > div:last-child {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.flex-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.flex-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0rem;
  width: 100%;
}

.gap-1 {
  gap: 1rem;
}

#kc-header {
  display: none;
}

/* ── Locale selector ────────────────────────────────────────────────── */
#kc-locale {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

#kc-locale-wrapper {
  position: relative;
}

#kc-locale-dropdown > a,
#kc-locale-dropdown > button {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
  box-sizing: border-box;
}

#kc-locale-dropdown > a::before,
#kc-locale-dropdown > button::before {
  font-size: 1rem;
  line-height: 1;
}

html[lang^="fr"] #kc-current-locale-link::before {
  content: "🇫🇷";
}

html[lang^="en"] #kc-current-locale-link::before {
  content: "🇬🇧";
}

#kc-locale-dropdown > a:hover,
#kc-locale-dropdown > button:hover {
  background: #fff;
  border-color: #bbb;
  color: #333;
}

#kc-locale-dropdown ul {
  display: none;
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 100%;
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  animation: kc-locale-fade-in 0.12s ease-out;
}

@keyframes kc-locale-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

#kc-locale-dropdown:focus-within ul {
  display: block;
}

#kc-locale-dropdown ul li {
  margin: 0;
}

#kc-locale-dropdown ul li a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  color: #333;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.1s;
}

#kc-locale-dropdown ul li a[href*="kc_locale=fr"]::before {
  content: "🇫🇷";
  font-size: 1rem;
  line-height: 1;
}

#kc-locale-dropdown ul li a[href*="kc_locale=en"]::before {
  content: "🇬🇧";
  font-size: 1rem;
  line-height: 1;
}

#kc-locale-dropdown ul li a:hover {
  background: #f0f4ff;
  color: #0066cc;
  text-decoration: none;
}

div:has(> label) {
  margin-bottom: 0.5rem;
}

/* Page title (Sign in to your account) – scales with viewport */
body > div:first-child #kc-page-title,
body > div:first-child #kc-header-wrapper,
body > div:first-child h1 {
  font-size: clamp(1.35rem, 2.5vw + 1rem, 1.75rem);
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 1.5rem;
  text-align: center;
}

/* Login form container – no card, just layout */
#kc-form {
  width: 100%;
}

#kc-form-wrapper {
  padding: 0;
}

#kc-content-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  width: 100%;
  flex: 1;
  gap: 1rem;
}

/* Form groups (username, password, OTP forms) */
#kc-form-login .pf-c-form__group,
#kc-form-login [class*="form__group"],
#kc-otp-login-form .pf-c-form__group,
#kc-otp-login-form [class*="form__group"],
#kc-totp-settings-form .pf-c-form__group,
#kc-totp-settings-form [class*="form__group"],
#kc-otp-reset-form .pf-c-form__group,
#kc-otp-reset-form [class*="form__group"] {
  margin-bottom: 1.875rem;
}

/* Extra space between username field and password label */
#kc-username-group {
  margin-bottom: 1.5rem;
}

#kc-username {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 0.5rem;
}

#kc-attempted-username {
  font-size: 1.25rem;
}

#kc-form-login .pf-c-form__group:last-of-type {
  margin-bottom: 0;
}

/* Labels (login + OTP forms) */
#kc-form label,
#kc-otp-login-form label,
#kc-totp-settings-form label,
#kc-otp-reset-form label {
  display: block;
  font-weight: 600;
  font-size: 1.1rem;
  color: #333;
  margin-bottom: 0.75rem;
}

/* Text and password inputs (login + OTP forms) */
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.0625rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  box-sizing: border-box;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
  color: #999;
}

/* Password input group (with visibility toggle) */
#kc-password-group,
#kc-password-new-group,
#kc-password-confirm-group,
#kc-form .pf-c-input-group,
#kc-form [class*="input-group"],
#kc-update-password-form [class*="input-group"] {
  display: flex;
  align-items: stretch;
}

#kc-password-group #password,
#kc-password-new-group #password-new,
#kc-password-confirm-group #password-confirm,
#kc-form .pf-c-input-group input,
#kc-form [class*="input-group"] input,
#kc-update-password-form [class*="input-group"] input {
  flex: 1;
  min-width: 0;
  width: auto;
  border-radius: 8px 0 0 8px;
}

button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.875rem;
  min-width: 2.75rem;
  border: 1px solid #ccc;
  border-left: none;
  border-radius: 0 8px 8px 0;
  background: #f5f5f5;
  cursor: pointer;
}

button:hover {
  background: #ebebeb;
}

/* Visibility icon (show/hide password) – use theme img */
#kc-password-group button .kc-password-visibility-icon,
#kc-password-new-group button .kc-password-visibility-icon,
#kc-password-confirm-group button .kc-password-visibility-icon,
#kc-form [class*="input-group"] button .kc-password-visibility-icon,
#kc-update-password-form
  [class*="input-group"]
  button
  .kc-password-visibility-icon {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

#kc-password-group button i,
#kc-password-new-group button i,
#kc-password-confirm-group button i,
#kc-form [class*="input-group"] button i,
#kc-update-password-form [class*="input-group"] button i {
  display: none;
}

/* Options row (remember me + forgot password) */
#kc-form-options {
  margin-bottom: 0.75rem;
}

#kc-form .checkbox label {
  font-weight: 400;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

#kc-form .checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

#kc-form a,
#kc-otp-login-form a,
#kc-totp-settings-form a,
#kc-otp-reset-form a {
  color: #0066cc;
  text-decoration: none;
  font-size: 1rem;
}

#kc-form a:hover,
#kc-otp-login-form a:hover,
#kc-totp-settings-form a:hover,
#kc-otp-reset-form a:hover {
  text-decoration: underline;
}

/* Error message (login + OTP forms) */
#kc-form #input-error,
#kc-form [id^="input-error"],
#kc-otp-login-form #input-error,
#kc-otp-login-form [id^="input-error"],
#kc-totp-settings-form #input-error,
#kc-totp-settings-form [id^="input-error"],
#kc-otp-reset-form #input-error,
#kc-otp-reset-form [id^="input-error"] {
  display: block;
  font-size: 1rem;
  color: #c00;
  margin-top: 0.75rem;
}

/* Submit button */
#kc-form-buttons {
  margin-top: 2rem;
}

input[type="submit"],
#kc-form #kc-login,
#kc-otp-login-form #kc-login,
#kc-totp-settings-form #saveTOTPBtn,
#kc-otp-reset-form #kc-otp-reset-form-submit {
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-size: 1.0625rem;
  font-weight: 600;
  color: #fff;
  background: #0066cc;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

#kc-form input[type="submit"]:hover,
#kc-form #kc-login:hover,
#kc-otp-login-form input[type="submit"]:hover,
#kc-otp-login-form #kc-login:hover,
#kc-totp-settings-form input[type="submit"]:hover,
#kc-totp-settings-form #saveTOTPBtn:hover,
#kc-otp-reset-form input[type="submit"]:hover,
#kc-otp-reset-form #kc-otp-reset-form-submit:hover {
  background: #0052a3;
}

#kc-form input[type="submit"]:focus,
#kc-form #kc-login:focus,
#kc-otp-login-form input[type="submit"]:focus,
#kc-otp-login-form #kc-login:focus,
#kc-totp-settings-form input[type="submit"]:focus,
#kc-totp-settings-form #saveTOTPBtn:focus,
#kc-otp-reset-form input[type="submit"]:focus,
#kc-otp-reset-form #kc-otp-reset-form-submit:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
}

/* Registration link (No account? Register) */
#kc-registration-container {
  margin-top: 1.25rem;
  text-align: center;
}

#kc-registration {
  font-size: 1rem;
  color: #444;
}

#kc-registration a {
  font-size: 1rem;
}

/* Social providers (Sign in with Google, etc.) */
#kc-social-providers {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
}

#kc-social-providers hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 0 0 1.25rem;
}

#kc-social-providers h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  margin: 0 0 1rem;
  text-align: center;
}

#kc-social-providers ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

/* Social provider buttons */
#kc-social-providers a[href] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  font-size: 1.0625rem;
  font-weight: 500;
  color: #1a1a1a;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  text-decoration: none;
  transition:
    background 0.2s,
    border-color 0.2s;
  box-sizing: border-box;
}

#kc-social-providers a[href]:hover {
  background: #f8f8f8;
  border-color: #999;
  text-decoration: none;
}

/* Google sign-in: use provided logo instead of default icon */
#social-google i {
  display: none;
}

#social-google::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 22px;
  background: url("../img/google-logo.svg") center / contain no-repeat;
  flex-shrink: 0;
}

#kc-totp-secret-qr-code {
  margin-left: 95px;
}

/* Multi-digit OTP/TOTP inputs */
.otp-inputs {
  display: flex;
  gap: 0.625rem;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.otp-inputs .otp-digit {
  width: 3.5rem;
  min-width: 3.5rem;
  max-width: 4rem;
  min-height: 4rem;
  padding: 1.25rem 0;
  font-size: 2rem !important;
  font-weight: 600;
  text-align: center;
  border: 2px solid #ccc;
  border-radius: 10px;
  box-sizing: border-box;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.otp-inputs .otp-digit:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

.otp-inputs[aria-invalid="true"] .otp-digit {
  border-color: #c00;
}

.otp-inputs[aria-invalid="true"] .otp-digit:focus {
  border-color: #c00;
  box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.15);
}

.alert-error {
  color: #c00;
  background-color: #ffe6e6;
  border: 1px solid #c00;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

/* Live password policy checklist */
.password-rules {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #fff;
  transition:
    background 0.25s ease,
    border-color 0.25s ease;
}

.password-rules.is-complete {
  border-color: #a8d5ad;
  background: #f4fbf5;
}

.password-rules-title {
  margin: 0 0 0.75rem;
  color: #666;
  font-size: 0.95rem;
  font-weight: 600;
}

.password-rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.password-rule {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.25rem;
  color: #666;
  font-size: 0.95rem;
  line-height: 1.3;
  transition:
    color 0.2s ease,
    opacity 0.2s ease;
}

.password-rule.is-valid {
  color: #2e7d32;
  font-weight: 500;
  opacity: 0.86;
}

.password-rule-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  flex: 0 0 1.25rem;
  background: rgba(211, 47, 47, 0.1);
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.password-rule-icon::before,
.password-rule-icon::after {
  content: "";
  position: absolute;
  width: 0.58rem;
  height: 0.12rem;
  border-radius: 999px;
  background: #d32f2f;
}

.password-rule-icon::before {
  transform: rotate(45deg);
}

.password-rule-icon::after {
  transform: rotate(-45deg);
}

.password-rule.is-valid .password-rule-icon {
  background: rgba(46, 125, 50, 0.15);
}

.password-rule.is-valid .password-rule-icon::before {
  width: 0.38rem;
  height: 0.12rem;
  transform: translate(-0.18rem, 0.08rem) rotate(45deg);
  background: #2e7d32;
}

.password-rule.is-valid .password-rule-icon::after {
  width: 0.7rem;
  height: 0.12rem;
  transform: translate(0.13rem, 0) rotate(-45deg);
  background: #2e7d32;
}

.password-rule-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.password-rule-info {
  min-width: 1rem;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: #555;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.password-rule-info:hover,
.password-rule-info:focus {
  background: rgba(0, 0, 0, 0.06);
  outline: none;
}

.password-rule-info:focus-visible {
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

.password-rule-tooltip-content {
  position: absolute;
  right: -0.75rem;
  bottom: calc(100% + 0.5rem);
  z-index: 2;
  width: min(17.5rem, 72vw);
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  background: #1f2933;
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.25rem);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}

.password-rule-tooltip-content code {
  display: block;
  margin-top: 0.4rem;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}

.password-rule-tooltip:hover .password-rule-tooltip-content,
.password-rule-info:focus + .password-rule-tooltip-content {
  opacity: 1;
  transform: translateY(0);
}
