/* Auth pages (Phase 1): full-screen card, controls, forms. Tokens only. */

.auth-page {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--color-primary-soft), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--color-success-soft), transparent 55%),
    var(--color-bg);
}

/* Theme + language used to render as two separate floating chips with a gap
   between them — read as disconnected clutter over the gradient background.
   Merged into one pill (single border/shadow, thin divider between segments)
   so it reads as one deliberate control, not two stray buttons. */
.auth-controls {
  position: fixed;
  /* Clear the notch/status bar (env inset) and always paint above the card —
     on the near-fullscreen mobile card they were slipping under both. */
  top: max(var(--space-4), calc(env(safe-area-inset-top, 0px) + var(--space-3)));
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  align-items: stretch;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden; /* clips both children to the pill's rounded ends */
}
.auth-icon-btn,
.auth-lang {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 0 var(--space-4);
  border: 0;
  background: transparent;
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  letter-spacing: 0.02em;
  transition: background var(--dur-fast) var(--ease-in-out), color var(--dur-fast) var(--ease-in-out);
}
.auth-lang { border-left: 1px solid var(--color-border); }
.auth-icon-btn:hover,
.auth-lang:hover { background: var(--color-surface-hover); color: var(--color-fg); }
.auth-icon-btn .icon { width: 18px; height: 18px; }

.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: var(--space-8);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: auth-in var(--dur-slow) var(--ease-out) both;
}
/* Gradient-ring accent on the app's own chrome only — never applied to a
   customer's white-label logo/name below, which must render exactly as
   configured in Налаштування → Компанія. */
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: var(--brand-gradient);
  opacity: 0.35;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
@keyframes auth-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.auth-brand {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.auth-brand__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.auth-logo {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: var(--font-extrabold);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
}
.auth-brand__name { font-weight: var(--font-bold); font-size: var(--text-lg); }
/* Default HRlume wordmark — wrapped in a white chip so the logo's own dark
   navy text stays legible on a dark-theme auth card (a no-op in light theme,
   where the card is already white). Not applied to customer logos below,
   which should sit on the app's own surface as designed. */
.auth-brand-full { height: 32px; width: auto; object-fit: contain; background: #fff; border-radius: var(--radius-sm); padding: var(--space-1) var(--space-2); }
.brand-logo { width: 40px; height: 40px; object-fit: contain; border-radius: var(--radius-md); }
.auth-powered {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  opacity: 0.55;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}
.auth-powered img { width: 16px; height: 16px; object-fit: contain; border-radius: 4px; }

.auth-loading { display: grid; place-items: center; min-height: 180px; }

.auth-badge {
  display: inline-block;
  margin-bottom: var(--space-3);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.auth-title { font-size: var(--text-2xl); margin-bottom: var(--space-1); }
.auth-subtitle { color: var(--color-fg-muted); font-size: var(--text-sm); margin-bottom: var(--space-6); }

.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-field { display: flex; flex-direction: column; gap: var(--space-1); }
.auth-field__label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-on-surface); }
.auth-input {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4);
  font: inherit;
  /* 16px, not 14 — smaller triggers iOS Safari's focus auto-zoom on mobile. */
  font-size: var(--text-base);
  color: var(--color-fg);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--dur-fast) var(--ease-in-out), box-shadow var(--dur-fast) var(--ease-in-out);
}
/* Password field with a show/hide toggle: input reserves room on the right so
   the eye button never overlaps the typed value. */
.auth-input--password { padding-right: var(--space-12); }
.auth-input-wrap { position: relative; display: flex; }
.auth-pw-toggle {
  position: absolute; top: 0; right: 0; height: 48px; width: 48px;
  display: grid; place-items: center;
  border: 0; background: transparent; color: var(--color-fg-subtle);
  border-radius: var(--radius-lg); cursor: pointer;
}
.auth-pw-toggle:hover { color: var(--color-fg); }
.auth-pw-toggle .icon { width: 20px; height: 20px; }
.auth-input::placeholder { color: var(--color-fg-subtle); }
.auth-input:focus {
  outline: none;
  border-color: var(--color-ring);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.auth-field__err { min-height: 1em; font-size: var(--text-xs); color: var(--color-danger); }

.auth-form-error { min-height: 1em; font-size: var(--text-sm); color: var(--color-danger); }
.auth-form-ok { min-height: 1em; font-size: var(--text-sm); color: var(--color-success); }

.auth-submit {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 48px;
  margin-top: var(--space-1);
  font-size: var(--text-base);
  box-shadow: var(--shadow-sm);
  transition: background var(--dur-fast) var(--ease-in-out), box-shadow var(--dur-fast) var(--ease-in-out), transform var(--dur-fast) var(--ease-out);
}
.auth-submit:hover:not(:disabled) { box-shadow: var(--shadow-md); }
/* Same gradient-ring sheen as .auth-card, layered on the fill this button
   already has (.btn--primary) — no cursor-follow motion, just a static
   gloss (that "cheap" mouse-tracking effect was tried and rejected). */
.auth-submit::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(180deg, rgba(255,255,255,.5) 0%, rgba(255,255,255,.1) 30%,
    rgba(255,255,255,0) 50%, rgba(255,255,255,0) 65%, rgba(255,255,255,.2) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.auth-submit[data-loading='1'] { position: relative; color: transparent; pointer-events: none; }
.auth-submit[data-loading='1']::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  animation: app-spin 0.7s linear infinite;
}
.auth-link {
  align-self: center;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-primary);
}
.auth-link:hover { text-decoration: underline; }

/* Minimal authenticated shell (placeholder until Phase 3). */
.app-topbar {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.app-topbar__brand { display: flex; align-items: center; gap: var(--space-3); font-weight: var(--font-bold); }
.app-topbar__actions { display: flex; align-items: center; gap: var(--space-3); }
.app-topbar__user { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-fg-muted); }
.app-placeholder { display: grid; place-items: center; gap: var(--space-2); min-height: calc(100dvh - var(--header-height)); text-align: center; padding: var(--space-8); }
.app-placeholder h1 { font-size: var(--text-3xl); }
.app-placeholder p { color: var(--color-fg-muted); }

@media (max-width: 480px) {
  /* Mobile-first login: the card fills the width (calc(100% - 32px)) and reads
     as a near-fullscreen sheet rather than a shrunk desktop card. */
  .auth-page { padding: var(--space-4); }
  .auth-card { max-width: none; padding: var(--space-8); border-radius: var(--radius-2xl); }
  .app-topbar__user { display: none; }
}

/* SSO (Phase 57) — divider + provider button under the password form.
   Tokens only; the button reuses .btn/.auth-submit sizing so it lines up
   with the primary submit above it. */
.auth-divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0; color: var(--color-fg-muted); font-size: var(--text-sm); }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--color-border); }
.auth-sso-btn { display: flex; align-items: center; justify-content: center; gap: var(--space-2); text-decoration: none; }
.auth-sso-btn .icon { width: 18px; height: 18px; }
