/*
 * Tema de login Rezende Fiscal — design system v1 (out/2026).
 * Tokens iguais aos do front (frontend/src/app/globals.css). Sem PatternFly.
 * Claro por padrão; escuro segue o sistema operacional (prefers-color-scheme).
 * Vermelho da marca (#FF3E35) só no logo; erro usa danger, sempre com texto.
 */
:root {
  --surface: #F6F7FB;
  --surface-raised: #FFFFFF;
  --surface-sunken: #EEF0F6;
  --line: #DDE0EC;
  --line-strong: #8A90B3;
  --ink: #1B2042;
  --ink-muted: #5A6185;
  --primary: #333D74;
  --primary-hover: #283062;
  --on-primary: #FFFFFF;
  --primary-soft: #E5E8F3;
  --brand-navy: #333D74;
  --success: #0F7A55; --success-soft: #E6F4EE;
  --warning: #9A5B00; --warning-soft: #FFF4E0;
  --danger: #B42318;  --danger-soft: #FDECEA;
  --info: #2B5FB8;    --info-soft: #E8EFFB;
  --shadow-sm: 0 1px 2px rgba(27, 32, 66, 0.08);
  --shadow-overlay: 0 8px 24px rgba(27, 32, 66, 0.16);
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Montserrat", "IBM Plex Sans", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #12152B;
    --surface-raised: #1B1F3A;
    --surface-sunken: #0D1022;
    --line: #2E3459;
    --line-strong: #6E76A8;
    --ink: #EEF0F8;
    --ink-muted: #A3A9C7;
    --primary: #AEB6EA;
    --primary-hover: #C5CBF0;
    --on-primary: #12152B;
    --primary-soft: #262B4A;
    --success: #4ED6A0; --success-soft: #173A2F;
    --warning: #F5B54A; --warning-soft: #3A2A10;
    --danger: #FF8A80;  --danger-soft: #3D1A1A;
    --info: #8DB4FF;    --info-soft: #1A2847;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-overlay: 0 8px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body.rz-body {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

a { color: var(--primary); text-decoration: none; font-weight: 600; cursor: pointer; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

.rz-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Layout: painel de marca + conteúdo ---------- */
.rz-pagina {
  display: grid;
  grid-template-columns: minmax(360px, 42%) 1fr;
  min-height: 100vh;
}

.rz-marca {
  background: var(--brand-navy); /* fixo nos dois temas */
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
}
.rz-marca-logo { height: 56px; width: auto; align-self: flex-start; }
.rz-marca-texto { max-width: 420px; }
.rz-marca-produto {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 32px; line-height: 40px; font-weight: 700;
}
.rz-marca-descricao { margin: 0; font-size: 14px; line-height: 22px; color: #D9DCEC; }

.rz-conteudo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 16px;
}

.rz-cartao {
  width: 100%;
  max-width: 400px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 32px;
}

.rz-rodape { margin: 0; font-size: 12px; line-height: 16px; color: var(--ink-muted); text-align: center; }

@media (max-width: 900px) {
  .rz-pagina { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rz-marca { padding: 16px; flex-direction: row; align-items: center; }
  .rz-marca-logo { height: 32px; }
  .rz-marca-descricao { display: none; }
  .rz-marca-produto { font-size: 18px; line-height: 26px; font-weight: 600; margin: 0; }
  .rz-conteudo { justify-content: flex-start; padding-top: 32px; }
  .rz-cartao { padding: 24px 16px; border: 0; box-shadow: none; background: transparent; }
}

/* ---------- Cabeçalho do cartão ---------- */
.rz-cabecalho { margin-bottom: 24px; }
#kc-page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px; line-height: 32px; font-weight: 700;
  color: var(--ink);
}
.rz-obrigatorios { margin: 8px 0 0; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.required { color: var(--danger); }

.rz-usuario {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px;
  background: var(--surface-sunken);
  border-radius: 6px;
}
#kc-attempted-username { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
#reset-login { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }

/* ---------- Formulário ---------- */
.rz-form, #kc-form-login, #kc-content form { display: flex; flex-direction: column; gap: 16px; }
.rz-grupo { display: flex; flex-direction: column; gap: 4px; margin: 0; }

.rz-rotulo, #kc-content label {
  font-size: 14px; line-height: 22px; font-weight: 600; color: var(--ink);
}

.rz-input,
#kc-content input[type="text"],
#kc-content input[type="password"],
#kc-content input[type="email"],
#kc-content input[type="tel"],
#kc-content input[type="number"],
#kc-content select,
#kc-content textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}
#kc-content textarea { height: auto; min-height: 80px; padding: 8px 12px; }
.rz-input:disabled { opacity: 0.5; cursor: not-allowed; }
.rz-input[aria-invalid="true"] { border-color: var(--danger); }

.rz-input-grupo { position: relative; display: flex; }
.rz-input-grupo .rz-input { padding-right: 44px; }

.rz-erro-campo { font-size: 12px; line-height: 16px; color: var(--danger); }
.rz-ajuda { font-size: 12px; line-height: 16px; color: var(--ink-muted); }

.rz-opcoes { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rz-opcoes-links { font-size: 14px; }

.rz-check, #kc-form-options .checkbox label {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-weight: 400 !important; /* label de checkbox não é rótulo de campo */
}
#kc-content input[type="checkbox"], #kc-content input[type="radio"] {
  width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer;
}

/* ---------- Botões ---------- */
.rz-botao,
#kc-content input[type="submit"],
#kc-content button[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 36px; padding: 0 16px;
  font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: 6px;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.rz-botao-primario,
#kc-content input[type="submit"]:not(.rz-botao-secundario),
#kc-content button[type="submit"]:not(.rz-botao-secundario) {
  background: var(--primary); color: var(--on-primary);
}
.rz-botao-primario:hover,
#kc-content input[type="submit"]:not(.rz-botao-secundario):hover,
#kc-content button[type="submit"]:not(.rz-botao-secundario):hover { background: var(--primary-hover); }
.rz-botao-secundario { background: var(--surface-raised); color: var(--ink); border-color: var(--line-strong); }
.rz-botao-secundario:hover { background: var(--primary-soft); text-decoration: none; }
.rz-botao-bloco { width: 100%; }
.rz-botao:disabled, #kc-content input[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }
#kc-form-buttons { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }

.rz-botao-icone {
  position: absolute; right: 2px; top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  color: var(--ink-muted); background: transparent; border: 0; border-radius: 4px;
  cursor: pointer;
}
.rz-botao-icone:hover { color: var(--ink); background: var(--primary-soft); }

/* ---------- Alertas (mensagens do Keycloak) ---------- */
.rz-alerta {
  display: flex; align-items: flex-start; gap: 8px;
  margin-bottom: 16px; padding: 12px;
  border-radius: 6px;
  border-left: 4px solid currentColor;
  font-size: 14px; line-height: 22px;
}
.rz-alerta-texto { color: var(--ink); }
.rz-alerta-error   { background: var(--danger-soft);  color: var(--danger); }
.rz-alerta-warning { background: var(--warning-soft); color: var(--warning); }
.rz-alerta-success { background: var(--success-soft); color: var(--success); }
.rz-alerta-info    { background: var(--info-soft);    color: var(--info); }
.rz-alerta .rz-icone { margin-top: 2px; }

/* ---------- Ícones (Lucide, via máscara: herdam a cor do texto) ---------- */
.rz-icone {
  display: inline-block; flex-shrink: 0;
  width: 18px; height: 18px;
  background-color: currentColor;
  -webkit-mask: var(--rz-icone) center / contain no-repeat;
  mask: var(--rz-icone) center / contain no-repeat;
}
#reset-login .rz-icone { width: 14px; height: 14px; }

/* ---------- Info, social, rodapé do formulário ---------- */
.rz-info { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; color: var(--ink-muted); }
.rz-social { margin-top: 24px; }
.rz-social hr { border: 0; border-top: 1px solid var(--line); }
.rz-social h2 { font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); text-align: center; }
.rz-social-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
#try-another-way { font-size: 14px; }
#kc-content-wrapper > p, .instruction { color: var(--ink-muted); }

/* Lista de autenticadores (quando houver OTP/WebAuthn) */
.rz-lista-autenticadores { display: flex; flex-direction: column; gap: 8px; }
.rz-autenticador {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.rz-autenticador:hover { background: var(--primary-soft); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.rz-icone-olho { --rz-icone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.rz-icone-olho-fechado { --rz-icone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49'/%3E%3Cpath d='M14.084 14.158a3 3 0 0 1-4.242-4.242'/%3E%3Cpath d='M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143'/%3E%3Cpath d='m2 2 20 20'/%3E%3C/svg%3E"); }
.rz-icone-erro { --rz-icone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E"); }
.rz-icone-ok { --rz-icone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E"); }
.rz-icone-info { --rz-icone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E"); }
.rz-icone-alerta { --rz-icone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }
.rz-icone-voltar { --rz-icone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3C/svg%3E"); }
.rz-icone-seta { --rz-icone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E"); }