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

body.login-page {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  /* Empirys corporate v2 — red hero + cream-to-slate base, symmetric rule-of-thirds
     composition. Kept in sync with choose.php so pre/post-login feels consistent. */
  background-color: #F6F8FB;
  background-image:
    radial-gradient(ellipse 65% 48% at 50% -10%,  rgba(230,50,20,0.22), transparent 65%),
    radial-gradient(ellipse 55% 40% at 50% 110%,  rgba(230,50,20,0.10), transparent 62%),
    radial-gradient(ellipse 42% 32% at 88% 18%,   rgba(0,87,255,0.10),  transparent 60%),
    radial-gradient(ellipse 44% 34% at 12% 85%,   rgba(123,97,255,0.09),transparent 60%),
    linear-gradient(180deg, #FDFBF9 0%, #F6F8FB 45%, #F6F8FB 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow-x: hidden;
}

/* Fine 44×44 corporate grid — faded at the edges via radial mask so it doesn't
   compete with the red hero glow. */
body.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right,  rgba(15,23,42,0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15,23,42,0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 90% 75% at 50% 45%, #000 25%, transparent 85%);
          mask-image: radial-gradient(ellipse 90% 75% at 50% 45%, #000 25%, transparent 85%);
}

/* Red dot-mesh centred at top — adds density where the eye lands first. */
body.login-page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(230,50,20,0.12) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse 55% 40% at 50% 30%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse 55% 40% at 50% 30%, #000 20%, transparent 75%);
}

/* Lift the card above the background pseudo-layers. The `.lang-selector` is
   `position: fixed` with `z-index: 100`, so it's already on top — we mustn't
   override its positioning. */
.login-card-wrap { position: relative; z-index: 1; }

/* Accessibility: the static gradient stays, but we drop the fixed attachment
   (which can cause paint jank for motion-sensitive users). */
@media (prefers-reduced-motion: reduce) {
  body.login-page { background-attachment: scroll; }
}

/* ── LANGUAGE SELECTOR ─────────────────────────────────────────────────────
   Pill-style switcher, visually consistent with the post-login choose.php
   dropdown. Discrete white pill (fr-FR flag + label + chevron) → clean menu
   on click with full keyboard support (arrow keys / Home / End / Escape,
   driven by the inline script in pages/login.php).
   ─────────────────────────────────────────────────────────────────────── */
.lang-selector {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  color: #374151;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  transition: background 150ms, border-color 150ms, box-shadow 150ms;
}
.lang-btn:hover { background: #F9FAFB; border-color: #D1D5DB; }
/* Focus ring mirrors choose.php: `ring-2 ring-brand/40` — 2px blue ring at 40% alpha. */
.lang-btn:focus-visible {
  outline: none;
  border-color: #0057FF;
  box-shadow: 0 0 0 2px rgba(0,87,255,0.40);
}
.lang-btn .flag { font-size: 16px; line-height: 1; }
.lang-btn .label { /* visible by default; hidden on very small screens */ }
/* Static chevron — matches choose.php (no rotation on open). */
.lang-btn .chevron { width: 12px; height: 12px; color: #6B7280; }

.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(15,23,42,0.08);
  z-index: 101;
}
.lang-menu.open { display: block; }
/* Each menu item is wrapped in a <form> (CSRF-protected POST) → no margin so
   the click area spans the full width without gaps. */
.lang-menu form { margin: 0; display: block; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 150ms;
  text-align: left;
}
/* Parity with choose: hover = gray-50, focus = gray-100 (slightly darker so
   keyboard users can still tell where the focus ring landed). */
.lang-option:hover { background: #F9FAFB; }
.lang-option:focus { background: #F3F4F6; outline: none; }
.lang-option .flag { font-size: 16px; line-height: 1; }

/* ── CARD ──────────────────────────────────────────── */
.login-card-wrap {
  width: 100%;
  max-width: 576px;
}
.login-card {
  background: white;
  border-radius: 24px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 48px;
  display: flex;
  flex-direction: column;
}

/* Logo */
.login-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
}
.login-logo img {
  display: block;
  height: 72px;
  width: auto;
  object-fit: contain;
}

/* Heading */
.login-heading { text-align: center; margin-bottom: 32px; }
.login-heading h1 {
  font-size: 36px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}
.login-heading p {
  font-size: 18px;
  color: #4B5563;
  line-height: 1.5;
}

/* Error */
.login-error {
  background: #FEF2F2;
  border: 1.5px solid #FECACA;
  border-radius: 10px;
  padding: 12px 16px;
  color: #DC2626;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
}

/* Form */
.login-form { display: flex; flex-direction: column; gap: 20px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 500; color: #374151; }
.field input {
  height: 48px;
  border: 1.5px solid #E5E7EB;
  border-radius: 12px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 15px;
  color: #111827;
  background: white;
  outline: none;
  transition: border-color 200ms, box-shadow 200ms;
  width: 100%;
}
.field input:focus {
  border-color: #E63214;
  box-shadow: 0 0 0 3px rgba(230,50,20,0.10);
}
.field input::placeholder { color: #9CA3AF; }

/* Remember + forgot row */
.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #4B5563;
}
.remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #E63214;
  border-radius: 4px;
  cursor: pointer;
}
.forgot {
  font-size: 14px;
  font-weight: 500;
  color: #E63214;
  text-decoration: none;
  transition: color 150ms;
}
.forgot:hover { color: #C22911; }

/* Sign-in button */
.btn-signin {
  width: 100%;
  height: 48px;
  background: #E63214;
  color: white;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(230,50,20,0.25);
  transition: background 150ms, transform 100ms;
}
.btn-signin:hover { background: #C22911; }
.btn-signin:active { transform: scale(0.98); }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}
.divider-line { flex: 1; height: 1px; background: #E5E7EB; }
.divider span { font-size: 13px; color: #9CA3AF; white-space: nowrap; }

/* SSO button */
.btn-sso {
  width: 100%;
  height: 48px;
  background: white;
  border: 1.5px solid #E5E7EB;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 150ms, border-color 150ms;
}
.btn-sso:hover { background: #F9FAFB; border-color: #D1D5DB; }
.btn-sso svg { color: #6B7280; }

/* Footer */
.login-footer {
  text-align: center;
  font-size: 13px;
  color: #9CA3AF;
  padding-top: 24px;
  margin-top: 8px;
  border-top: 1px solid #F3F4F6;
}

/* Responsive */
@media (max-width: 640px) {
  .login-card { padding: 32px 24px; }
  .login-heading h1 { font-size: 28px; }
  .login-heading p { font-size: 15px; }
  .lang-selector { top: 16px; right: 16px; }
  /* Hide label on tiny screens — flag alone is enough to identify the pill. */
  .lang-btn .label { display: none; }
}
