/**
 * Peace Infinite — Refined Admin Auth UI
 * Minimalist editorial split layout, zero-scroll on desktop, aligned with tokens.css.
 */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body.pi-auth-body {
  font-family: var(--font-text);
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input {
  font-family: inherit;
}

/* ── Split Layout (Zero-scroll on desktop) ────────────────────────────── */
.pi-auth-shell {
  height: 100dvh;
  min-height: 540px;
  display: grid;
  grid-template-columns: 44% 56%;
  overflow: hidden;
  background: var(--surface);
}

/* ── Left Editorial Brand Panel ───────────────────────────────────────── */
.pi-auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 3.6vw, 48px);
  background:
    radial-gradient(520px circle at 12% 100%, rgba(76, 185, 234, 0.14), transparent 62%),
    linear-gradient(165deg, #13203B 0%, var(--brand-navy) 100%);
  color: var(--text-on-dark);
  overflow: hidden;
  isolation: isolate;
}

.pi-brand-watermark {
  position: absolute;
  right: -12%;
  bottom: -6%;
  width: 78%;
  max-width: 440px;
  color: rgba(164, 222, 248, 0.06);
  pointer-events: none;
  z-index: -1;
}

.pi-auth-brand-top {
  display: flex;
  align-items: center;
}

.pi-brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.pi-brand-emblem {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex-shrink: 0;
}

.pi-brand-wordmark {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #FFFFFF;
}

.pi-brand-wordmark span {
  color: var(--brand-sky);
}

.pi-auth-brand-body {
  max-width: 360px;
}

.pi-brand-rule {
  width: 36px;
  height: 2px;
  background: var(--brand-sky);
  border-radius: 2px;
  margin-bottom: 20px;
}

.pi-auth-brand-title {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 2.5vw, 2.45rem);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.03em;
  color: #FFFFFF;
  margin-bottom: 14px;
}

.pi-auth-brand-desc {
  font-size: 0.92rem;
  line-height: 1.6;
  color: rgba(201, 212, 232, 0.78);
}

.pi-auth-brand-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.78rem;
  color: rgba(201, 212, 232, 0.56);
}

.pi-back-site {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
  transition: color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.pi-back-site:hover {
  color: #FFFFFF;
  transform: translateX(-2px);
}

/* ── Right Pure-White Form Panel ──────────────────────────────────────── */
.pi-auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 3vw, 40px);
  background: var(--surface);
  overflow-y: auto;
}

.pi-auth-card {
  width: 100%;
  max-width: 380px;
}

.pi-auth-mobile-logo {
  display: none;
  align-items: center;
  gap: 9px;
  margin-bottom: 20px;
}

.pi-auth-mobile-logo img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.pi-auth-logo-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-navy);
  letter-spacing: -0.02em;
}

.pi-auth-logo-name span {
  color: var(--brand-blue);
}

.pi-auth-card-head {
  margin-bottom: 22px;
}

.pi-auth-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--brand-navy);
  letter-spacing: -0.03em;
  line-height: 1.22;
  margin-bottom: 5px;
}

.pi-auth-subtitle {
  font-size: 0.865rem;
  color: var(--text-subtle);
  line-height: 1.5;
}

/* ── Alerts & Inline Error Below Password ─────────────────────────────── */
.pi-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.815rem;
  line-height: 1.45;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.pi-alert-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  font-weight: 800;
  font-size: 0.72rem;
  line-height: 1;
}

.pi-alert-error {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #991B1B;
}

.pi-alert-error .pi-alert-icon {
  background: #DC2626;
  color: #FFFFFF;
}

.pi-alert-error strong {
  font-weight: 700;
  color: #991B1B;
}

.pi-alert-error .pi-error-guide {
  font-weight: 400;
  color: #B91C1C;
}

.pi-alert-warn {
  background: #FFFBEB;
  border-color: #FDE68A;
  color: #92400E;
}

.pi-alert-warn .pi-alert-icon {
  background: #D97706;
  color: #FFFFFF;
}

.pi-alert-success {
  background: #F0FDF4;
  border-color: #BBF7D0;
  color: #166534;
}

.pi-inline-error {
  margin-top: -4px;
  margin-bottom: 14px;
}

/* ── Form Controls ────────────────────────────────────────────────────── */
.pi-field {
  margin-bottom: 15px;
}

.pi-field-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.pi-label {
  display: block;
  font-size: 0.815rem;
  font-weight: 600;
  color: var(--brand-navy);
  margin-bottom: 6px;
  transition: color var(--dur) var(--ease);
}

.pi-field-row .pi-label {
  margin-bottom: 0;
}

.pi-label .req {
  color: var(--danger);
}

.pi-link-forgot {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--brand-blue);
  padding-right: 4px;
  transition: color var(--dur) var(--ease);
  white-space: nowrap;
}

.pi-link-forgot:hover {
  color: var(--brand-navy);
  text-decoration: underline;
}

.pi-input-wrap {
  position: relative;
}

.pi-input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #94A3B8;
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: color var(--dur) var(--ease);
}

.pi-input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  background: #F8FAFC;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  font-size: 0.885rem;
  color: var(--brand-navy);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
  outline: none;
}

.pi-input-wrap .pi-input {
  padding-left: 40px;
}

.pi-input-wrap.has-toggle .pi-input {
  padding-right: 44px;
}

.pi-input::placeholder {
  color: #94A3B8;
}

.pi-input:hover {
  border-color: #94A3B8;
}

.pi-input:focus {
  background: #FFFFFF;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(74, 112, 182, 0.14);
}

.pi-input-wrap:focus-within .pi-input-icon {
  color: var(--brand-blue);
}

/* Invalid field state (red label + red border) */
.pi-field.is-invalid .pi-label {
  color: #B91C1C;
}

.pi-field.is-invalid .pi-input {
  border-color: #DC2626;
  background: #FFFBFB;
}

.pi-field.is-invalid .pi-input:focus {
  border-color: #DC2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

.pi-field.is-invalid .pi-input-icon {
  color: #DC2626;
}

.pi-input:-webkit-autofill,
.pi-input:-webkit-autofill:hover,
.pi-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 9999px #FFFFFF inset !important;
  box-shadow: 0 0 0 9999px #FFFFFF inset !important;
  -webkit-text-fill-color: var(--brand-navy) !important;
  caret-color: var(--brand-navy) !important;
}

.pi-pw-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748B;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.pi-pw-toggle:hover {
  background: #E2E8F0;
  color: var(--brand-navy);
}

.pi-pw-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.pi-hint {
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--text-subtle);
}

/* ── Remember Email & OTP Checkbox ────────────────────────────────────── */
.pi-check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 16px;
  cursor: pointer;
  user-select: none;
}

.pi-check-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-navy);
  cursor: pointer;
}

.pi-otp-input {
  height: 52px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.45em;
  text-align: center;
  padding-left: 0.45em;
}

/* ── Primary Button + Infinity Loop Loader ────────────────────────────── */
.pi-btn-submit {
  width: 100%;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: none;
  border-radius: 10px;
  background: var(--brand-navy);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.pi-btn-submit:hover:not(:disabled) {
  background: #16233F;
}

.pi-btn-submit:active:not(:disabled) {
  transform: translateY(1px);
}

.pi-btn-submit:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.pi-btn-submit:disabled {
  opacity: 0.88;
  cursor: wait;
}

/* Infinity loop SVG inside button */
.pi-infinity-btn {
  display: none;
  width: 30px;
  height: 15px;
  flex-shrink: 0;
}

.pi-infinity-btn svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pi-infinity-btn .pi-inf-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 8;
  stroke-linecap: round;
}

.pi-infinity-btn .pi-inf-trail {
  fill: none;
  stroke: #A4DEF8;
  stroke-width: 8.5;
  stroke-linecap: round;
  stroke-dasharray: 28 72;
  stroke-dashoffset: 0;
  animation: piInfinityLoop 1.15s linear infinite;
}

.is-loading .pi-infinity-btn {
  display: inline-flex;
  align-items: center;
}

.is-loading .pi-btn-icon {
  display: none;
}

@keyframes piInfinityLoop {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -100; }
}

.pi-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: piAuthSpin 0.75s linear infinite;
  display: none;
}

.is-loading .pi-spinner {
  display: inline-block;
}

@keyframes piAuthSpin {
  to { transform: rotate(360deg); }
}

/* ── Divider & Passwordless Secondary Button ──────────────────────────── */
.pi-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  font-size: 0.75rem;
  color: #94A3B8;
}

.pi-auth-divider::before,
.pi-auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.pi-btn-secondary {
  width: 100%;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  background: #FFFFFF;
  color: var(--brand-navy);
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.pi-btn-secondary svg {
  color: var(--brand-blue);
  flex-shrink: 0;
}

.pi-btn-secondary:hover {
  border-color: var(--brand-blue);
  background: #F8FAFC;
}

.pi-btn-secondary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ── Footer Links inside Card ─────────────────────────────────────────── */
.pi-auth-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  font-size: 0.82rem;
}

.pi-auth-links a,
.pi-auth-links button {
  background: none;
  border: none;
  color: var(--brand-blue);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.pi-auth-links a:hover,
.pi-auth-links button:hover {
  color: var(--brand-navy);
  text-decoration: underline;
}

.pi-auth-mobile-back {
  display: none;
  margin-top: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-subtle);
}

.pi-auth-mobile-back:hover {
  color: var(--brand-navy);
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .pi-auth-shell {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .pi-auth-brand {
    display: none;
  }

  .pi-auth-main {
    min-height: 100dvh;
    padding: 28px 20px;
  }

  .pi-auth-mobile-logo {
    display: inline-flex;
  }

  .pi-auth-mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pi-infinity-btn .pi-inf-trail {
    animation-duration: 2.4s;
  }
  .pi-spinner {
    animation-duration: 1.8s;
  }
  .pi-btn-submit,
  .pi-back-site {
    transition: none;
  }
}
