/* ============================================================
   LOGIN — Tema Dark
   ============================================================
   Aplicado em login.jsp e login_localhost.jsp. Carrega ANTES
   do principal-1.9.css pra que as regras especificas vencam o
   layout legado.

   Layout (>=1024px):
     [ painel-marca ESQ ] [ card-login 460px CENTRO ] [ spacer DIR ]
   Em <1024px o painel-marca esconde e o card-login centraliza.
   ============================================================ */

/* Design tokens (replicados aqui pra nao depender do dark.css global
   que so ativa via [data-theme="dark"]). A tela de login eh sempre dark. */
:root {
  --bg-base: #0A0E1A;
  --bg-surface: #141A26;
  --bg-elevated: #232B3A;
  --bg-input: #0F1420;
  --bg-hover: rgba(255, 255, 255, 0.04);

  --text-primary: #E8ECF3;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --text-faint: #4B5563;

  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.04);

  --brand: #E8945D;
  --brand-hover: #F0A574;
  --brand-active: #D17F4A;
  --brand-soft: rgba(232, 148, 93, 0.14);
  --brand-ring: rgba(232, 148, 93, 0.32);

  --info: #60A5FA;
  --danger: #F87171;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
}

/* ===== Reset / base ===== */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
* { box-sizing: border-box; }
::selection { background: rgba(232, 148, 93, 0.22); color: var(--text-primary); }

/* ===== Decoracoes de fundo ===== */
body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}
/* Glow laranja superior esquerdo */
body::before {
  top: -200px;
  left: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(232, 148, 93, 0.15), transparent 60%);
  filter: blur(40px);
}
/* Glow azul inferior direito */
body::after {
  bottom: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.08), transparent 55%);
  filter: blur(40px);
}
/* Grid sutil */
.login-grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.014) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

/* ===== Layout principal ===== */
.login-page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  padding: 40px 24px 80px;
  gap: 60px;
}
@media (min-width: 1024px) {
  .login-page {
    grid-template-columns: minmax(360px, 480px) 460px 1fr;
    justify-items: stretch;
    padding: 60px 80px 100px;
    gap: 80px;
  }
}

/* ===== Painel de marca (esquerda) ===== */
.login-brand {
  display: none;
}
@media (min-width: 1024px) {
  .login-brand {
    display: block;
    max-width: 480px;
    align-self: center;
  }
}
.login-brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}
.login-brand-tile {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-active));
  display: grid;
  place-items: center;
  box-shadow: 0 12px 32px rgba(232, 148, 93, 0.32);
}
.login-brand-tile svg {
  width: 28px;
  height: 28px;
  color: #1a0f08;
}
.login-brand-name {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.login-brand-name em {
  color: var(--brand);
  font-style: normal;
}
.login-brand-tagline {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 0 0 16px;
}
.login-brand-tagline em {
  color: var(--brand);
  font-style: normal;
}
.login-brand-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 420px;
  margin: 0 0 36px;
}
.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.login-brand-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.login-brand-feature-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.login-brand-feature-icon svg {
  width: 14px;
  height: 14px;
}
.login-brand-feature-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.login-brand-feature-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* Feature em destaque (emissao de notas fiscais) */
.login-brand-feature.is-highlight {
  background: linear-gradient(135deg, rgba(232, 148, 93, 0.10), rgba(232, 148, 93, 0.03));
  border: 1px solid rgba(232, 148, 93, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
}
.login-brand-feature.is-highlight::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--brand), var(--brand-active));
}
.login-brand-feature.is-highlight .login-brand-feature-icon {
  background: linear-gradient(135deg, var(--brand), var(--brand-active));
  color: #1a0f08;
  box-shadow: 0 4px 12px rgba(232, 148, 93, 0.32);
}
.login-brand-feature.is-highlight .login-brand-feature-icon svg {
  width: 15px;
  height: 15px;
}
.login-brand-feature.is-highlight .login-brand-feature-title {
  color: var(--text-primary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.login-brand-feature-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand);
  color: #1a0f08;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Badge dual (Online · Offline) — pontos verde/azul + texto claro */
.login-brand-feature-badge.is-dual {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  border: 1px solid rgba(232, 148, 93, 0.25);
  font-weight: 600;
  gap: 5px;
  padding: 3px 10px;
}
.login-brand-feature-badge.is-dual .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.login-brand-feature-badge.is-dual .dot.is-online {
  background: #34D399;
  box-shadow: 0 0 6px #34D399;
}
.login-brand-feature-badge.is-dual .dot.is-offline {
  background: var(--info, #60A5FA);
  box-shadow: 0 0 6px var(--info, #60A5FA);
}
.login-brand-feature-badge.is-dual .dot-sep {
  color: var(--text-muted);
  margin: 0 1px;
}

/* ===== Card de login (centro) ===== */
.login-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 32px;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 0 100px rgba(232, 148, 93, 0.06);
  position: relative;
}

/* Header do card */
.login-card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 28px;
}
.login-card-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.login-card-brand-tile {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-active));
  display: grid;
  place-items: center;
  color: #1a0f08;
  font-weight: 700;
  font-size: 17px;
}
.login-card-brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.login-card-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0 0 6px;
}
.login-card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* ===== Form ===== */
.login-form { width: 100%; }
.login-field { margin-bottom: 18px; }
.login-field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.login-field-label .forgot-link {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  color: var(--brand);
  text-decoration: none;
  transition: color 150ms ease;
}
.login-field-label .forgot-link:hover { color: var(--brand-hover); }

/* Input wrapper com icone */
.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.login-input-wrap .login-input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.login-input-wrap .login-input-icon svg {
  width: 16px;
  height: 16px;
}

/* Input em si */
.login-card .input-custom,
.login-card input[type="text"],
.login-card input[type="email"],
.login-card input[type="password"] {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all 150ms ease;
  box-sizing: border-box;
  margin: 0;
}
.login-card .input-custom::placeholder { color: var(--text-muted); }
.login-card .input-custom:focus {
  outline: none;
  background: var(--bg-elevated);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.login-card .input-custom:focus ~ .login-input-icon,
.login-card .login-input-wrap:focus-within .login-input-icon {
  color: var(--brand);
}

/* Botao olho (mostrar/esconder senha) */
.login-card .login-toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 150ms ease;
  z-index: 2;
}
.login-card .login-toggle-password:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.login-card .login-toggle-password i {
  font-size: 14px;
}

/* Mensagem de erro */
.login-card #mensagens-retorno { margin: 0 0 18px; }
.login-card #mensagens-retorno.invisible { display: none; }
.login-card #erro.alert.alert-danger {
  display: block;
  padding: 11px 14px;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 9px;
  background: rgba(248, 113, 113, 0.08);
  color: var(--danger);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-shadow: none;
  box-shadow: none;
  margin: 0;
}

/* ===== Checkbox "Manter conectado" ===== */
.login-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 22px;
  cursor: pointer;
  user-select: none;
}
.login-remember input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.login-remember .check {
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-input);
  display: grid;
  place-items: center;
  transition: all 150ms ease;
  flex-shrink: 0;
}
.login-remember input:checked + .check {
  background: var(--brand);
  border-color: var(--brand);
}
.login-remember input:checked + .check::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #1a0f08;
  border-bottom: 2px solid #1a0f08;
  transform: rotate(-45deg) translate(1px, -1px);
}
.login-remember input:focus-visible + .check {
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.login-remember-label {
  font-size: 13px;
  color: var(--text-primary);
}

/* ===== Botao Entrar ===== */
.login-card .btn,
.login-card .login-submit {
  width: 100%;
  height: 48px;
  background: var(--brand);
  color: #1a0f08;
  border: none;
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 150ms ease;
  box-shadow: 0 8px 24px rgba(232, 148, 93, 0.22);
  margin: 0;
}
.login-card .btn:hover,
.login-card .login-submit:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(232, 148, 93, 0.32);
}
.login-card .btn:active,
.login-card .login-submit:active {
  transform: translateY(0);
}
.login-card .btn svg,
.login-card .login-submit svg { width: 14px; height: 14px; }

/* ===== Divisor "ou" ===== */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 18px;
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: lowercase;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ===== Signup link ===== */
.login-signup {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.login-signup a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
  transition: color 150ms ease;
}
.login-signup a:hover { color: var(--brand-hover); }

/* ===== Footer fixo ===== */
.login-footer {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 16px;
  pointer-events: none;
  z-index: 2;
}
.login-footer span,
.login-footer a {
  pointer-events: auto;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 150ms ease;
}
.login-footer a:hover { color: var(--text-primary); }
.login-footer .sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-faint);
  pointer-events: none;
}

/* ===== Loading overlay (mantem o spinner existente) ===== */
#loading .loading-box {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--text-primary) !important;
}
#loading #loading-text {
  color: var(--text-primary) !important;
}

/* Esconder elementos legados que nao usamos mais */
.login-card .logo-login,
.login-card h1 { display: none !important; }

/* ===== Container legado .container > .login-box ===== */
/* O JSP atual usa .container > .login-box — neutralizamos. */
.container { all: unset; }
.login-box { all: unset; }
