/* ═══════════════════════════════════════════════════════════
   NTProxy — Authentication Experience
   Premium, minimal, viewport-adaptive auth shell
   ═══════════════════════════════════════════════════════════ */

/* ─── Shell & viewport lock ─────────────────────────────── */
.auth-body {
  height: 100dvh;
  overflow: hidden;
}

.auth-shell {
  position: relative;
  z-index: 1;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(0.5rem, 1.5vh, 1rem) clamp(0.75rem, 2vw, 1.25rem) 0;
  overflow: hidden;
}

.auth-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* ─── Card ──────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: min(440px, 96vw);
  max-height: calc(100dvh - clamp(2.5rem, 8vh, 4.5rem));
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: clamp(16px, 2.5vw, 24px);
  padding: clamp(1.25rem, 3.5vh, 2.25rem) clamp(1.25rem, 4vw, 2.25rem);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: authCardEnter 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-card--projector {
  max-width: min(400px, 96vw);
}

@keyframes authCardEnter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ─── Brand header ──────────────────────────────────────── */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: clamp(0.75rem, 2.5vh, 1.5rem);
  flex-shrink: 0;
}

.auth-logo {
  width: clamp(36px, 6vh, 48px);
  height: clamp(36px, 6vh, 48px);
  margin-bottom: clamp(0.5rem, 1.5vh, 0.85rem);
  flex-shrink: 0;
}

.auth-logo .logo-icon {
  width: 100%;
  height: 100%;
  display: block;
}

.auth-title {
  font-size: clamp(1.1rem, 2.2vh + 0.5rem, 1.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.2rem;
  color: var(--text-primary);
}

.auth-tagline {
  font-size: clamp(0.75rem, 1.2vh + 0.4rem, 0.85rem);
  color: var(--text-muted);
  font-weight: 400;
}

/* Compact brand for projector step */
.auth-card--projector .auth-brand {
  margin-bottom: clamp(0.5rem, 1.5vh, 0.85rem);
}

.auth-card--projector .auth-logo {
  width: clamp(32px, 5vh, 40px);
  height: clamp(32px, 5vh, 40px);
  margin-bottom: clamp(0.35rem, 1vh, 0.5rem);
}

.auth-card--projector .auth-title {
  font-size: clamp(1rem, 1.8vh + 0.4rem, 1.15rem);
}

.auth-card--projector .auth-tagline {
  display: none;
}

/* ─── Step indicator (login) ────────────────────────────── */
.step-indicators {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: clamp(0.85rem, 2.5vh, 1.5rem);
  flex-shrink: 0;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s ease;
}

.step-dot.active {
  background: var(--accent-light);
  width: 24px;
  border-radius: 4px;
}

.step-dot.done {
  background: var(--success);
}

.step-line {
  width: 20px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
}

/* ─── Step container ────────────────────────────────────── */
.auth-step {
  display: none;
  flex-direction: column;
  min-height: 0;
  animation: authStepIn 0.28s ease both;
}

.auth-step.active {
  display: flex;
}

@keyframes authStepIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-step-head {
  text-align: center;
  margin-bottom: clamp(0.75rem, 2vh, 1.25rem);
  flex-shrink: 0;
}

.auth-step-title {
  font-size: clamp(0.95rem, 1.5vh + 0.45rem, 1.05rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.3rem;
  color: var(--text-primary);
}

.auth-step-subtitle {
  font-size: clamp(0.78rem, 1.1vh + 0.35rem, 0.85rem);
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 32ch;
  margin-inline: auto;
}

/* ─── Forms (auth-scoped enhancements) ──────────────────── */
.auth-form-group {
  margin-bottom: clamp(0.75rem, 2vh, 1.1rem);
}

.auth-form-group .form-label {
  font-size: clamp(0.78rem, 1vh + 0.35rem, 0.82rem);
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}

.auth-form-group .form-control {
  padding: clamp(0.65rem, 1.5vh, 0.8rem) clamp(0.85rem, 2vw, 1rem);
  font-size: clamp(0.88rem, 1.2vh + 0.4rem, 0.95rem);
  border-radius: clamp(10px, 1.5vw, 12px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth-form-group .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1.5vh, 0.75rem);
  margin-top: clamp(0.25rem, 1vh, 0.5rem);
}

.auth-actions .btn {
  min-height: clamp(42px, 6vh, 48px);
  font-size: clamp(0.88rem, 1.2vh + 0.4rem, 0.95rem);
  border-radius: clamp(10px, 1.5vw, 12px);
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.auth-actions .btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
}

.auth-actions .btn-primary:not(:disabled):active {
  transform: translateY(0);
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: clamp(0.65rem, 1.8vh, 1rem) 0;
}

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

.auth-divider span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Temporary login option visibility on mobile */
.temp-login-option {
  width: 100%;
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .temp-login-option {
    display: none !important;
  }
}

/* ─── OTP inputs ────────────────────────────────────────── */
.auth-otp-group {
  display: flex;
  gap: clamp(6px, 1.5vw, 10px);
  justify-content: center;
  margin: clamp(0.85rem, 2.5vh, 1.35rem) 0;
}

.auth-otp-group .otp-input {
  width: clamp(44px, 10vw, 54px);
  height: clamp(50px, 8vh, 60px);
  font-size: clamp(1.25rem, 2.5vh + 0.5rem, 1.6rem);
  border-radius: clamp(10px, 1.5vw, 12px);
  border-width: 1.5px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.auth-otp-group .otp-input:focus {
  transform: scale(1.02);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-otp-group .otp-input.filled {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}

.auth-resend {
  font-size: clamp(0.75rem, 1vh + 0.3rem, 0.8rem);
  color: var(--text-muted);
  text-align: center;
  margin-top: clamp(0.65rem, 1.5vh, 1rem);
}

.auth-resend button {
  background: none;
  border: none;
  color: var(--accent-light);
  cursor: pointer;
  font-family: var(--font);
  font-size: inherit;
  font-weight: 600;
  padding: 0.25rem 0.35rem;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.auth-resend button:hover:not(:disabled) {
  color: var(--accent);
}

.auth-resend button:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ─── Passkey step ──────────────────────────────────────── */
.auth-passkey-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(0.75rem, 2.5vh, 1.5rem) 0;
  flex-shrink: 0;
}

.auth-passkey-icon {
  width: clamp(56px, 10vh, 68px);
  height: clamp(56px, 10vh, 68px);
  border-radius: clamp(14px, 2vw, 18px);
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: clamp(0.65rem, 1.5vh, 1rem);
  transition: border-color 0.3s ease, background 0.3s ease;
}

.auth-passkey-icon--success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
}

.auth-passkey-status {
  font-size: clamp(0.78rem, 1.1vh + 0.35rem, 0.85rem);
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.45;
  transition: color 0.25s ease;
}

/* ─── Notices (blocked, cooldown) ───────────────────────── */
.auth-notice {
  border-radius: clamp(10px, 1.5vw, 12px);
  padding: clamp(0.75rem, 1.8vh, 1rem) clamp(0.85rem, 2vw, 1.1rem);
  text-align: center;
  margin-bottom: clamp(0.65rem, 1.5vh, 1rem);
  flex-shrink: 0;
  animation: authStepIn 0.3s ease both;
}

.auth-notice--warning {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.22);
}

.auth-notice--danger {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
}

.auth-notice-title {
  font-weight: 600;
  font-size: clamp(0.82rem, 1.1vh + 0.35rem, 0.88rem);
  margin-bottom: 0.25rem;
}

.auth-notice--warning .auth-notice-title {
  color: var(--warning-light);
}

.auth-notice--danger .auth-notice-title {
  color: var(--danger-light);
}

.auth-notice-text {
  font-size: clamp(0.75rem, 1vh + 0.3rem, 0.8rem);
  color: var(--text-muted);
  line-height: 1.45;
}

.auth-notice-timer {
  font-size: clamp(1.15rem, 2.5vh + 0.5rem, 1.4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  color: var(--danger);
  margin-top: 0.5rem;
}

/* ─── QR stage (projector login) ────────────────────────── */
.auth-step-projector .auth-step-head {
  margin-bottom: clamp(0.5rem, 1.2vh, 0.75rem);
}

.auth-qr-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.5rem, 1.5vh, 0.85rem);
  flex-shrink: 0;
}

.auth-qr-frame {
  position: relative;
  width: clamp(160px, 38vw, 220px);
  height: clamp(160px, 38vw, 220px);
  background: #ffffff;
  border-radius: clamp(14px, 2vw, 18px);
  padding: clamp(8px, 1.5vw, 12px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 8px 32px rgba(99, 102, 241, 0.15),
    var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.auth-qr-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.auth-qr-image.visible {
  opacity: 1;
}

/* Skeleton placeholder */
.auth-qr-skeleton {
  position: absolute;
  inset: clamp(8px, 1.5vw, 12px);
  border-radius: 6px;
  background: linear-gradient(
    110deg,
    rgba(99, 102, 241, 0.06) 0%,
    rgba(99, 102, 241, 0.12) 40%,
    rgba(99, 102, 241, 0.06) 80%
  );
  background-size: 200% 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.auth-qr-skeleton.active {
  opacity: 1;
  animation: authQrShimmer 1.4s ease-in-out infinite;
}

@keyframes authQrShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.auth-qr-meta {
  text-align: center;
  flex-shrink: 0;
}

.auth-qr-status {
  font-size: clamp(0.78rem, 1.1vh + 0.35rem, 0.85rem);
  color: var(--text-secondary);
  line-height: 1.4;
  transition: color 0.25s ease;
}

.auth-qr-status--success {
  color: var(--success-light);
}

.auth-qr-status--danger {
  color: var(--danger-light);
}

.auth-qr-timer {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: clamp(0.95rem, 1.5vh + 0.4rem, 1.1rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-light);
  margin-top: 0.25rem;
  min-height: 1.25em;
  transition: color 0.25s ease;
}

.auth-qr-timer--danger {
  color: var(--danger-light);
}

.auth-qr-timer--empty {
  visibility: hidden;
}

/* ─── State screens (approve flow) ──────────────────────── */
.auth-state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: authStepIn 0.28s ease both;
}

.auth-state.active {
  display: flex;
}

.auth-state-icon {
  width: clamp(60px, 10vh, 72px);
  height: clamp(60px, 10vh, 72px);
  border-radius: clamp(14px, 2vw, 18px);
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: clamp(0.85rem, 2vh, 1.25rem);
  color: var(--accent-light);
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.auth-state-icon--success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
  color: var(--success-light);
}

.auth-state-icon--error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.22);
  color: var(--danger-light);
}

.auth-state-detail {
  font-size: clamp(0.78rem, 1.1vh + 0.35rem, 0.85rem);
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: clamp(0.85rem, 2vh, 1.25rem);
  max-width: 36ch;
}

.auth-state-loader {
  margin-top: clamp(0.5rem, 1vh, 0.75rem);
}

/* ─── Footer link & footer ──────────────────────────────── */
.auth-back-link {
  text-align: center;
  margin-top: clamp(0.75rem, 2vh, 1.25rem);
  flex-shrink: 0;
}

.auth-back-link a,
.auth-back-link button.auth-link-btn {
  font-size: clamp(0.78rem, 1vh + 0.3rem, 0.82rem);
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition: color 0.15s ease;
}

.auth-back-link a:hover,
.auth-back-link button.auth-link-btn:hover {
  color: var(--text-secondary);
}

.auth-footer {
  flex-shrink: 0;
  width: 100%;
  padding: clamp(0.5rem, 1.5vh, 0.85rem) 0;
  border: none;
  background: transparent;
}

.auth-footer .footer-text {
  font-size: clamp(0.68rem, 1vh + 0.25rem, 0.75rem);
}

/* ─── Auth alerts spacing ───────────────────────────────── */
.auth-card .alert {
  margin-bottom: clamp(0.65rem, 1.5vh, 1rem);
  font-size: clamp(0.78rem, 1.1vh + 0.35rem, 0.85rem);
}

/* ─── Short viewport compaction ─────────────────────────── */
@media (max-height: 700px) {
  .auth-card {
    padding: 1rem 1.15rem;
    max-height: calc(100dvh - 2.75rem);
  }

  .auth-brand {
    margin-bottom: 0.65rem;
  }

  .step-indicators {
    margin-bottom: 0.65rem;
  }

  .auth-step-head {
    margin-bottom: 0.65rem;
  }

  .auth-passkey-visual {
    padding: 0.5rem 0;
  }

  .auth-qr-frame {
    width: clamp(140px, 34vw, 180px);
    height: clamp(140px, 34vw, 180px);
  }

  .auth-back-link {
    margin-top: 0.65rem;
  }
}

@media (max-height: 560px) {
  .auth-logo {
    width: 32px;
    height: 32px;
    margin-bottom: 0.35rem;
  }

  .auth-title {
    font-size: 1rem;
  }

  .auth-tagline {
    display: none;
  }

  .auth-qr-frame {
    width: clamp(120px, 30vw, 150px);
    height: clamp(120px, 30vw, 150px);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .auth-step,
  .auth-notice,
  .auth-state {
    animation: none;
  }

  .auth-qr-skeleton.active {
    animation: none;
    opacity: 1;
  }

  .auth-qr-image {
    transition: none;
  }

  .auth-otp-group .otp-input:focus {
    transform: none;
  }

  .auth-loader-orbit-outer,
  .auth-loader-orbit-inner,
  .auth-loader-core {
    animation: none !important;
  }
}

/* ─── Futuristic Auth Loader ─────────────────────────────── */
.auth-futuristic-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--loader-size, 18px);
  height: var(--loader-size, 18px);
  position: relative;
  vertical-align: middle;
  flex-shrink: 0;
}

.auth-loader-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
}

.auth-loader-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 3.5;
}

:root[data-theme="light"] .auth-loader-track {
  stroke: rgba(15, 23, 42, 0.15);
}

.auth-loader-orbit-outer {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 75 50;
  transform-origin: 25px 25px;
  animation: authSpinOuter 1.1s linear infinite;
  filter: drop-shadow(0 0 5px rgba(129, 140, 248, 0.75));
}

.auth-loader-orbit-inner {
  fill: none;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 45 30;
  transform-origin: 25px 25px;
  animation: authSpinInner 0.75s linear infinite reverse;
  filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.65));
}

.auth-loader-core {
  fill: var(--accent-light, #818cf8);
  transform-origin: 25px 25px;
  animation: authPulseCore 1s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.85));
}

@keyframes authSpinOuter {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes authSpinInner {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes authPulseCore {
  0% { transform: scale(0.65); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; }
}

/* ─── Desktop Student Mobile-Only View ──────────────────── */
.auth-step-desktop-student {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.desktop-student-icon-wrap {
  width: clamp(48px, 8vh, 60px);
  height: clamp(48px, 8vh, 60px);
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--accent-light, #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light, #818cf8);
  margin: 0 auto clamp(0.75rem, 2vh, 1.25rem);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.25);
  animation: pulseDeviceIcon 3s infinite ease-in-out;
}

@keyframes pulseDeviceIcon {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(99, 102, 241, 0.25); }
  50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(99, 102, 241, 0.45); }
}

.auth-badge-student {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-light, #818cf8);
  border: 1px solid rgba(99, 102, 241, 0.3);
  margin-bottom: 0.6rem;
}

.desktop-student-qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: clamp(0.75rem, 2vh, 1.25rem) 0 0.5rem;
  width: 100%;
}

.desktop-student-qr-container .auth-qr-frame {
  width: clamp(140px, 25vh, 170px);
  height: clamp(140px, 25vh, 170px);
  padding: 8px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
}

.desktop-student-qr-label {
  font-size: clamp(0.75rem, 1.2vh + 0.35rem, 0.82rem);
  color: var(--text-muted);
  margin-top: 0.65rem;
}

/* ─── Projector code login ──────────────────────────────── */
.auth-form-group .auth-code-input {
  text-align: center;
  letter-spacing: 0.35em;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: clamp(1rem, 1.4vh + 0.5rem, 1.15rem);
  padding-left: calc(clamp(0.85rem, 2vw, 1rem) + 0.35em);
}

.auth-form-group .auth-code-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-code-hint {
  margin-top: 0.45rem;
  text-align: center;
  font-size: clamp(0.72rem, 1vh + 0.3rem, 0.78rem);
  color: var(--text-muted);
}

/* Student reset review remains inside the existing login card. */
.passkey-reset-option {
  margin: 10px 0 0;
  text-align: center;
}
.passkey-reset-option p { margin: 8px 0 0; font-size: 0.8rem; overflow-wrap: break-word; }
.passkey-reset-option p:empty { display: none; }
.auth-card--reset #step-passkey { overflow-y: auto; flex-shrink: 1; padding-right: 3px; }
.auth-card--reset #step-passkey > * { flex-shrink: 0; }
.auth-card--reset .auth-passkey-visual { display: none; }
