/* =====================================================================
   Innomaker theme for the Authelia portal (built against v4.39.28).
   Authelia's stylesheet loads AFTER this file, so every rule is
   prefixed (:root / html / #id) to win on specificity.
   ===================================================================== */

/* ---------- 1. Palette, mapped onto Authelia's theme variables ------ */
/* Authelia sets <html data-theme="light|dark|grey|oled"> ("auto" is
   resolved to light/dark by its JS), and every component reads these
   variables, so 2FA, password-reset and settings pages turn green too. */
:root[data-theme="light"] {
  --verde: #41a639;
  --verde-hover: #358c30;
  --bg-effect: rgba(65, 166, 57, .08);
  --page-bg: #f4f7f4;
  --card-bg: #ffffff;
  --text-1: #182019;
  --text-2: #707b72;
  --line: #dce4dd;
  --line-hover: #bec9c0;
  --field-bg: #ffffff;
  --footer-line: #edf1ed;
  --card-shadow: 0 30px 80px rgba(28, 55, 30, .11), 0 8px 25px rgba(28, 55, 30, .05);

  --background: var(--page-bg);
  --foreground: var(--text-1);
  --card: var(--card-bg);
  --card-foreground: var(--text-1);
  --popover: var(--card-bg);
  --popover-foreground: var(--text-1);
  --primary: var(--verde);
  --primary-foreground: #ffffff;
  --muted-foreground: var(--text-2);
  --border: var(--line);
  --input: var(--line);
  --ring: var(--verde);
  --custom-icon: var(--verde);
  --custom-loading-bar: var(--verde);
}

:root[data-theme="dark"],
:root[data-theme="grey"],
:root[data-theme="oled"] {
  --verde: #41a639;
  --verde-hover: #5cc254;
  --bg-effect: rgba(65, 166, 57, .065);
  --page-bg: #0f1310;
  --card-bg: #181d19;
  --text-1: #f0f4f1;
  --text-2: #9da89f;
  --line: #303932;
  --line-hover: #455148;
  --field-bg: #202621;
  --footer-line: #29302a;
  --card-shadow: 0 30px 80px rgba(0, 0, 0, .35);

  --background: var(--page-bg);
  --foreground: var(--text-1);
  --card: var(--card-bg);
  --card-foreground: var(--text-1);
  --popover: var(--card-bg);
  --popover-foreground: var(--text-1);
  --primary: var(--verde);
  --primary-foreground: #ffffff;
  --muted-foreground: var(--text-2);
  --border: var(--line);
  --input: var(--line);
  --ring: var(--verde);
  --custom-icon: var(--verde);
  --custom-loading-bar: var(--verde);
}

/* ---------- 2. Page background + decorative circles ----------------- */
html body {
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  color: var(--text-1);
  background:
    radial-gradient(circle at 15% 10%, var(--bg-effect), transparent 32%),
    radial-gradient(circle at 90% 90%, var(--bg-effect), transparent 28%),
    var(--page-bg);
  background-attachment: fixed;
}
html body::before,
html body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  border: 1px solid rgba(65, 166, 57, .07);
  z-index: 0;
}
html body::before { width: 420px; height: 420px; top: -210px; right: -180px; }
html body::after  { width: 300px; height: 300px; bottom: -160px; left: -120px; }

/* Language picker stays usable but quiet */
html #language-button { color: var(--text-2); position: relative; z-index: 3; }

/* ---------- 3. The card (every login-layout page: sign-in, 2FA, reset) */
html .min-h-\[90vh\] > div {
  position: relative;
  z-index: 2;
  max-width: 535px;
  padding: 48px 48px 32px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 27px;
  box-shadow: var(--card-shadow);
  transition: background-color .25s ease, border-color .25s ease;
}

/* Logo: wide wordmark, swapped per theme (the <img> keeps its box, the
   PNG is pushed out of view and the SVG is drawn as its background) */
html .min-h-\[90vh\] img[alt="Logo"] {
  width: 265px;
  max-width: 82%;
  height: 82px;
  margin: 0 auto 28px;
  object-position: -9999px 0;
  background: url("/branding/logo-light.svg") center / contain no-repeat;
}
html[data-theme="dark"] .min-h-\[90vh\] img[alt="Logo"],
html[data-theme="grey"] .min-h-\[90vh\] img[alt="Logo"],
html[data-theme="oled"] .min-h-\[90vh\] img[alt="Logo"] {
  background-image: url("/branding/logo-dark.svg");
}
html .min-h-\[90vh\] .flex-col > .p-2:first-child { padding: 0; }

/* ---------- 4. Sign-in page: heading block ---------------------------- */
#first-factor-stage .flex-col { text-align: left; }

/* "Iniciar sessão" heading is replaced by eyebrow + title + description.
   (Same translation key as the button, so it's swapped here, not in locales.) */
#first-factor-stage h5 { font-size: 0; line-height: 0; }
#first-factor-stage h5::before {
  content: "Sistema Integrado";
  display: block;
  margin-bottom: 9px;
  color: var(--verde);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 1.35px;
  text-transform: uppercase;
}
#first-factor-stage h5::after {
  content: "Bem-vindo";
  display: block;
  color: var(--text-1);
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.6px;
}
#first-factor-stage .flex-col > .w-full:has(> h5)::after {
  content: "Entre com suas credenciais para acessar o sistema.";
  display: block;
  margin: 9px 0 23px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- 5. Form layout -------------------------------------------- */
/* Two-column grid so "Lembrar de mim" and "Esqueci minha senha" share a
   row; everything else spans both columns. "order" puts them above the
   button, like the mockup. */
#first-factor-stage #form-login > .grid {
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  row-gap: 20px;
}
#first-factor-stage #form-login > .grid > * { grid-column: 1 / -1; order: 10; }
#first-factor-stage #form-login > .grid > :has(#username-textfield) { order: 1; }
#first-factor-stage #form-login > .grid > :has(#password-textfield) { order: 2; }
#first-factor-stage #form-login > .grid > :has([role="alert"]) { order: 3; }
#first-factor-stage #form-login > .grid > :has(#remember-checkbox) {
  order: 4; grid-column: 1; margin: -6px 0 4px; align-self: center;
}
#first-factor-stage #form-login > .grid > :has(#reset-password-button) {
  order: 5; grid-column: 2; margin: -6px 0 4px; align-self: center;
}
#first-factor-stage #form-login > .grid > :has(#sign-in-button) { order: 6; }

/* Floating labels become static uppercase labels above the inputs.
   column-reverse puts the <label> (after the <input> in the DOM) on top. */
#first-factor-stage .relative:has(> [data-slot="floating-input"]) {
  display: flex;
  flex-direction: column-reverse;
}
#first-factor-stage label[for="username-textfield"],
#first-factor-stage label[for="password-textfield"] {
  position: static;
  transform: none;
  translate: none;          /* Tailwind v4 shifts via "translate", not "transform" */
  margin-bottom: 8px;
  font-size: 0;            /* hides the "Nome de usuário *" text… */
  line-height: 1.2;
}
#first-factor-stage label[for="username-textfield"]::before,
#first-factor-stage label[for="password-textfield"]::before {
  display: block;          /* …and draws the mockup's label instead */
  color: var(--text-1);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .55px;
  text-transform: uppercase;
}
#first-factor-stage label[for="username-textfield"]::before { content: "E-mail"; }
#first-factor-stage label[for="password-textfield"]::before { content: "Senha"; }

/* Inputs */
#first-factor-stage [data-slot="floating-input"] {
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--field-bg);
  color: var(--text-1);
  font-family: inherit;
  font-size: 14px;
  box-shadow: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .25s ease;
}
#first-factor-stage #password-textfield { padding-right: 64px; }
#first-factor-stage [data-slot="floating-input"]:hover { border-color: var(--line-hover); }
#first-factor-stage [data-slot="floating-input"]:focus {
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(65, 166, 57, .12);
}
#first-factor-stage [data-slot="floating-input"][aria-invalid="true"] {
  border-color: #c9372c;
  box-shadow: 0 0 0 3px rgba(201, 55, 44, .12);
}
/* Hide the browser's blue autofill fill so the field keeps its colors */
#first-factor-stage [data-slot="floating-input"]:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 40px var(--field-bg) inset;
  -webkit-text-fill-color: var(--text-1);
}

/* Show/hide password: eye icon → "VER" / "OCULTAR" text button,
   re-centred on the input (the label now sits above it) */
#first-factor-stage button[aria-pressed] {
  top: auto;
  bottom: 0;
  right: 10px;
  height: 52px;
  transform: none;
  translate: none;          /* undo Tailwind's -translate-y-1/2 */
  padding: 0 6px;
  color: var(--text-2);
}
#first-factor-stage button[aria-pressed] svg { display: none; }
#first-factor-stage button[aria-pressed]::before {
  content: "VER";
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .2px;
}
#first-factor-stage button[aria-pressed="true"]::before { content: "OCULTAR"; }
#first-factor-stage button[aria-pressed]:hover { color: var(--verde); }

/* Remember me: smaller, matches the link next to it */
#first-factor-stage label[for="remember-checkbox"] {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

/* "Redefinir senha?" → "Esqueci minha senha" */
#first-factor-stage #reset-password-button {
  padding: 0;
  font-size: 0;
  color: var(--verde);
  text-decoration: none;
}
#first-factor-stage #reset-password-button::before {
  content: "Esqueci minha senha";
  font-size: 12px;
  font-weight: 600;
}
#first-factor-stage #reset-password-button:hover { color: var(--verde-hover); text-decoration: underline; }

/* ---------- 6. Buttons (all pages): green gradient -------------------- */
html .min-h-\[90vh\] [data-slot="button"][data-variant="default"] {
  min-height: 51px;
  border-radius: 11px;
  background: linear-gradient(135deg, #41a639, #51b848);
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
  box-shadow: 0 8px 22px rgba(65, 166, 57, .21);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
html .min-h-\[90vh\] [data-slot="button"][data-variant="default"]:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 27px rgba(65, 166, 57, .28);
}

/* Sign-in button label: "Iniciar sessão" → "Entrar no sistema"
   (the loading spinner is an SVG, so font-size 0 doesn't hide it) */
#first-factor-stage #sign-in-button { font-size: 0; }
#first-factor-stage #sign-in-button::before { content: "Entrar no sistema"; font-size: 14px; }

/* ---------- 7. Footer: "Powered by Authelia" → Innomaker footer -------- */
html .min-h-\[90vh\] .flex-col > div:has(> a[href*="authelia.com"]) {
  margin-top: 30px;
  padding-top: 21px;
  border-top: 1px solid var(--footer-line);
}
html .min-h-\[90vh\] a[href*="authelia.com"] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0;
  pointer-events: none;     /* plain text, not a link */
  color: var(--text-2);
}
html .min-h-\[90vh\] a[href*="authelia.com"]::before { content: "Sistema Integrado Innomaker"; font-size: 11px; }
html .min-h-\[90vh\] a[href*="authelia.com"]::after {
  content: "Ambiente seguro";
  font-size: 11px;
  padding-left: 13px;       /* room for the green dot drawn as background */
  background: radial-gradient(circle at 2.5px 50%, var(--verde) 2.5px, transparent 3px) no-repeat;
}

/* ---------- 8. Mobile: full-bleed card, like the mockup --------------- */
@media (max-width: 600px) {
  html body { background: var(--card-bg); }   /* card is full-bleed, so the page matches it */
  html body::before, html body::after { display: none; }
  html .min-h-\[90vh\] { align-items: stretch; }
  html .min-h-\[90vh\] > div {
    max-width: none;
    min-height: 100vh;
    padding: 38px 25px 30px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  html .min-h-\[90vh\] img[alt="Logo"] { width: 230px; }
  #first-factor-stage h5::after { font-size: 27px; }
}   /* closes @media (max-width: 600px) */

/* ---------- Caps Lock warning (sign-in, 2FA password, re-auth pages) ---------- */
html [data-slot="alert"][class*="border-warning"] {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  padding: 12px 14px;
  border: 1px solid #efa94d;
  border-radius: 10px;
  background: #fff7eb;
  color: #6a4215;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
}
html [data-slot="alert"][class*="border-warning"] > svg { display: none; }
html [data-slot="alert"][class*="border-warning"] > [data-slot="alert-title"] {
  min-height: 0;
  font-weight: 700;
  -webkit-line-clamp: none;
  line-clamp: none;
}
html [data-slot="alert"][class*="border-warning"] > [data-slot="alert-title"]::after { content: ":"; }
html[data-theme="dark"] [data-slot="alert"][class*="border-warning"],
html[data-theme="grey"] [data-slot="alert"][class*="border-warning"],
html[data-theme="oled"] [data-slot="alert"][class*="border-warning"] {
  background: #332717;
  border-color: #916626;
  color: #f8d69c;
}
#first-factor-stage #form-login > .grid > :has(> [data-slot="alert"]) {
  padding: 0;
  margin-top: -10px;
}
