/* Shared look for every signed-out page: the landing/sign-in page, both
   password-reset pages and the access-denied page (see includes/auth_layout.php).
   Self-contained on purpose - these pages no longer load css/style.css, so the
   handful of colours it shares with the app are repeated here as --a-* tokens. */
:root {
  --a-navy: #1b2a4a;
  --a-navy-dark: #121d33;
  --a-accent: #2563eb;
  --a-purple: #7e22ce;
  --a-ink: #0f172a;
  --a-text: #334155;
  --a-muted: #64748b;
  --a-line: #dbe1ee;
  --a-field: #f8fafc;
}

* { box-sizing: border-box; }

/* Same hidden scrollbar as the rest of the app (css/style.css). */
html { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar { display: none; }

body.auth-body {
  margin: 0;
  min-height: 100vh; min-height: 100dvh;
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  color: var(--a-ink);
  background: #0f172a;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Backdrop: deep navy (the app's own navy family) with soft blue, purple
   and teal glows and three slowly drifting blurred orbs ---- */
.auth-bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(1100px 620px at 10% -12%, rgba(37,99,235,0.42), transparent 62%),
    radial-gradient(900px 580px at 100% 0%, rgba(126,34,206,0.36), transparent 62%),
    radial-gradient(900px 560px at 50% 118%, rgba(15,118,110,0.30), transparent 62%),
    linear-gradient(165deg, #1b2a4a 0%, #121d33 55%, #0b1220 100%);
}
.auth-bg .orb { position: absolute; border-radius: 50%; filter: blur(64px); opacity: 0.4; animation: orbFloat 16s ease-in-out infinite alternate; }
.auth-bg .o1 { width: 340px; height: 340px; left: -100px; top: 16%; background: #2563eb; }
.auth-bg .o2 { width: 280px; height: 280px; right: -80px; top: 46%; background: #7e22ce; animation-delay: -5s; }
.auth-bg .o3 { width: 250px; height: 250px; left: 38%; bottom: -110px; background: #0f766e; animation-delay: -9s; }
.auth-shell {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 84px 16px 22px;
}

/* ---- The card: narrow, with the avatar hanging half-way over its top edge ---- */
.auth-card {
  position: relative;
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, rgba(37,99,235,0.07), rgba(255,255,255,0) 160px), #fff;
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 26px;
  padding: 76px 34px 30px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 34px 80px -18px rgba(0,0,0,0.65),
    0 10px 28px -10px rgba(0,0,0,0.4);
  animation: cardIn 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.auth-avatar {
  position: absolute; left: 50%; top: 0;
  width: 112px; height: 112px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  isolation: isolate;
  z-index: 2;
}
/* The light, cloudy glow sitting behind the avatar. */
.auth-avatar::before {
  content: ''; position: absolute; inset: -38px; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(120,160,255,0.85) 0%, rgba(168,85,247,0.55) 46%, rgba(255,255,255,0) 72%);
  filter: blur(16px);
  animation: glowPulse 5s ease-in-out infinite;
}
.auth-avatar-inner {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  background: #fff; box-shadow: 0 0 0 6px #fff, 0 14px 30px rgba(30,41,90,0.20);
  display: flex; align-items: center; justify-content: center;
  color: var(--a-accent);
}
.auth-avatar-inner img { width: 100%; height: 100%; object-fit: cover; }
.auth-avatar-inner img.logo { object-fit: contain; padding: 16px; }
.auth-avatar-inner.initial,
.auth-avatar-inner.icon {
  background: linear-gradient(135deg, var(--a-accent), var(--a-purple)); color: #fff;
}
.auth-avatar-inner.initial { font-size: 46px; font-weight: 700; }
.auth-avatar-inner.warn { background: linear-gradient(135deg, #f59e0b, #dc2626); color: #fff; }

/* ---- Text ---- */
.auth-title { margin: 0 0 6px; text-align: center; font-size: 25px; line-height: 1.2; font-weight: 800; letter-spacing: -0.02em; color: var(--a-ink); }
.auth-title.small { font-size: 20px; }
.auth-sub { margin: 0 0 20px; text-align: center; color: var(--a-muted); font-size: 13.5px; line-height: 1.5; }
.auth-sub strong { color: var(--a-text); }

.auth-rolebadge {
  display: table; margin: 0 auto 18px; padding: 4px 12px; border-radius: 100px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: #eef2ff; color: #3730a3;
}

.auth-roles { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.auth-roles span {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 100px;
  background: #f1f5f9; color: #475569; font-size: 11.5px; font-weight: 600;
}
.auth-roles svg { color: var(--a-accent); }

/* ---- Fields ---- */
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; margin: 0 0 7px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em; color: var(--a-text); }
.auth-input { position: relative; }
.auth-input > svg {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  color: #94a3b8; pointer-events: none; transition: color 0.15s;
}
.auth-input input {
  width: 100%; height: 48px; padding: 0 44px;
  border: 1.5px solid var(--a-line); border-radius: 14px;
  background: var(--a-field); color: var(--a-ink);
  font: inherit; font-size: 14.5px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.auth-input input::placeholder { color: #a3aec2; }
.auth-input input:focus { border-color: var(--a-accent); background: #fff; box-shadow: 0 0 0 4px rgba(37,99,235,0.14); }
.auth-input:focus-within > svg { color: var(--a-accent); }
.auth-input input.is-match { border-color: #16a34a; }
.auth-input input.is-mismatch { border-color: #ef4444; }
.auth-input input[type="date"] { padding-right: 14px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: none; border-radius: 10px;
  color: #94a3b8; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.pw-toggle:hover { color: var(--a-accent); background: #eef2ff; }

.pw-meter { display: flex; gap: 5px; margin: 9px 2px 0; }
.pw-meter i { flex: 1; height: 4px; border-radius: 4px; background: #e2e8f0; transition: background 0.2s; }
.pw-meter[data-level="1"] i:nth-child(-n+1) { background: #ef4444; }
.pw-meter[data-level="2"] i:nth-child(-n+2) { background: #f59e0b; }
.pw-meter[data-level="3"] i:nth-child(-n+3) { background: #84cc16; }
.pw-meter[data-level="4"] i { background: #16a34a; }
.pw-hint { margin: 5px 2px 0; min-height: 15px; font-size: 11.5px; color: var(--a-muted); }

/* ---- Buttons & links ---- */
.auth-btn {
  position: relative; display: block; width: 100%; height: 50px; margin-top: 8px;
  border: 0; border-radius: 100px; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  text-align: center; text-decoration: none; line-height: 50px; color: #fff;
  background: linear-gradient(135deg, var(--a-navy), var(--a-navy-dark));
  box-shadow: 0 14px 28px -10px rgba(15,23,42,0.55);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.auth-btn:hover { transform: translateY(-1px); box-shadow: 0 18px 32px -10px rgba(15,23,42,0.6); filter: brightness(1.1); text-decoration: none; }
.auth-btn:active { transform: translateY(0); }
.auth-btn.is-loading { color: transparent; pointer-events: none; }
.auth-btn.is-loading::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border: 2.5px solid rgba(255,255,255,0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite;
}

.auth-links { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; font-size: 13px; }
.auth-links form { margin: 0; }
.auth-link, .auth-links a, .auth-link-btn {
  background: none; border: 0; padding: 0; font: inherit; font-size: 13px; cursor: pointer;
  color: var(--a-accent); font-weight: 600; text-decoration: none;
}
.auth-links a:hover, .auth-link-btn:hover { text-decoration: underline; }
.auth-link, .auth-links a, .auth-link-btn { display: inline-flex; align-items: center; min-height: 24px; }   /* a comfortable target (WCAG 2.2: 24 px) */

.auth-switch { display: flex; background: #eef2f9; border-radius: 100px; padding: 4px; margin: 0 0 18px; }
.auth-switch a { flex: 1; text-align: center; padding: 9px 10px; border-radius: 100px; font-size: 12.5px; font-weight: 700; color: var(--a-muted); text-decoration: none; transition: background 0.15s, color 0.15s; }
.auth-switch a:hover { color: var(--a-ink); }
.auth-switch a.active { background: #fff; color: var(--a-ink); box-shadow: 0 4px 12px -4px rgba(30,41,90,0.28); }

/* ---- Messages ---- */
.auth-alert { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; padding: 11px 13px; border: 1px solid; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.auth-alert svg { flex-shrink: 0; margin-top: 1px; }
.auth-alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; animation: shake 0.45s; }
.auth-alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.auth-alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.auth-foot { display: flex; align-items: center; justify-content: center; gap: 6px; max-width: 400px; margin: 18px 0 0; text-align: center; color: rgba(226,232,240,0.72); font-size: 12px; line-height: 1.4; }
.auth-foot svg { flex-shrink: 0; }

/* ---- Motion ---- */
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes glowPulse { 0%, 100% { opacity: 0.8; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes orbFloat { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(30px, -26px, 0) scale(1.12); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) {
  .auth-card, .auth-bg .orb, .auth-avatar::before, .auth-alert.error { animation: none; }
  .auth-btn { transition: none; }
}

/* Phones and tablets: 16px fields, so iOS does not zoom the page when one is focused. */
@media (max-width: 900px) {
  .auth-input input { font-size: 16px; }
}

/* ---- Small screens: same card, tighter ---- */
@media (max-width: 480px) {
  .auth-shell { padding: 74px 12px 22px; }
  .auth-card { padding: 70px 22px 24px; border-radius: 24px; }
  .auth-title { font-size: 23px; }
}
@media (max-height: 640px) {
  .auth-shell { padding-top: 62px; padding-bottom: 16px; }
  .auth-avatar { width: 88px; height: 88px; }
  .auth-avatar-inner.initial { font-size: 36px; }
  .auth-avatar-inner img.logo { padding: 12px; }
  .auth-card { padding-top: 58px; }
  .auth-sub { margin-bottom: 14px; }
  .auth-roles, .auth-rolebadge { margin-bottom: 12px; }
  .auth-field { margin-bottom: 10px; }
}
