/* ═══════════════════════════════════════════════════════════════
   ERPAvel — Tela de login
   Identidade extraída da logomarca: azul-marinho #122741, azul #0a68f8
   Tipografia: Montserrat (títulos, mesma família geométrica da marca) + Inter (interface)
   Arquivo estático de propósito: o WebStencils não processa @media aqui.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --lg-navy:      #122741;
  --lg-panel:     #0e2240;
  --lg-blue:      #0a68f8;
  --lg-blue-deep: #0056e4;
  --lg-blue-soft: #5da2ff;
  --lg-ink:       #122741;
  --lg-text:      #3d4f66;
  --lg-muted:     #6b7a90;
  --lg-line:      #d5dde9;
  --lg-bg:        #ffffff;
  --lg-danger:    #c62828;
  --lg-surface:   #ffffff;
  --lg-surface-2: #f7f9fc;
  --lg-tint:      #f2f7ff;
  --lg-tint-line: #d6e4fb;
  --lg-hairline:  #e3e9f2;
  --lg-line-strong:#b9c6d8;
  --lg-icon-bg:   #eef4ff;
  --lg-danger-bg: #fdf1f1;
  --lg-danger-line:#f3c7c7;
  --lg-warn-bg:   #fff8e6;
  --lg-warn-line: #f2dc9b;
  --lg-warn-text: #7a5400;
  --lg-ok-bg:     #e8f6ee;
  --lg-placeholder:#9aa7b8;
}

/* Tema escuro (classe aplicada pelo authLayout a partir do localStorage 'theme') */
.dark-mode {
  --lg-ink:       #e8eef7;
  --lg-text:      #b6c2d3;
  --lg-muted:     #8d9bb0;
  --lg-line:      #2c3e57;
  --lg-bg:        #0b1626;
  --lg-blue:      #2b7bff;
  --lg-blue-deep: #4a90ff;
  --lg-danger:    #ff7b7b;
  --lg-surface:   #12233a;
  --lg-surface-2: #172b45;
  --lg-tint:      #10294a;
  --lg-tint-line: #1f3f6b;
  --lg-hairline:  #22344d;
  --lg-line-strong:#3b5273;
  --lg-icon-bg:   #14305a;
  --lg-danger-bg: #3a1a1f;
  --lg-danger-line:#6b2a33;
  --lg-warn-bg:   #3a2f12;
  --lg-warn-line: #6b5518;
  --lg-warn-text: #f2c75c;
  --lg-ok-bg:     #12361f;
  --lg-placeholder:#6d7d95;
  color-scheme: dark;
}
.dark-mode .lg-btn:disabled { background: #2b7bff; }

/* O layout de autenticação injeta fundo, centralização e padding no body — aqui a tela é nossa */
html, body {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100vh;
  background: var(--lg-bg) !important;
  display: block !important;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
  -webkit-font-smoothing: antialiased;
}
body.dark-mode { background: var(--lg-bg) !important; }

.lg-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
  background: var(--lg-bg);
}

/* ── Lado da marca ───────────────────────────────────────────── */
.lg-brand {
  display: none;
  position: relative;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem 4rem 2.25rem;
  background: var(--lg-panel);
  color: #fff;
}

/* A marca "A" em grande escala, sangrando para fora do painel — é o elemento que dá identidade */
.lg-brand-mark {
  position: absolute;
  right: -9%;
  bottom: -14%;
  width: 78%;
  max-width: 760px;
  opacity: .07;
  pointer-events: none;
  user-select: none;
}

.lg-brand-logo { position: relative; display: block; align-self: flex-start; height: 52px; width: auto; max-width: 100%; }

.lg-brand-body { position: relative; max-width: 560px; }
.lg-rule { display: block; width: 44px; height: 3px; border-radius: 2px; background: var(--lg-blue); margin-bottom: 1.6rem; }
.lg-headline {
  margin: 0 0 1.25rem;
  font-family: 'Montserrat', 'Inter', sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 3.1vw, 3rem);
  line-height: 1.12;
  letter-spacing: -.015em;
  color: #fff;
}
.lg-headline span { color: var(--lg-blue-soft); }
.lg-lead {
  margin: 0 0 2.25rem;
  max-width: 470px;
  font-size: 1rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, .72);
}

.lg-modules { list-style: none; margin: 0; padding: 0; counter-reset: modulo; }
.lg-modules li {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  column-gap: .5rem;
  padding: .95rem 0;
  border-top: 1px solid rgba(255, 255, 255, .13);
}
.lg-modules li:last-child { border-bottom: 1px solid rgba(255, 255, 255, .13); }
.lg-modules li::before {
  counter-increment: modulo;
  content: counter(modulo, decimal-leading-zero);
  grid-row: 1 / span 2;
  font-family: 'Montserrat', sans-serif;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--lg-blue-soft);
  padding-top: .15rem;
}
.lg-modules b  { font-size: .95rem; font-weight: 600; color: #fff; }
.lg-modules em { font-style: normal; font-size: .83rem; color: rgba(255, 255, 255, .6); line-height: 1.5; }

.lg-brand-foot {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: .75rem;
  color: rgba(255, 255, 255, .5);
}

/* ── Lado do formulário ──────────────────────────────────────── */
.lg-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: var(--lg-bg);
}
.lg-form-inner { width: 100%; max-width: 400px; }

.lg-mobile-logo { display: block; height: 44px; width: auto; max-width: 100%; margin: 0 0 2.25rem; }

.lg-title {
  margin: 0 0 .5rem;
  font-family: 'Montserrat', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: -.01em;
  color: var(--lg-ink);
}
.lg-subtitle { margin: 0 0 2rem; font-size: .92rem; line-height: 1.55; color: var(--lg-muted); }

.lg-field { margin-bottom: 1.15rem; }
.lg-label { display: block; margin-bottom: .4rem; font-size: .8rem; font-weight: 600; color: var(--lg-ink); }
.lg-control { position: relative; }

.lg-input {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 .95rem;
  font-family: inherit;
  font-size: .95rem;
  color: var(--lg-ink);
  background: var(--lg-surface);
  border: 1px solid var(--lg-line);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.lg-input::placeholder { color: var(--lg-placeholder); }
.lg-input:hover { border-color: var(--lg-line-strong); }
.lg-input:focus { border-color: var(--lg-blue); box-shadow: 0 0 0 3px rgba(10, 104, 248, .16); }
.lg-input:disabled { background: var(--lg-surface-2); color: var(--lg-muted); cursor: progress; }
.lg-input:-webkit-autofill,
.lg-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--lg-ink);
  -webkit-box-shadow: 0 0 0 1000px var(--lg-surface) inset;
  transition: background-color 9999s;
}
.lg-has-toggle .lg-input { padding-right: 5rem; }
.lg-toggle {
  position: absolute; top: 0; right: 0; height: 46px; padding: 0 .95rem;
  border: 0; background: none; cursor: pointer;
  font-family: inherit; font-size: .78rem; font-weight: 600; color: var(--lg-blue);
}
.lg-toggle:hover { color: var(--lg-blue-deep); }

select.lg-input {
  appearance: none; -webkit-appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b7a90' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .95rem center;
}

/* Empresa só aparece depois de validar usuário e senha */
.lg-empresa { max-height: 0; opacity: 0; overflow: hidden; transition: max-height .35s ease, opacity .25s ease; }
.lg-empresa.visible { max-height: 120px; opacity: 1; overflow: visible; }
.lg-empresa .lg-field { padding-top: .05rem; }

.lg-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: .35rem 0 1.5rem; }
.lg-check { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--lg-text); cursor: pointer; }
.lg-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--lg-blue); cursor: pointer; }
.lg-link { font-size: .85rem; font-weight: 500; color: var(--lg-blue); text-decoration: none; }
.lg-link:hover { color: var(--lg-blue-deep); text-decoration: underline; }

.lg-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 48px;
  font-family: inherit; font-size: .95rem; font-weight: 600; letter-spacing: .01em;
  color: #fff; background: var(--lg-blue);
  border: 0; border-radius: 8px; cursor: pointer;
  transition: background .15s, transform .05s;
}
.lg-btn:hover { background: var(--lg-blue-deep); }
.lg-btn:active { transform: translateY(1px); }
.lg-btn:focus-visible { outline: 3px solid rgba(10, 104, 248, .35); outline-offset: 2px; }
.lg-btn:disabled { cursor: progress; background: #4b8df5; }
.lg-spinner {
  display: none; width: 18px; height: 18px; margin-right: .6rem;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  animation: lg-spin .7s linear infinite;
}
.lg-btn.loading .lg-spinner { display: inline-block; }
@keyframes lg-spin { to { transform: rotate(360deg); } }

.lg-error {
  display: none; align-items: flex-start; gap: .6rem;
  margin: 0 0 1.25rem; padding: .75rem .9rem;
  font-size: .85rem; line-height: 1.45; color: var(--lg-danger);
  background: var(--lg-danger-bg); border: 1px solid var(--lg-danger-line); border-left: 3px solid var(--lg-danger); border-radius: 6px;
}
.lg-error.show { display: flex; }
.lg-error i { margin-top: .1rem; }

.lg-register { margin: 1.6rem 0 0; text-align: center; font-size: .88rem; color: var(--lg-muted); }
.lg-register a { font-weight: 600; color: var(--lg-blue); text-decoration: none; }
.lg-register a:hover { color: var(--lg-blue-deep); text-decoration: underline; }

.lg-foot { margin-top: 2.75rem; padding-top: 1.1rem; border-top: 1px solid var(--lg-hairline); font-size: .76rem; line-height: 1.6; color: var(--lg-muted); }

/* mensagens flash do servidor (partials/messages) */
.lg-form-inner .alert { font-size: .85rem; border-radius: 6px; }

/* ── Desktop ─────────────────────────────────────────────────── */
@media (min-width: 1025px) {
  .lg-page { grid-template-columns: minmax(0, 1.08fr) minmax(440px, .92fr); }
  .lg-brand { display: flex; }
  .lg-mobile-logo { display: none; }
  .lg-form-side { padding: 3rem 4rem; }
}
@media (min-width: 1025px) and (max-width: 1279px) {
  .lg-brand { padding: 2.5rem 2.5rem 2rem; }
}
@media (min-width: 1600px) {
  .lg-brand { padding: 3.5rem 5.5rem 2.5rem; }
  .lg-brand-logo { height: 52px; }
  .lg-form-inner { max-width: 420px; }
}

/* ── Telas pequenas: sem zoom automático no iOS, mais respiro ── */
@media (max-width: 575px) {
  .lg-form-side { align-items: flex-start; padding: 2rem 1.25rem; }
  .lg-input { font-size: 1rem; }
  .lg-title { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lg-empresa, .lg-btn, .lg-input { transition: none; }
  .lg-spinner { animation-duration: 1.6s; }
}


/* ═══════════════════════════════════════════════════════════════
   Componentes compartilhados pelas demais telas de autenticação
   (esqueci a senha, criar/redefinir senha, empresa, filial, criar conta)
   ═══════════════════════════════════════════════════════════════ */

.lg-back {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: 0 0 1.75rem; font-size: .85rem; font-weight: 500;
  color: var(--lg-muted); text-decoration: none;
}
.lg-back:hover { color: var(--lg-blue); }

.lg-note {
  display: flex; gap: .65rem;
  margin: 0 0 1.4rem; padding: .8rem .95rem;
  font-size: .84rem; line-height: 1.5; color: var(--lg-text);
  background: var(--lg-tint); border: 1px solid var(--lg-tint-line); border-left: 3px solid var(--lg-blue); border-radius: 6px;
}
.lg-note i { color: var(--lg-blue); margin-top: .15rem; flex-shrink: 0; }

.lg-hint { margin-top: .4rem; font-size: .78rem; color: var(--lg-muted); }

/* Botões */
.lg-btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; height: 46px; padding: 0 1rem;
  font-family: inherit; font-size: .92rem; font-weight: 600; text-decoration: none;
  color: var(--lg-ink); background: var(--lg-surface);
  border: 1px solid var(--lg-line); border-radius: 8px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.lg-btn-ghost:hover { border-color: var(--lg-line-strong); background: var(--lg-surface-2); color: var(--lg-ink); }
.lg-btn:disabled, .lg-btn[disabled] { opacity: .5; cursor: not-allowed; background: var(--lg-blue); }
.lg-sep { display: flex; align-items: center; gap: .9rem; margin: 1.4rem 0; font-size: .8rem; color: var(--lg-muted); }
.lg-sep::before, .lg-sep::after { content: ''; flex: 1; height: 1px; background: var(--lg-hairline); }
.lg-center { text-align: center; }

/* Passos (redefinir senha) */
.lg-steps { display: flex; align-items: center; gap: .6rem; margin: 0 0 1.75rem; }
.lg-step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; color: var(--lg-muted);
  background: var(--lg-surface); border: 1.5px solid var(--lg-line);
}
.lg-step-dot.active { color: #fff; background: var(--lg-blue); border-color: var(--lg-blue); }
.lg-step-dot.completed { color: #fff; background: #1b8a4b; border-color: #1b8a4b; }
.lg-step-line { flex: 0 0 36px; height: 1.5px; background: var(--lg-line); }

/* Requisitos de senha */
.lg-req { margin: .25rem 0 1.5rem; padding: .9rem 1rem; background: var(--lg-surface-2); border: 1px solid var(--lg-hairline); border-radius: 8px; }
.lg-req p, .lg-req h6 { margin: 0 0 .6rem; font-size: .78rem; font-weight: 600; color: var(--lg-ink); }
.lg-req ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .75rem; }
.lg-req li { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--lg-muted); }
.lg-req li.valid { color: #1b8a4b; }
.lg-req li.wide { grid-column: 1 / -1; }

/* Token (campo em fonte monoespaçada) */
.lg-input.lg-mono { font-family: 'Consolas', 'Courier New', monospace; font-size: .85rem; letter-spacing: .04em; }

/* Seleção de empresa / filial — o HTML dos itens é gerado pelo servidor (classes empresa-*) */
.lg-form-inner .empresa-option { position: relative; margin-bottom: .7rem; }
.lg-form-inner .empresa-option input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.lg-form-inner .empresa-card-label {
  display: flex; align-items: center; gap: .9rem;
  padding: .9rem 1rem; background: var(--lg-surface); cursor: pointer;
  border: 1px solid var(--lg-line); border-radius: 8px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.lg-form-inner .empresa-card-label:hover { border-color: var(--lg-line-strong); }
.lg-form-inner .empresa-option input:checked + .empresa-card-label {
  border-color: var(--lg-blue); background: var(--lg-surface-2); box-shadow: 0 0 0 3px rgba(10, 104, 248, .14);
}
.lg-form-inner .empresa-option input:focus-visible + .empresa-card-label { box-shadow: 0 0 0 3px rgba(10, 104, 248, .32); }
.lg-form-inner .empresa-icon {
  width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--lg-icon-bg); color: var(--lg-blue); font-size: 1rem;
}
.lg-form-inner .empresa-info { flex: 1; min-width: 0; }
.lg-form-inner .empresa-nome { display: block; font-size: .92rem; font-weight: 600; color: var(--lg-ink); }
.lg-form-inner .empresa-id { font-size: .76rem; color: var(--lg-muted); }
.lg-form-inner .empresa-check { font-size: 1.1rem; color: var(--lg-blue); opacity: 0; transition: opacity .15s; }
.lg-form-inner .empresa-option input:checked + .empresa-card-label .empresa-check { opacity: 1; }
.lg-choices { margin: 0 0 1.5rem; }

/* Estado de sucesso */
.lg-success { text-align: left; }
.lg-success-icon {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 0 1.25rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff; background: #1b8a4b;
}

@media (max-width: 575px) {
  .lg-req ul { grid-template-columns: 1fr; }
}
