/* ============================================================
   Eurofarma v3 — tela de cadastro (register.ftl)
   Tokens e estilos derivados 1:1 do prototipo (register.html).
   ============================================================ */
:root {
  /* palette */
  --bg:            #000000;
  --panel:         #222625;
  --field:         rgba(217, 217, 217, .20);
  --field-focus:   rgba(217, 217, 217, .30);
  --accent:        #63C0AD;   /* primary action            */
  --accent-strong: #4fb09c;
  --accent-soft:   #9ADECC;   /* headings / links          */
  --glow:          #69B2A0;   /* ambient background glow   */
  --divider:       #959F9C;
  --text:          #ffffff;
  --muted:         rgba(255, 255, 255, .45);
  --placeholder:   rgba(255, 255, 255, .30);
  --danger:        #ff6b6b;
  --ok:            var(--accent-soft);

  /* typography */
  --font-body:    "Open Sans", system-ui, sans-serif;
  --font-display: "Lufga", "Poppins", system-ui, sans-serif;
  --font-sub:     "Inter", system-ui, sans-serif;

  /* shape */
  --r-field: 0.75rem;
  --r-panel: 1.75rem;
  --r-check: 0.375rem;

  /* spacing scale */
  --gap: clamp(0.875rem, 1.5vw, 1rem);
  --pad-panel: clamp(1.25rem, 3vw, 2.5rem);
  --ctl-pad: clamp(0.8125rem, 1.1vw, 1rem);
  --touch: 2.75rem;

  /* fluid type */
  --fs-h1:   clamp(1.75rem, 3.4vw, 2.75rem);
  --fs-sub:  clamp(0.9375rem, 1.4vw, 1.125rem);
  --fs-label:clamp(0.8125rem, 1vw, 0.9375rem);
  --fs-ctl:  clamp(0.875rem, 1vw, 1rem);
}

/* ============================================================ RESET */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.45;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent-soft); }

/* vence regras globais de login.css (.login-pf body, html,body{height:100vh}, main{display:flex}) */
html { height: auto; }
.login-pf body, html.login-pf body { background: var(--bg); height: auto; min-height: 100dvh; }

/* ============================================================ AMBIENT GLOWS */
.bg-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.glow {
  position: absolute;
  border-radius: 50%;
  opacity: .55;
  filter: blur(2px);
  background: radial-gradient(circle at center, var(--glow) 0%, transparent 70%);
}
.glow--tl { width: 90vmin; height: 90vmin; top: -45vmin; left: -30vmin; }
.glow--br { width: 110vmin; height: 110vmin; bottom: -55vmin; left: 5%; }

/* ============================================================ LAYOUT */
.page {
  display: block;            /* anula main { display: flex } do login.css (corrige "3 colunas") */
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding: clamp(18px, 3vw, 32px) clamp(16px, 4vw, 28px) 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(20px, 3vw, 36px);
}
.brand img { height: clamp(1.875rem, 3.6vw, 2.75rem); width: auto; }

/* language switch */
.lang {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.lang select {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 0.5625rem;
  font-weight: 600;
  font-size: clamp(0.8125rem, 1.2vw, 0.9375rem);
  min-height: var(--touch);
  padding: 0 2rem 0 0.875rem;
  color-scheme: dark;
}
.lang::after {
  content: "";
  position: absolute;
  right: 0.8125rem;
  width: 0.625rem; height: 0.4375rem;
  pointer-events: none;
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* hero */
.hero { text-align: center; margin-bottom: clamp(22px, 3.4vw, 36px); }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-soft);
  font-size: var(--fs-h1);
  margin: 0 0 14px;
  letter-spacing: .2px;
}
.hero p {
  font-family: var(--font-sub);
  font-size: var(--fs-sub);
  color: var(--text);
  max-width: 60ch;
  margin: 0 auto;
}

/* card */
.card {
  background: var(--panel);
  border-radius: var(--r-panel);
  padding: var(--pad-panel);
  box-shadow: 9px 4px 23px 11px rgba(0,0,0,.25);
}

/* ============================================================ FORM */
.form { display: flex; flex-direction: column; gap: var(--gap); }

/* progressive-reveal wrapper: animates 0fr -> 1fr (no JS height math) */
.step {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transform: translateY(-6px);
  transition: grid-template-rows .42s ease, opacity .42s ease, transform .42s ease;
}
.step > .step__inner { overflow: hidden; min-height: 0; }
.step.is-visible { grid-template-rows: 1fr; opacity: 1; transform: none; }
.step:not(.is-visible) { margin: calc(var(--gap) * -.5) 0; }

.step__inner { display: flex; flex-direction: column; gap: var(--gap); padding-top: 2px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

/* a single field */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label {
  font-size: var(--fs-label);
  font-weight: 400;
  color: var(--text);
}
.req { color: var(--accent-soft); }

.control {
  width: 100%;
  min-height: var(--touch);
  background: var(--field);
  border: 1px solid transparent;
  border-radius: var(--r-field);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-ctl);
  padding: var(--ctl-pad) 1rem;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
  color-scheme: dark;
}
.control::placeholder { color: var(--placeholder); font-weight: 300; }
.control:focus {
  outline: none;
  background: var(--field-focus);
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(154, 222, 204, .18);
}

/* mostrar/ocultar senha ("olhinho") */
.pw-wrap { position: relative; }
.pw-wrap .control { padding-right: 3rem; }
.pw-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 3rem;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--placeholder);
  transition: color .2s ease;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle:focus-visible {
  outline: none;
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(154, 222, 204, .4);
  border-radius: var(--r-field);
}
.pw-toggle svg { width: 1.25rem; height: 1.25rem; display: block; }
.pw-toggle .icon-off { display: none; }
.pw-toggle[aria-pressed="true"] .icon-on { display: none; }
.pw-toggle[aria-pressed="true"] .icon-off { display: block; }

/* selects: custom chevron */
select.control {
  appearance: none;
  padding-right: 2.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='14' viewBox='0 0 22 14'%3E%3Cpath fill='%23ffffff' d='M1 1l10 11L21 1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 0.875rem 0.625rem;
  cursor: pointer;
}
select.control:disabled { opacity: .5; cursor: not-allowed; }

/* dropdown option contrast */
select.control,
.lang select { color-scheme: dark; }
select.control option,
.lang select option {
  background-color: #1b1f1e;
  color: #ffffff;
}
select.control option:disabled { color: var(--placeholder); }
select.control option:checked,
.lang select option:checked { background-color: #2f3a37; }

/* conditional fields toggled by the controller */
.field.is-hidden, .optin.is-hidden { display: none; }

/* invalid state */
.field.has-error .control { border-color: var(--danger); }
.error-msg {
  font-size: 0.8125rem;
  color: var(--danger);
  min-height: 0;
  display: none;
}
.field.has-error .error-msg { display: block; }
/* erros server-side do Keycloak: visiveis mesmo sem a classe has-error */
.error-msg[role="alert"]:not([hidden]) { display: block; }

/* password rules */
.rules { list-style: none; margin: 0.25rem 0 0; padding: 0; display: grid; gap: 0.375rem; }
.rules li {
  display: flex; align-items: center; gap: 0.625rem;
  font-size: var(--fs-ctl); color: var(--text);
  transition: color .2s ease;
}
.rules li .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.2em; font-weight: 800;
}
.rules li[data-pass="false"] .mark { color: var(--text); }
.rules li[data-pass="true"]  { color: var(--ok); }
.rules li[data-pass="true"] .mark::before { content: "\2713"; }
.rules li[data-pass="false"] .mark::before { content: "\2715"; }

/* checkbox (opt-in) */
.optin {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.875rem;
  align-items: start;
  position: relative;
  cursor: pointer;
  min-height: var(--touch);
  font-size: var(--fs-ctl);
  line-height: 1.45;
}
.optin input { position: absolute; opacity: 0; width: 0; height: 0; }
.optin .box {
  width: 1.75rem; height: 1.75rem;
  border-radius: var(--r-check);
  background: var(--field);
  display: grid; place-items: center;
  transition: background .2s ease, box-shadow .2s ease;
}
.optin:hover .box { background: var(--field-focus); }
.optin input:focus-visible + .box { box-shadow: 0 0 0 3px rgba(154,222,204,.4); }
.optin .box svg { width: 1rem; height: 1rem; opacity: 0; transition: opacity .15s ease; }
.optin input:checked + .box { background: var(--accent); }
.optin input:checked + .box svg { opacity: 1; }

/* submit */
.btn {
  width: 100%;
  min-height: var(--touch);
  border: none;
  border-radius: var(--r-field);
  padding: 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-ctl);
  color: #fff;
  background: var(--accent);
  transition: background .2s ease, transform .05s ease;
}
.btn:hover { background: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.foot { text-align: center; margin-top: 1.5rem; font-size: var(--fs-ctl); }
.foot a { font-weight: 700; text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* ============================================================ LOGIN SOCIAL (step 1)
   Mesmo bloco do login.ftl, reaproveitando os tokens desta pagina.
   Colapsa (mesma mecanica 1fr -> 0fr dos steps) quando o step 2 e revelado. */
.social-block {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 1.5rem;
  transition: grid-template-rows .42s ease, opacity .28s ease, margin-top .42s ease, visibility 0s;
}
.social-block > .social-block__inner { overflow: hidden; min-height: 0; }
.social-block.is-collapsed {
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
  visibility: hidden;                       /* tira os links do foco/tab order */
  transition: grid-template-rows .42s ease, opacity .28s ease, margin-top .42s ease, visibility 0s linear .42s;
}

.social-block .divider {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}
.social-block .divider::before,
.social-block .divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, .15);
}
.social-block .divider span {
  padding: 0 1em;
  font-size: 0.8em;
  color: var(--muted);
}

.social-buttons { display: flex; flex-direction: column; gap: 0.8rem; }

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1em;
  width: 100%;
  min-height: var(--touch);
  padding: 0.9em;
  border-radius: var(--r-field);
  font-size: var(--fs-ctl);
  font-family: var(--font-body);
  background: transparent;
  text-decoration: none;
  color: var(--text);
  transition: background .2s ease, transform .2s ease;
}
.btn-social:hover { text-decoration: none; }
.btn-social:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(154, 222, 204, .4);
}

.btn-google {
  background: var(--field);
  border: 1px solid #fff;
  font-weight: 700;
}
.btn-google:hover { background: var(--field-focus); transform: translateY(-1px); }

.btn-eurofarma {
  border: 1px solid var(--accent-soft);
  padding-inline: 1.5em;
}
.btn-eurofarma:hover { background: rgba(154, 222, 204, .05); transform: translateY(-1px); }
.btn-eurofarma .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
}
.btn-eurofarma .text-group { display: flex; flex-direction: column; text-align: left; flex: 1; }
.btn-eurofarma .text-group .title { color: var(--accent-soft); font-size: 0.95em; font-weight: 600; line-height: 1.2; }
.btn-eurofarma .text-group .sub { font-size: 0.75em; color: var(--text); }

/* ============================================================ RESPONSIVE */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  :root { --pad-panel: 1.125rem; }
  .topbar { margin-bottom: 1.25rem; }
  .btn-eurofarma { padding-inline: 0.5em; }
}

@media (pointer: coarse) {
  .control, .btn, .lang select { min-height: 3rem; }
  .optin { min-height: 3rem; }
}

@media (min-width: 1600px) {
  .page { max-width: 820px; }
}

@media (prefers-reduced-motion: reduce) {
  .step, .social-block { transition: none; }
  * { scroll-behavior: auto; }
}

/* height-aware compacting */
@media (max-height: 860px) {
  :root { --pad-panel: clamp(1rem, 2.4vw, 1.75rem); --gap: 0.8125rem; }
  .page { padding-top: 0.75rem; }
  .topbar { margin-bottom: 0.75rem; }
  .hero { margin-bottom: 0.9rem; }
  .hero h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: 0.35rem; }
  .hero p { font-size: clamp(0.8rem, 1.2vw, 0.95rem); line-height: 1.4; }
}
@media (max-height: 720px) {
  .hero h1 { font-size: 1.55rem; }
  .hero p  { font-size: 0.8rem; line-height: 1.32; }
  .hero { margin-bottom: 0.55rem; }
  .field { gap: 6px; }
}

/* inline boolean (residente) */
.optin--inline { align-items: center; min-height: auto; }

/* readonly fields */
.control[readonly] { opacity: .65; cursor: not-allowed; }

/* termos de aceite (register-commons) herdam o estilo de optin */
#kc-registration-terms-text { font-size: var(--fs-ctl); }
#kc-registration-terms-text a { font-weight: 600; }
