/*
 * Suppress browser default focus outline on mouse/programmatic focus.
 * Keyboard navigation (:focus-visible) retains its outline for accessibility.
 */
*:focus:not(:focus-visible) {
  outline: none;
}

html,
body {
  height: 100%;
}

:root body {
  font-family: var(--font-body, 'Figtree', system-ui, -apple-system, sans-serif);
}

@keyframes auth-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Auth page shell — responsive padding matching original Tamagui $gtXs/$gtSm ===== */

.auth-page-shell {
  --auth-page-bg: #151919;
  --auth-card-bg: #101414;
  --auth-card-border: rgb(255 255 255 / 0.36);
  --auth-control-border: rgb(255 255 255 / 0.44);
  --auth-control-border-hover: rgb(255 255 255 / 0.58);
  --auth-control-border-focus: var(--auth-primary-bg-hover, #43a9bd);
  --auth-input-placeholder: rgb(238 246 247 / 0.58);
  --auth-label-bg: var(--auth-card-bg);
  --auth-primary-bg: #3a98ad;
  --auth-primary-bg-hover: #43a9bd;
  --auth-primary-bg-press: #32899d;
  --auth-primary-fg: #050708;
  --auth-primary-hairline-hover: #6dc8dd;
  --auth-primary-hairline-press: #7dd8ee;
  --auth-secondary-bg: #202828;
  --auth-secondary-bg-hover: #283232;
  --auth-secondary-bg-press: #182020;
  --auth-secondary-fg: #eef6f7;
  --auth-secondary-hairline-hover: #464f4f;
  --auth-secondary-hairline-press: #545d5d;
  --loading-inline-size: 16px;
  --loading-inline-border: 3px;
  --loading-rotation-ms: 800ms;
  --auth-subtle-foreground: color-mix(
    in oklab,
    hsl(var(--foreground)) 74%,
    hsl(var(--muted-foreground)) 26%
  );
  min-height: 100vh;
  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 10px;
  background: var(--auth-page-bg);
  color: hsl(var(--foreground));
}

[data-color-scheme='light'] .auth-page-shell,
.t_light .auth-page-shell {
  --auth-page-bg: #f3f7f8;
  --auth-card-bg: #ffffff;
  --auth-card-border: rgb(0 0 0 / 0.22);
  --auth-control-border: rgb(0 0 0 / 0.34);
  --auth-control-border-hover: rgb(0 0 0 / 0.46);
  --auth-control-border-focus: var(--auth-primary-bg, #2f879b);
  --auth-input-placeholder: rgb(9 30 34 / 0.52);
  --auth-primary-bg: #2f879b;
  --auth-primary-bg-hover: #29798b;
  --auth-primary-bg-press: #226a7b;
  --auth-primary-fg: #041012;
  --auth-primary-hairline-hover: #005b6e;
  --auth-primary-hairline-press: #004d5f;
  --auth-secondary-bg: #eef5f6;
  --auth-secondary-bg-hover: #e2eef0;
  --auth-secondary-bg-press: #d5e4e7;
  --auth-secondary-fg: #091e22;
  --auth-secondary-hairline-hover: #bdc4c5;
  --auth-secondary-hairline-press: #adb4b5;
}

.auth-frame {
  width: 100%;
  position: relative;
  z-index: 1;
}

.auth-card {
  padding: 16px 16px 16px;
  box-sizing: border-box;
}

@media (min-width: 660px) {
  .auth-page-shell {
    padding: 24px 24px;
  }

  .auth-frame {
    max-width: 460px;
  }

  .auth-card {
    padding: 22px 24px 24px;
  }
}

@media (min-width: 800px) {
  .auth-frame {
    max-width: 500px;
  }
}

/* ===== Outlined floating-label input ===== */

.auth-outlined-field {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  margin-top: 6px;
  border-radius: calc(var(--radius, 0.5625rem) * 1.56);
  cursor: text;
}

.auth-outlined-fieldset {
  position: absolute;
  inset: -6px 0 0 0;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--auth-control-border);
  border-radius: inherit;
  pointer-events: none;
  overflow: hidden;
  min-inline-size: auto;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

/* The floated label masks both border and focus ring with one cutout. */
.auth-outlined-legend {
  display: none;
  width: auto;
  max-width: 100%;
  padding: 0;
  height: 0;
  font-size: 0.75rem;
  visibility: hidden;
  white-space: nowrap;
  overflow: hidden;
}

.auth-outlined-legend > span {
  display: inline-block;
  padding: 0 5px;
}

.auth-outlined-field.is-focused .auth-outlined-fieldset {
  border-color: var(--auth-control-border-focus);
  border-width: 1.5px;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--auth-control-border-focus) 34%, transparent);
}

.auth-outlined-field:not(.is-focused):hover .auth-outlined-fieldset {
  border-color: var(--auth-control-border-hover);
}

/* Label always floated on border (matches Tamagui OutlinedInput) */
.auth-outlined-label {
  position: absolute;
  left: 14px;
  top: -6px;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: color-mix(in oklab, hsl(var(--foreground)) 82%, hsl(var(--muted-foreground)) 18%);
  pointer-events: none;
  background: var(--auth-label-bg);
  padding: 0 5px;
}

.auth-outlined-field.is-focused .auth-outlined-label {
  color: hsl(var(--foreground));
}

.auth-outlined-input {
  width: 100%;
  height: 44px;
  padding: 0 14px 3px;
  border: none;
  border-radius: inherit;
  background: transparent;
  color: hsl(var(--foreground));
  font-size: 0.98rem;
  font-family: inherit;
  line-height: 41px;
  outline: none;
  box-sizing: border-box;
}

.auth-outlined-input::placeholder {
  color: var(--auth-input-placeholder);
  opacity: 1;
}

.auth-password-toggle {
  position: absolute;
  right: 8px;
  top: 0;
  bottom: 3px;
  margin: auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--auth-subtle-foreground);
  cursor: pointer;
}

.auth-password-toggle:hover {
  background: hsl(var(--muted) / 0.5);
}

.auth-outlined-field:has(.auth-password-toggle) .auth-outlined-input {
  padding-right: 48px;
}

/* ===== Autofill protection ===== */

.auth-outlined-input:-webkit-autofill,
.auth-outlined-input:-webkit-autofill:hover,
.auth-outlined-input:-webkit-autofill:focus,
.auth-outlined-input:-webkit-autofill:active {
  /* Override the browser's autofill background with the card color */
  -webkit-box-shadow: 0 0 0 1000px var(--auth-card-bg) inset !important;
  box-shadow: 0 0 0 1000px var(--auth-card-bg) inset !important;
  /* Force text to match the input's normal styling */
  -webkit-text-fill-color: hsl(var(--foreground)) !important;
  caret-color: hsl(var(--foreground)) !important;
  font-family: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  line-height: inherit !important;
  letter-spacing: inherit !important;
  /* Delay the UA background-color so the box-shadow stays visible */
  transition: background-color 5000s ease-in-out 0s;
}

/* ===== Button hover / press states (matches Tamagui Button solid emphasis) ===== */
/* Hairline colors are precomputed from Tamagui OKLCH solidBorderDelta values */
/* Source values: primitives.base.ts solidBorderDelta hover=0.15 press=0.2 */
/* Border is transparent at rest, then uses the transformed solid border color */
/* Text color locked to rest state (lockTextToRestState) */
/* Animated: background-color + box-shadow only (BUTTON_WEB_ANIMATE_ONLY) */
/* Transform y+0.5px on press NOT animated (instant) */

.auth-btn {
  -webkit-tap-highlight-color: transparent;
  background-color: var(--auth-btn-bg);
  border: 1px solid var(--auth-btn-border);
  box-shadow: var(--auth-btn-shadow);
  color: var(--auth-btn-color);
  transform: translateY(0);
  touch-action: manipulation;
  transition: background-color 120ms ease-in-out, border-color 120ms ease-in-out,
    box-shadow 120ms ease-in-out, color 120ms ease-in-out, transform 80ms ease-out;
  will-change: background-color, box-shadow, transform;
}

.auth-btn:hover:not(:disabled) {
  background-color: var(--auth-btn-hover-bg, var(--auth-btn-bg));
  border-color: var(--auth-btn-hover-border, var(--auth-btn-border));
  box-shadow: var(--auth-btn-hover-shadow, var(--auth-btn-shadow));
}

.auth-btn:active:not(:disabled) {
  background-color: var(--auth-btn-press-bg, var(--auth-btn-bg));
  border-color: var(--auth-btn-press-border, var(--auth-btn-border));
  box-shadow: var(--auth-btn-press-shadow, var(--auth-btn-shadow));
  transform: translateY(0.5px);
}

.auth-btn:focus-visible:not(:disabled) {
  box-shadow: var(--auth-btn-hover-shadow, var(--auth-btn-shadow));
}

.auth-btn-spinner {
  display: inline-block;
  width: var(--loading-inline-size, 16px);
  height: var(--loading-inline-size, 16px);
  border: var(--loading-inline-border, 3px) solid transparent;
  border-top-color: currentColor;
  border-left-color: currentColor;
  border-radius: 50%;
  animation: auth-spinner var(--loading-rotation-ms, 800ms) linear infinite;
  flex-shrink: 0;
}

.auth-fullscreen-spinner {
  width: var(--loading-fullscreen-size);
  height: var(--loading-fullscreen-size);
  border: var(--loading-fullscreen-border) solid var(--loading-spinner-track);
  border-top-color: var(--loading-spinner-active);
  border-left-color: var(--loading-spinner-active);
  border-radius: 50%;
  animation: auth-spinner var(--loading-rotation-ms) linear infinite;
  flex-shrink: 0;
}

.auth-loading-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--loading-screen-bg);
  color: var(--loading-spinner-active);
}

.auth-loading-stack {
  width: 100%;
  max-width: 360px;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  font-family: var(--loading-font-family, var(--font-body));
}

.auth-loading-title {
  margin: 0;
  color: var(--loading-spinner-active);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.auth-loading-status {
  margin: 0;
  color: var(--loading-status-color);
  font-size: 0.875rem;
  line-height: 1.5;
}

.auth-loading-detail {
  margin: 0;
  color: var(--loading-detail-color);
  font-size: 0.92rem;
  line-height: 1.5;
  flex-shrink: 0;
}

/* ===== Tenant chooser hub (/login) ===== */

.auth-tenant-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-tenant-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--auth-control-border);
  border-radius: calc(var(--radius, 0.5625rem) * 1.56);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.auth-tenant-option:hover {
  background: hsl(var(--muted) / 0.5);
  border-color: var(--auth-control-border-hover);
}

.auth-tenant-option:active {
  background: hsl(var(--muted) / 0.7);
}

.auth-tenant-option-hint {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--auth-subtle-foreground);
}

.auth-tenant-empty {
  margin: 0;
  padding: 20px 16px;
  border: 1px dashed var(--auth-control-border);
  border-radius: calc(var(--radius, 0.5625rem) * 1.56);
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--auth-subtle-foreground);
}

/* Ghost link button (no border, text-only with hover bg) */
.auth-btn-ghost {
  display: inline-flex;
  align-items: center;
  border: none;
  background: transparent;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--auth-subtle-foreground);
  cursor: pointer;
  border-radius: calc(var(--radius, 0.5625rem) * 1.11);
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease;
}

.auth-btn-ghost:hover {
  background: hsl(var(--muted) / 0.5);
  color: hsl(var(--foreground));
}

.auth-btn-ghost:active {
  background: hsl(var(--muted) / 0.7);
  color: hsl(var(--foreground));
}
