/* PWA Auth — PIN entry and setup */

.pwa-auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: var(--space-4);
  text-align: center;
}

.pwa-auth__logo {
  margin-bottom: var(--space-6);
}

.pwa-auth__logo-img {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-3);
}

.pwa-auth__heading {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0 0 var(--space-2);
}

.pwa-auth__name {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin: 0;
}

.pwa-auth__hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: var(--space-2) 0 0;
}

.pwa-auth__step-label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--space-3);
}

.pwa-auth__error {
  color: var(--color-destructive);
  font-size: var(--text-sm);
  margin: var(--space-3) 0;
  animation: pwa-shake 0.4s ease-in-out;
}

@keyframes pwa-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.pwa-auth__form {
  width: 100%;
  max-width: 320px;
}

/* PIN dot display */
.pwa-pin-display {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  min-height: 14px;
}

.pwa-pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--color-border-default);
  background: transparent;
  transition: all var(--duration-fast) ease;
}

.pwa-pin-dot--filled {
  background: var(--color-brand);
  border-color: var(--color-brand);
  transform: scale(1.1);
}

/* PIN keypad */
.pwa-pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.pwa-pin-pad__key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1.3;
  min-height: 56px;
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-medium);
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-surface-200);
  color: var(--color-text-primary);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.pwa-pin-pad__key:active {
  background: var(--color-border-default);
  transform: scale(0.95);
}

.pwa-pin-pad__key--empty {
  background: transparent;
  cursor: default;
}

.pwa-pin-pad__key--action {
  font-size: var(--text-xl);
}

.pwa-pin-pad__key--action .icon {
  width: 24px;
  height: 24px;
}

/* Submit button */
.pwa-auth__submit {
  width: 100%;
  margin-bottom: var(--space-3);
}

.pwa-auth__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pwa-auth__back {
  width: 100%;
  background: transparent;
  color: var(--color-text-muted);
}

/* Form overrides for PWA auth context */
.pwa-auth .form-field {
  text-align: left;
}

/* Divider */
.pwa-auth__divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  max-width: 320px;
  margin: var(--space-4) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.pwa-auth__divider::before,
.pwa-auth__divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--color-border-default);
}

/* QR section */
.pwa-auth__qr-section {
  width: 100%;
  max-width: 320px;
}

.pwa-auth__qr-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.pwa-auth__qr-btn .icon {
  width: 20px;
  height: 20px;
}

/* QR Scanner overlay */
.pwa-qr-scanner[hidden] {
  display: none;
}

.pwa-qr-scanner {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--color-surface-100);
  display: flex;
  flex-direction: column;
}

.pwa-qr-scanner__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-brand);
  color: white;
}

.pwa-qr-scanner__title {
  font-size: var(--text-base);
  font-weight: var(--font-weight-medium);
  margin: 0;
}

.pwa-qr-scanner__close {
  background: none;
  border: none;
  color: white;
  padding: var(--space-1);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.pwa-qr-scanner__close .icon {
  width: 24px;
  height: 24px;
}

.pwa-qr-scanner__viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: black;
}

.pwa-qr-scanner__viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pwa-qr-scanner__frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  height: 240px;
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.pwa-qr-scanner__hint {
  text-align: center;
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

/* Responsive */
@media (max-width: 374px) {
  .pwa-pin-pad__key {
    min-height: 48px;
    font-size: var(--text-xl);
  }
}
