/*
 * goHRMS sign-in.
 *
 * Scoped to the authentication pages only — deliberately not part of app.css,
 * whose palette is the legacy teal. The blue here matches the Flutter app's
 * AppColors.primary so the mobile and web sign-in read as one product.
 *
 * The visual language stays in the same family as the rest of goHRMS: flat,
 * bordered, enterprise. No glassmorphism, no hover-lift — this is a page users
 * look at for three seconds, not a landing page.
 */

:root {
  --lg-primary: #2563EB;
  --lg-primary-dark: #1D4ED8;
  --lg-primary-tint: #EFF6FF;
  --lg-success: #16A34A;
  --lg-danger: #DC2626;
  --lg-ink: #0F172A;
  --lg-body: #475569;
  --lg-muted: #94A3B8;
  --lg-border: #E2E8F0;
  --lg-surface: #FFFFFF;
  --lg-field: #F8FAFC;

  --radius-card: 16px;
  --radius-input: 10px;
  --radius-pill: 999px;
  --shadow-card: 0 20px 40px -12px rgba(37, 99, 235, 0.18),
                 0 4px 10px rgba(15, 23, 42, 0.04);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--lg-body);
  background: linear-gradient(135deg, #EFF6FF 0%, #FFFFFF 45%, #E0E7FF 100%);
}

/* ── Brand ───────────────────────────────────────────────────────────── */

.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand img { height: 48px; width: auto; }
.login-brand p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--lg-muted);
  letter-spacing: 0.02em;
}

/* ── Card ────────────────────────────────────────────────────────────── */

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--lg-surface);
  border: 1px solid var(--lg-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 36px;
  transition: max-width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Widened only while the credentials + QR two-column view is showing. */
.login-card.credentials-mode { max-width: 780px; }

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--lg-ink);
  letter-spacing: -0.2px;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  color: var(--lg-ink);
  letter-spacing: -0.2px;
}

.login-card .subtitle {
  margin: 0 0 24px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--lg-body);
}

.login-card .subtitle strong { color: var(--lg-ink); font-weight: 600; }

/* ── Two-column split (credentials | QR) ─────────────────────────────── */

.login-split { display: flex; gap: 32px; align-items: stretch; }
.login-split .col-form { flex: 1 1 0; min-width: 0; }
.login-split .col-divider {
  width: 1px;
  background: var(--lg-border);
  flex: 0 0 1px;
}
.login-split .col-qr {
  flex: 0 0 232px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ── Fields ──────────────────────────────────────────────────────────── */

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--lg-body);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--lg-ink);
  background: var(--lg-field);
  border: 1.5px solid var(--lg-border);
  border-radius: var(--radius-input);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.form-control:focus {
  outline: none;
  background: var(--lg-surface);
  border-color: var(--lg-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.form-control.is-invalid {
  border-color: var(--lg-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.10);
}

.field-group { margin-bottom: 18px; }

/* ── Segmented code input ────────────────────────────────────────────── */

.otp-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 6px 0 4px;
}

.otp-box {
  width: 46px;
  height: 52px;
  padding: 0;
  text-align: center;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--lg-ink);
  background: var(--lg-field);
  border: 1.5px solid var(--lg-border);
  border-radius: var(--radius-input);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.otp-box:focus {
  outline: none;
  background: var(--lg-surface);
  border-color: var(--lg-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.otp-box.filled { background: var(--lg-surface); border-color: #CBD5E1; }
.otp-group.is-invalid .otp-box { border-color: var(--lg-danger); }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn-primary-lg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--lg-primary);
  border: none;
  border-radius: var(--radius-input);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn-primary-lg:hover { background: var(--lg-primary-dark); }
.btn-primary-lg:active { transform: scale(0.99); }
.btn-primary-lg:disabled { background: #93C5FD; cursor: not-allowed; }
.btn-primary-lg:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.link-btn {
  padding: 0;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--lg-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

.muted-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--lg-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.muted-link:hover { color: var(--lg-body); text-decoration: underline; }

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--lg-body);
}
.check-inline input { width: 15px; height: 15px; accent-color: var(--lg-primary); }

.center { text-align: center; }
.stack-sm > * + * { margin-top: 10px; }
.mt-lg { margin-top: 24px; }
.mt-md { margin-top: 16px; }

/* ── Status messages ─────────────────────────────────────────────────── */

#login-message {
  min-height: 20px;
  margin-bottom: 16px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
}
#login-message[data-variant="error"] { color: var(--lg-danger); }
#login-message[data-variant="success"] { color: var(--lg-success); }
#login-message[data-variant="info"] { color: var(--lg-body); font-weight: 500; }

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  border-radius: var(--radius-input);
  border: 1px solid;
}
.alert-error {
  color: #991B1B;
  background: #FEF2F2;
  border-color: #FECACA;
}
.alert-info {
  color: #1E40AF;
  background: var(--lg-primary-tint);
  border-color: #BFDBFE;
}
.alert-warning {
  color: #92400E;
  background: #FFFBEB;
  border-color: #FDE68A;
}

/* ── QR panel ────────────────────────────────────────────────────────── */

.qr-headline {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--lg-ink);
  margin-bottom: 4px;
}
.qr-sub {
  font-size: 12.5px;
  color: var(--lg-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}
.qr-frame {
  padding: 10px;
  background: #fff;
  border: 1.5px solid var(--lg-border);
  border-radius: 12px;
  line-height: 0;
}
.qr-frame img { width: 168px; height: 168px; display: block; }
.qr-status {
  margin-top: 12px;
  min-height: 18px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--lg-muted);
}
.qr-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--lg-primary);
  animation: qr-pulse 1.6s ease-in-out infinite;
}
@keyframes qr-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.qr-panel.is-expired .qr-frame img { filter: grayscale(1) opacity(0.35); }
.qr-panel.is-expired .qr-dot { display: none; }

/* ── Enrolment secret ────────────────────────────────────────────────── */

.secret-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 14px;
  background: var(--lg-field);
  border: 1px solid var(--lg-border);
  border-radius: var(--radius-input);
}
.secret-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--lg-ink);
  word-break: break-all;
}

.step-list {
  margin: 0 0 20px;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--lg-body);
}

/* ── Footer ──────────────────────────────────────────────────────────── */

.login-footer { margin-top: 24px; text-align: center; }
.login-footer small { font-size: 12px; color: var(--lg-muted); }

/* ── Spinner ─────────────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 780px) {
  .login-card.credentials-mode { max-width: 440px; }
  .login-split { flex-direction: column; gap: 24px; }
  .login-split .col-divider { width: 100%; height: 1px; flex: 0 0 1px; }
}

@media (max-width: 480px) {
  body { padding: 16px; }
  .login-card { padding: 28px 20px; }
  .login-brand img { height: 40px; }
  .otp-box { width: 40px; height: 48px; font-size: 18px; }
  .otp-group { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
