/** @license For full copyright and license information, please see the LICENSE.md file. */

/*
 * Ammonly 4-Tier Authentication Shell & Perceptual Design Tokens (Baseline Modern CSS).
 * Uses oklch(), color-mix(), @container, @starting-style, and native View Transitions.
 * Zero !important declarations.
 */

/* Cross-document @view-transition omitted: destination app shells do not opt in, avoiding Chromium AbortError. */

:root,
html[data-tier="panel"] {
  --auth-accent: oklch(0.54 0.22 274);
  --auth-accent-alt: oklch(0.61 0.19 294);
  --auth-accent-ink: #ffffff;
}

html[data-tier="helpdesk"] {
  --auth-accent: oklch(0.56 0.15 174);
  --auth-accent-alt: oklch(0.63 0.14 198);
  --auth-accent-ink: #ffffff;
}

html[data-tier="crm"] {
  --auth-accent: oklch(0.56 0.19 246);
  --auth-accent-alt: oklch(0.64 0.16 222);
  --auth-accent-ink: #ffffff;
}

html[data-tier="shop"] {
  --auth-accent: oklch(0.58 0.18 234);
  --auth-accent-alt: oklch(0.70 0.15 72);
  --auth-accent-ink: #ffffff;
}

:root,
html[data-bs-theme="light"] {
  color-scheme: light;
  --auth-canvas: #f4f7fb;
  --auth-surface: color-mix(in oklch, #ffffff 95%, var(--auth-accent) 5%);
  --auth-surface-elevated: #ffffff;
  --auth-showcase-bg: color-mix(in oklch, #eef3fa 86%, var(--auth-accent) 14%);
  --auth-text: #0f172a;
  --auth-text-muted: #475569;
  --auth-border: color-mix(in oklch, #0f172a 12%, transparent);
  --auth-border-strong: color-mix(in oklch, var(--auth-accent) 42%, #cbd5e1);
  --auth-input-bg: #ffffff;
  --auth-ring: color-mix(in oklch, var(--auth-accent) 24%, transparent);
  --auth-shadow: 0 20px 50px -18px rgba(15, 23, 42, 0.14), 0 4px 14px -4px rgba(15, 23, 42, 0.06);
  --auth-grid-line: color-mix(in oklch, var(--auth-accent) 11%, transparent);
}

html[data-bs-theme="dark"] {
  color-scheme: dark;
  --auth-canvas: #070b14;
  --auth-surface: color-mix(in oklch, #0f172a 92%, var(--auth-accent) 8%);
  --auth-surface-elevated: color-mix(in oklch, #131d33 90%, var(--auth-accent) 10%);
  --auth-showcase-bg: color-mix(in oklch, #0b1222 84%, var(--auth-accent) 16%);
  --auth-text: #f1f5f9;
  --auth-text-muted: #94a3b8;
  --auth-border: color-mix(in oklch, #f8fafc 12%, var(--auth-accent) 14%);
  --auth-border-strong: color-mix(in oklch, var(--auth-accent) 58%, #334155);
  --auth-input-bg: rgba(9, 14, 26, 0.82);
  --auth-ring: color-mix(in oklch, var(--auth-accent) 34%, transparent);
  --auth-shadow: 0 28px 64px -20px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --auth-grid-line: color-mix(in oklch, var(--auth-accent) 16%, transparent);
}

html[data-font-size="small"], html[data-wcag-font="small"] { font-size: 14px; }
html[data-font-size="normal"], html[data-wcag-font="normal"] { font-size: 16px; }
html[data-font-size="large"], html[data-wcag-font="large"] { font-size: 19px; }

body.auth-body-container {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--auth-canvas);
  color: var(--auth-text);
  overflow-x: clip;
  position: relative;
}

/* Architectural Per-Tier Ambient Backdrop (GPU-safe static gradients, zero meteor noise) */
.auth-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(56rem 38rem at 14% 16%, color-mix(in oklch, var(--auth-accent) 18%, transparent), transparent 70%),
    radial-gradient(
      48rem 36rem at 88% 84%,
      color-mix(in oklch, var(--auth-accent-alt) 15%, transparent),
      transparent 72%
    );
}

.auth-ambient__pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--auth-grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--auth-grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 78% 72% at 50% 45%, #000 25%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse 78% 72% at 50% 45%, #000 25%, transparent 90%);
}

html[data-tier="helpdesk"] .auth-ambient__pattern {
  background-image: repeating-radial-gradient(
    circle at 22% 50%,
    var(--auth-grid-line) 0,
    var(--auth-grid-line) 1px,
    transparent 1px,
    transparent 52px
  );
  background-size: auto;
}

html[data-tier="crm"] .auth-ambient__pattern {
  background-size: 64px 64px;
}

/* Top Utility & Accessibility Dock */
.auth-topbar {
  position: relative;
  z-index: 20;
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding: 0.875rem 1.25rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
}

.auth-topbar__group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.auth-dock-btn {
  min-height: 2.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--auth-border);
  background: var(--auth-surface-elevated);
  color: var(--auth-text);
  font-size: 0.8125rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.auth-dock-btn:hover {
  border-color: var(--auth-border-strong);
  background: var(--auth-surface);
  color: var(--auth-text);
}

.auth-dock-btn:focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 2px;
}

/* Main Stage & Split-Screen Grid */
.auth-stage {
  position: relative;
  z-index: 10;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.auth-split {
  width: 100%;
  max-width: 460px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.auth-showcase {
  display: none;
}

@media (min-width: 992px) {
  .auth-split {
    max-width: 1080px;
    grid-template-columns: 1.06fr minmax(410px, 452px);
    gap: 2rem;
  }

  .auth-split.auth-split--centered {
    max-width: 460px;
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-showcase {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem;
    border-radius: 1.5rem;
    background: var(--auth-showcase-bg);
    border: 1px solid var(--auth-border);
    box-shadow: var(--auth-shadow);
    position: relative;
    overflow: hidden;
  }
}

.auth-showcase__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: color-mix(in oklch, var(--auth-accent) 16%, transparent);
  color: var(--auth-text);
  border: 1px solid color-mix(in oklch, var(--auth-accent) 34%, transparent);
}

.auth-showcase__title {
  font-size: clamp(1.65rem, 2.3vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.18;
  color: var(--auth-text);
  margin: 1.1rem 0 0.75rem;
}

.auth-showcase__desc {
  color: var(--auth-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.75rem;
}

.auth-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.85rem;
}

.auth-feature-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 0.875rem;
  background: color-mix(in oklch, var(--auth-surface-elevated) 72%, transparent);
  border: 1px solid var(--auth-border);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--auth-text);
}

.auth-feature-item__icon {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 0.625rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: color-mix(in oklch, var(--auth-accent) 18%, transparent);
  color: var(--auth-accent);
  font-size: 1rem;
}

html[data-bs-theme="dark"] .auth-feature-item__icon {
  color: oklch(0.80 0.14 250);
}

/* Right Workspace Card & 3-Zone Inner Architecture */
.auth-card--modern {
  container-type: inline-size;
  view-transition-name: auth-card;
  position: relative;
  overflow: hidden;
  background: var(--auth-surface-elevated);
  border: 1px solid var(--auth-border);
  border-radius: 1.5rem;
  box-shadow: var(--auth-shadow);
  color: var(--auth-text);
  display: flex;
  flex-direction: column;
}

.auth-card--modern::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--auth-accent), var(--auth-accent-alt));
}

.auth-card__body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.75rem;
}

@media (min-width: 576px) {
  .auth-card__body {
    padding: 2.5rem;
  }
}

.auth-login-layout {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
}

.auth-card__emblem {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklch, var(--auth-accent) 14%, transparent);
  border: 1px solid color-mix(in oklch, var(--auth-accent) 30%, transparent);
  color: var(--auth-accent);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

html[data-bs-theme="dark"] .auth-card__emblem {
  color: color-mix(in oklch, var(--auth-accent) 68%, #ffffff);
}

.auth-card__title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.22;
  color: var(--auth-text);
  margin: 0 0 0.375rem;
}

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

.auth-card__footer {
  padding-top: 1rem;
  border-top: 1px solid var(--auth-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-auth-logo { height: 2.5rem; width: auto; }
.brand-auth-logo--dark, html[data-bs-theme="dark"] .brand-auth-logo--light { display: none; }
html[data-bs-theme="dark"] .brand-auth-logo--dark { display: inline-block; }
