/**
 * Telas de autenticação do Portal Pagrisa (layout compartilhado: src/views/layouts/auth.hbs)
 * Usado por: /login (inclui "Esqueceu sua senha?"), /primeiro-acesso e /redefinir-senha.
 * Qualquer ajuste de fundo, logo, tipografia ou responsividade feito aqui vale para as três telas.
 */
:root {
  --navy: #082d52;
  --blue: #075cb9;
  --blue2: #0d75db;
  --green: #66dc45;
  --text: #102f51;
  --muted: #667e98;
  --border: #d4e0ed;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, "Segoe UI", Arial, sans-serif; }
body { color: white; background: #0b3c6c; }
[hidden] { display: none !important; }

/* ---------- Layout desktop: 60% área institucional | 40% formulário ---------- */
.page {
  position: relative; isolation: isolate;
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: minmax(0, 3fr) minmax(440px, 2fr); align-items: center;
  gap: clamp(30px, 5vw, 96px);
  padding: clamp(28px, 5vw, 84px) clamp(26px, 6vw, 112px);
  overflow: hidden;
}
/* Foto de drone da usina (usina-principal.jpg recortada sem a marca d'água e comprimida) */
.page::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: url('/public/img/fundo-login-usina.jpg') center 50% / cover no-repeat;
}
/* Degradê azul só na lateral esquerda (legibilidade do texto); à direita a foto aparece sem escurecer */
.page::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(2,33,67,.93) 0%, rgba(3,44,80,.85) 28%, rgba(4,41,75,.45) 50%, rgba(3,34,69,.08) 68%, rgba(3,34,69,0) 100%);
}

/* ---------- Área institucional (lado esquerdo) ---------- */
.hero { max-width: 820px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.logo { display: flex; align-items: center; }
/* Logo oficial (PNG com margem transparente: margens negativas compensam o respiro) */
.logo img { display: block; width: clamp(200px, 18vw, 270px); height: auto; margin: -14px 0 -14px -4px; }
.eyebrow { font-size: 12px; letter-spacing: .4em; margin: 24px 0 14px; text-transform: uppercase; font-weight: 700; color: #d9e9fc; }
.accent { width: 64px; height: 5px; border-radius: 6px; background: var(--green); margin: 16px 0 25px; }
.hero h1 { font-size: clamp(40px, 5vw, 78px); line-height: 1.05; letter-spacing: -.045em; margin: 0 0 23px; font-weight: 850; }
.hero h1 em { font-style: normal; color: #77e64e; }
.lead { font-size: clamp(17px, 1.65vw, 23px); line-height: 1.5; max-width: 600px; margin: 0 0 40px; color: #e1edf8; }
.features { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; max-width: 800px; }
.feature {
  border: 1px solid rgba(255,255,255,.22); border-radius: 18px; padding: 24px 14px 21px;
  background: rgba(255,255,255,.07); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  text-align: center; transition: transform .2s ease, background-color .2s ease, border-color .2s ease;
}
.feature:hover { transform: translateY(-3px); background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.34); }
.feature svg { width: 38px; height: 38px; margin-bottom: 12px; stroke: #b4e6ff; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.feature span { display: block; font-size: 15px; font-weight: 650; line-height: 1.35; }
.quote { margin-top: auto; padding-top: 38px; border-left: 4px solid var(--green); padding-left: 16px; font-size: clamp(16px, 1.1vw, 19px); font-weight: 600; color: #eef7ff; }

/* ---------- Card do formulário (lado direito) ---------- */
/* Topo do card alinhado ao topo do logo (e não centralizado): o card não "pula" ao trocar de tela
   (login, recuperação, primeiro acesso) e cada um pode ter a altura que o conteúdo pedir */
.login-wrap { width: 100%; display: flex; justify-content: center; align-self: start; }
/* Fundo branco sólido: a foto não aparece através do card */
.panel {
  width: min(100%, 570px); padding: clamp(34px, 3.6vw, 58px); border-radius: 24px;
  background: #fff; color: var(--text);
  box-shadow: 0 22px 64px rgba(0,25,60,.24); border: 1px solid rgba(255,255,255,.7);
}
.panel h2 { font-size: clamp(28px, 2.4vw, 36px); margin: 0; text-align: center; letter-spacing: -.04em; }
.sub { text-align: center; color: var(--muted); font-size: 16px; margin: 10px 0 32px; line-height: 1.5; }

.field { margin-bottom: 22px; }
.field label { display: block; font-size: 15px; font-weight: 750; margin-bottom: 9px; }
.input-wrap { position: relative; }
.input-wrap input {
  width: 100%; height: 56px; border-radius: 11px; border: 1.5px solid var(--border); background: #fbfdff;
  padding: 0 52px 0 46px; outline: none; color: var(--text); font: inherit; font-size: 16px; transition: .18s;
}
.input-wrap input:focus { border-color: #2681e2; box-shadow: 0 0 0 4px rgba(16,111,216,.10); }
.input-wrap input::placeholder { color: #8da0b6; }
/* Ícone e botão do olho centralizados na altura do campo (qualquer altura de input) */
.field-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); display: flex; color: #718da7; }
.field-icon svg, .eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.eye { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); display: flex; border: 0; background: transparent; cursor: pointer; color: #718da7; padding: 4px; }
.eye[aria-pressed="true"] { color: #075cb9; }

.options { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0 24px; font-size: 14px; }
.remember { display: flex; gap: 8px; align-items: center; color: #526b83; cursor: pointer; }
.remember input { accent-color: var(--blue); width: 17px; height: 17px; }
.link { color: #046acb; text-decoration: none; font-weight: 650; }
.link:hover { text-decoration: underline; }

.primary {
  display: flex; justify-content: center; align-items: center; gap: 9px; width: 100%; height: 56px;
  border: 0; border-radius: 11px; background: linear-gradient(100deg, #084b91, #096fce);
  box-shadow: 0 7px 15px rgba(6,81,157,.17); color: white; font-weight: 750; font-size: 16px; cursor: pointer; font-family: inherit;
}
.primary:hover { filter: brightness(1.08); }
.primary[disabled] { opacity: .8; cursor: progress; filter: none; }
.secondary {
  display: flex; justify-content: center; align-items: center; width: 100%; min-height: 50px;
  background: #fff; border: 1px solid #a8c7ed; border-radius: 11px; color: #075ba9;
  font-weight: 700; text-decoration: none; font-size: 16px; margin-top: 14px;
}
.secondary:hover { background: #f1f8ff; }
.bottom { margin: 28px 0 0; padding-top: 22px; border-top: 1px solid #e1e9f1; text-align: center; }
.bottom a { font-size: 15px; }
.copyright { margin: 18px 0 0; font-size: 12.5px; text-align: center; color: #7790a7; }

/* ---------- Avisos (sucesso / erro / informação) ---------- */
.notice { margin-top: 18px; padding: 12px 14px; font-size: 14px; border-radius: 10px; line-height: 1.5; display: none; align-items: flex-start; gap: 10px; transition: opacity .3s ease, transform .3s ease; }
.notice.success, .notice.error, .notice.info { display: flex; }
.notice.success { background: #e6f9e9; color: #12682c; border: 1px solid #b4e5be; }
.notice.error { background: #fff1f1; color: #8b2020; border: 1px solid #f3b8b8; }
.notice.info { background: #ebf4ff; color: #194e86; border: 1px solid #bbd8f4; }
.notice-icone { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notice-texto { flex: 1; min-width: 0; }
.notice-fechar { flex: 0 0 auto; margin: -3px -4px 0 0; padding: 0 4px; border: 0; background: none; color: inherit; opacity: .6; font-size: 20px; line-height: 1; cursor: pointer; }
.notice-fechar:hover { opacity: 1; }
.notice.saindo { opacity: 0; transform: translateY(-4px); }
.notice-action { display: inline-block; margin-top: 6px; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 750; text-decoration: underline; cursor: pointer; }

/* ---------- Ajuda, recuperação e textos de apoio ---------- */
.help-box { margin-top: 14px; padding: 14px 16px; border-radius: 10px; background: #f4f8fd; border: 1px solid #dbe7f3; text-align: left; font-size: 14px; line-height: 1.5; color: #36536f; }
.help-box ul { margin: 0; padding-left: 18px; }
.help-box li + li { margin-top: 7px; }
.help-box strong { color: var(--text); }
.help-box a { font-size: inherit; }
.rec-info { margin: 0; text-align: center; font-size: 15px; color: var(--muted); }
.rec-email { margin: 10px 0 20px; padding: 13px; text-align: center; font-size: 16px; font-weight: 750; color: var(--text); background: #f4f8fd; border: 1px dashed var(--border); border-radius: 11px; word-break: break-all; }
.texto-centro { text-align: center; margin: -8px 0 20px; font-size: 14px; }
.saudacao { margin: 0 0 14px; text-align: center; font-size: 16px; color: var(--text); }
.dica { margin: -8px 0 22px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }

/* Quadro "Como funciona?" (primeiro acesso) */
.info-box { margin: 0 0 22px; padding: 14px 16px; border-radius: 11px; background: #ebf4ff; border: 1px solid #cfe2f7; color: #194e86; font-size: 14px; line-height: 1.5; }
.info-box strong { display: block; margin-bottom: 3px; color: #0f3d6e; }
.info-box p { margin: 0; }

/* Indicador de etapas: Identificação → Verificação → Nova senha */
.stepper { display: flex; justify-content: space-between; margin: 0 0 26px; padding: 0; list-style: none; counter-reset: passo; }
.stepper li { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 13px; font-weight: 650; color: #8da0b6; text-align: center; }
.stepper li::before {
  counter-increment: passo; content: counter(passo); position: relative; z-index: 1;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-weight: 800; background: #eef3f9; color: #8da0b6; border: 2px solid var(--border);
}
/* Linha que liga o centro da etapa anterior ao centro desta */
.stepper li + li::after { content: ""; position: absolute; top: 16px; right: 50%; width: 100%; height: 2px; background: var(--border); }
.stepper li.ativo { color: var(--text); }
.stepper li.ativo::before { background: var(--blue); border-color: var(--blue); color: #fff; }
.stepper li.feito { color: #2f7d32; }
.stepper li.feito::before { content: "✓"; background: #e6f9e9; border-color: #66c26b; color: #2f7d32; }
.stepper li.feito + li::after { background: #66c26b; }

/* Erro logo abaixo do campo (criado por AuthUI.erroCampo em auth/comum.js) */
.input-wrap input[aria-invalid="true"] { border-color: #d64545; background: #fffafa; }
.input-wrap input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(214,69,69,.12); }
.campo-erro { display: flex; gap: 7px; align-items: flex-start; margin: 8px 0 0; font-size: 13.5px; line-height: 1.4; color: #b42318; }
.campo-erro::before {
  content: "!"; flex: 0 0 auto; width: 17px; height: 17px; margin-top: 0; border-radius: 50%;
  display: grid; place-items: center; background: #d64545; color: #fff; font-size: 11px; font-weight: 800;
}

/* Indicador de carregamento nos botões principais durante as solicitações */
a.primary { text-decoration: none; }
.primary[aria-busy="true"] [aria-hidden="true"] { display: none; }
.primary[aria-busy="true"]::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; animation: auth-girar .8s linear infinite;
}
@keyframes auth-girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .primary[aria-busy="true"]::after { animation-duration: 2.4s; } }

/* Confirmação "Verifique seu e-mail" (primeiro acesso e recuperação de senha) */
.confirmacao { text-align: center; outline: none; }
.confirmacao-icone { width: 64px; height: 64px; margin: 2px auto 16px; border-radius: 50%; display: grid; place-items: center; background: #e6f9e9; color: #2f7d32; }
.confirmacao-icone svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.confirmacao h3 { margin: 0 0 8px; font-size: 23px; letter-spacing: -.02em; color: var(--text); }
.confirmacao p { margin: 0 0 10px; font-size: 15px; line-height: 1.55; color: #36536f; }
.confirmacao strong { color: var(--text); word-break: break-all; }
.confirmacao .confirmacao-dica { font-size: 14px; color: var(--muted); margin-bottom: 22px; }
.confirmacao .secondary[disabled] { opacity: .6; cursor: not-allowed; }
.confirmacao .notice { text-align: left; }

a:focus-visible, button:focus-visible, .remember input:focus-visible { outline: 2px solid #2681e2; outline-offset: 2px; }

/* ---------- Responsividade ---------- */
@media (max-width: 1280px) and (min-width: 901px) {
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 480px; }
}
/* Telas baixas (notebooks 1366x768, janela com barra do navegador): compacta para caber sem rolagem */
@media (min-width: 901px) and (max-height: 860px) {
  .page { padding-top: clamp(18px, 3.5vh, 40px); padding-bottom: clamp(18px, 3.5vh, 40px); }
  .panel { padding: clamp(26px, 3.8vh, 40px) clamp(32px, 3vw, 46px); }
  .sub { margin-bottom: 22px; }
  .field { margin-bottom: 15px; }
  .field label { margin-bottom: 7px; }
  .input-wrap input { height: 51px; }
  .options { margin: 2px 0 16px; }
  .primary { height: 51px; }
  .secondary { min-height: 45px; margin-top: 11px; }
  .bottom { margin-top: 18px; padding-top: 15px; }
  .copyright { margin-top: 11px; }
  .eyebrow { margin: 16px 0 10px; }
  .accent { margin: 10px 0 16px; }
  .hero h1 { margin-bottom: 14px; }
  .lead { margin-bottom: 24px; }
  .quote { padding-top: 22px; }
  .info-box { margin-bottom: 16px; padding: 11px 14px; }
  .stepper { margin-bottom: 18px; }
}
@media (min-width: 901px) and (max-height: 700px) {
  .quote { display: none; }
  .hero h1 { font-size: clamp(34px, 4vw, 58px); }
  .lead { font-size: 17px; margin-bottom: 20px; }
  .feature { padding: 15px 10px 13px; }
  .feature svg { width: 30px; height: 30px; margin-bottom: 7px; }
  .feature span { font-size: 13.5px; }
  .panel h2 { font-size: 27px; }
  .sub { margin: 6px 0 16px; }
  .input-wrap input { height: 47px; }
  .field { margin-bottom: 11px; }
  .field label { font-size: 14px; margin-bottom: 5px; }
  .primary { height: 47px; }
  .secondary { min-height: 41px; }
  .bottom { margin-top: 14px; padding-top: 12px; }
  .info-box { font-size: 13px; }
  .stepper li::before { width: 28px; height: 28px; font-size: 13px; }
  .stepper li + li::after { top: 14px; }
}
@media (max-width: 900px) {
  .page { grid-template-columns: 1fr; padding: 28px 22px 28px; gap: 26px; }
  .hero { min-height: auto; align-self: auto; }
  .hero h1 { font-size: clamp(33px, 7vw, 55px); }
  .hero .lead { margin-bottom: 15px; font-size: 16px; }
  .hero .features, .quote { display: none; }
  .eyebrow { margin: 8px 0; }
  .accent { margin: 10px 0 17px; }
  .logo img { width: 170px; margin: -10px 0 -10px -3px; }
  .panel { width: 100%; max-width: 560px; padding: 32px; }
  .page::after { background: linear-gradient(180deg, rgba(4,43,77,.9), rgba(4,42,74,.8)); }
}
@media (max-width: 768px) {
  .hero .lead { display: none; }
}
/* Telas de toque (celular em pé ou deitado, tablet): áreas de toque de ~44 px, independente da largura */
@media (pointer: coarse) {
  .eye { padding: 10px; right: 6px; }
  .options .remember, .options .link { min-height: 44px; display: flex; align-items: center; }
  .remember input { width: 20px; height: 20px; }
  .bottom > a { display: inline-flex; align-items: center; min-height: 44px; }
}
/* Celular (e celular deitado): cabeçalho compacto — só logo + "Intranet Corporativa" — e o formulário
   como área principal, visível logo ao abrir a página. A foto vira apenas um fundo discreto. */
@media (max-width: 600px), (max-width: 900px) and (max-height: 520px) {
  .page { padding: 20px 16px 28px; gap: 16px; }
  .hero { align-items: center; text-align: center; }
  .logo img { width: 156px; margin: -9px 0; }
  .eyebrow { margin: 6px 0 0; font-size: 11px; letter-spacing: .32em; }
  .hero h1, .accent, .hero .lead { display: none; }
  .page::after { background: linear-gradient(180deg, rgba(4,40,74,.95) 0%, rgba(4,42,74,.88) 100%); }
}
/* Celular: card com quase toda a largura, textos maiores e áreas de toque de ~44 px */
@media (max-width: 600px) {
  .panel { max-width: 480px; padding: 28px 22px; border-radius: 22px; }
  .panel h2 { font-size: 26px; }
  .sub { font-size: 15px; margin: 8px 0 24px; }
  .field { margin-bottom: 18px; }
  .input-wrap input { height: 54px; }
  .options { flex-direction: column; align-items: stretch; gap: 0; margin: 0 0 16px; font-size: 15px; }
  .primary { height: 54px; }
  .secondary { min-height: 52px; }
  .bottom { margin-top: 20px; padding-top: 14px; }
  .copyright { font-size: 13px; margin-top: 6px; }
  .stepper { margin-bottom: 22px; }
  .stepper li { font-size: 12px; }
  .confirmacao h3 { font-size: 21px; }
}
@media (max-width: 380px) {
  .page { padding: 16px 12px 24px; }
  .panel { padding: 24px 16px; border-radius: 18px; }
  .panel h2 { font-size: 24px; }
  .stepper li { font-size: 11.5px; }
  .stepper li::before { width: 28px; height: 28px; font-size: 13px; }
  .stepper li + li::after { top: 14px; }
}
