/*
 * Lex AI brand theme for the Keycloak login pages.
 * Goal: a premium, modern, on-brand login (login / set-password / OTP /
 * verify-email) that bridges the marketing site (www.lex-ai.ro) and the
 * app (app.lex-ai.ro) — the same blue→purple gradient mark + accent, Inter
 * type, soft gradient backdrop and refined surfaces, in Romanian.
 *
 * Batch 7 (2026-06-05) — elevated from the previous flat app-aligned look
 * to match the marketing brand. Still layered on keycloak.v2 (PatternFly
 * v5) via CSS custom-property overrides + a few targeted rules; the
 * structure/pipeline (Dockerfile COPY themes/) is unchanged, so this is a
 * visual-only, low-risk upgrade. A full Keycloakify (React) migration
 * remains a separate, larger option if component-level control is needed.
 */

/* Self-hosted: naming Inter in font-family is not enough, it is not installed
   on a typical machine. latin-ext carries ă â î ș ț. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --lexai-brand: #2563eb;            /* marketing --brand   */
  --lexai-brand-2: #7a5cff;          /* marketing --brand-2 */
  --lexai-brand-strong: #1d4ed8;     /* hover / pressed     */
  --lexai-ring: rgba(37, 99, 235, 0.30);
  --lexai-ink: #11131a;
  --lexai-muted: #585f73;
  --lexai-border: #e6e8ee;
  --lexai-surface: #ffffff;
  --lexai-radius: 16px;

  /* Map PatternFly v5 primary tokens to the brand so default buttons/links
     pick it up without per-element overrides. */
  --pf-v5-global--primary-color--100: var(--lexai-brand);
  --pf-v5-global--primary-color--200: var(--lexai-brand-strong);
  --pf-v5-global--link--Color: var(--lexai-brand);
  --pf-v5-global--link--Color--hover: var(--lexai-brand-strong);
  --pf-v5-global--BorderRadius--sm: 10px;
}

/* Must target `body`: kcHtmlClass puts the classes on <html>, and keycloak.v2
   paints its own texture on the body (id="keycloak-bg"), over anything set
   on <html>. */
body,
body#keycloak-bg,
html.login-pf {
  background-color: #f6f7f9 !important;
  background-image:
    radial-gradient(60% 50% at 18% 0%, rgba(37, 99, 235, 0.12), transparent 70%),
    radial-gradient(55% 45% at 92% 8%, rgba(122, 92, 255, 0.12), transparent 70%) !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
  background-attachment: fixed !important;
}
.login-pf body {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  color: var(--lexai-ink);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}

/* Card / panel: white, generously rounded, layered soft shadow. */
.card-pf,
#kc-container .pf-v5-c-login__main,
.pf-v5-c-login__main {
  border: 1px solid var(--lexai-border);
  border-radius: var(--lexai-radius);
  box-shadow:
    0 1px 2px rgba(17, 19, 26, 0.04),
    0 18px 48px rgba(17, 19, 26, 0.10);
  background: var(--lexai-surface);
}

/* Brand lockup above the card: gradient "L" badge (with glow) + wordmark. */
#kc-header,
.pf-v5-c-login__header {
  text-align: center;
}
/* The wrapper holds the realm's displayNameHtml. `font-size: 0` does not
   collapse it — measured 69px of residual width — and in normal flow that
   width lands between the two images and blows the lockup apart. Both are
   positioned out of flow so the text can never move them; it stays in the DOM,
   invisible, for screen readers. The offsets centre the INK, not the boxes:
   the wordmark SVG carries ~7px of its own padding each side. */
#kc-header-wrapper {
  position: relative;
  display: block;
  height: 56px;
  margin: 28px 0 14px;
  font-size: 0;
  line-height: 0;
  color: transparent;
}
#kc-header-wrapper::before,
#kc-header-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  height: 56px;
}
#kc-header-wrapper::before {
  width: 56px;
  margin-left: -128px;
  border-radius: 16px;
  background: url("../img/mark.svg") center / cover no-repeat;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.35);
}
#kc-header-wrapper::after {
  width: 194px;
  margin-left: -60px;
  background: url("../img/wordmark.svg") center / contain no-repeat;
}

/* Primary button = brand gradient, rounded, with a subtle lift on hover. */
.pf-v5-c-button.pf-m-primary,
input[type="submit"].pf-m-primary,
#kc-login,
.btn-primary {
  background: linear-gradient(135deg, var(--lexai-brand), var(--lexai-brand-2)) !important;
  border: none !important;
  border-radius: 12px !important;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.28);
  transition: transform 0.2s cubic-bezier(0.16, 0.84, 0.44, 1), box-shadow 0.2s, filter 0.2s;
}
.pf-v5-c-button.pf-m-primary:hover,
#kc-login:hover,
.btn-primary:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.34);
}
.pf-v5-c-button.pf-m-primary:active,
#kc-login:active,
.btn-primary:active {
  transform: translateY(0) scale(0.99);
}

/* Inputs: rounded with a brand focus ring matching the app. */
.pf-v5-c-form-control,
input[type="text"],
input[type="password"],
input[type="email"] {
  border-radius: 11px !important;
}
.pf-v5-c-form-control:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
  outline: none !important;
  border-color: var(--lexai-brand) !important;
  box-shadow: 0 0 0 4px var(--lexai-ring) !important;
}

/* Social identity-provider buttons (logo height pinned so the Google "G"
 * can never render at its huge intrinsic size). Height-only keeps aspect
 * ratio, matching keycloak.v2's base behaviour. */
#kc-social-providers a[id^="social-"] svg {
  height: 18px;
  width: auto;
  max-height: 18px;
  flex: 0 0 auto;
}
#kc-social-providers a[id^="social-"] {
  border-radius: 11px;
}

/* Links + calmer helper text. */
a {
  color: var(--lexai-brand);
}
a:hover {
  color: var(--lexai-brand-strong);
}
#kc-info,
.pf-v5-c-login__main-footer {
  color: var(--lexai-muted);
}

/* ---- Dark mode (consistent with the app's dark/light/system) ----------
 * Follows the OS preference. Targeted overrides on the known PatternFly v5
 * login elements (not a blanket `*`) so contrast stays controlled. Same
 * brand gradient/mark as light. Preview in a running Keycloak to fine-tune
 * any edge element (alerts/validation) before relying on it. */
@media (prefers-color-scheme: dark) {
  body,
  body#keycloak-bg,
  html.login-pf {
    background-color: #06070b !important;
    background-image:
      radial-gradient(60% 50% at 18% 0%, rgba(37, 99, 235, 0.18), transparent 70%),
      radial-gradient(55% 45% at 92% 8%, rgba(122, 92, 255, 0.16), transparent 70%) !important;
  }
  .login-pf body {
    color: #e9ebf2;
  }
  .card-pf,
  #kc-container .pf-v5-c-login__main,
  .pf-v5-c-login__main {
    background: #0f1117;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 48px rgba(0, 0, 0, 0.55);
    color: #e9ebf2;
  }
  #kc-header-wrapper::after {
    background-image: url("../img/wordmark-dark.svg");
  }
  .pf-v5-c-login__main h1,
  .pf-v5-c-title,
  .pf-v5-c-form__label,
  .pf-v5-c-form__label-text,
  .pf-v5-c-form__group-label,
  .pf-v5-c-login__main-header-desc,
  label {
    color: #e9ebf2 !important;
  }
  .pf-v5-c-form-control,
  input[type="text"],
  input[type="password"],
  input[type="email"] {
    background: #0b0d13 !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
    color: #e9ebf2 !important;
  }
  .pf-v5-c-form-control::placeholder {
    color: #6b7280 !important;
  }
  #kc-info,
  .pf-v5-c-login__main-footer,
  .pf-v5-c-login__main-footer-band {
    color: #a6abbd;
  }
  a {
    color: #6f9bff;
  }
  a:hover {
    color: #8fb0ff;
  }
}
