/* Safe area insets for iPhone notch & home indicator */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

body {
  padding-top: var(--sat);
  padding-bottom: calc(var(--sab) + 65px);
  padding-left: var(--sal);
  padding-right: var(--sar);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Bottom navigation bar safe area */
.bottom-nav {
  padding-bottom: var(--sab);
}

/* Scanner viewport wrapper */
#reader {
  width: 100% !important;
  border: none !important;
  border-radius: 1rem;
  overflow: hidden;
  position: relative;
  background-color: #0f172a;
}

#reader video {
  border-radius: 1rem;
  object-fit: cover !important;
  width: 100% !important;
}

#qr-shaded-region {
  display: none !important;
}


/* Reticle scan frame */
.scan-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  height: 180px;
  border: 2px solid rgba(59, 130, 246, 0.9);
  border-radius: 14px;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 10;
}

.scan-reticle::before,
.scan-reticle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: #38bdf8;
  border-style: solid;
}

.scan-reticle::before {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
  border-top-left-radius: 10px;
}

.scan-reticle::after {
  bottom: -2px;
  right: -2px;
  border-width: 0 3px 3px 0;
  border-bottom-right-radius: 10px;
}

/* Laser scan animation line */
.scan-laser {
  position: absolute;
  top: 0;
  left: 5%;
  width: 90%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #38bdf8, #60a5fa, transparent);
  box-shadow: 0 0 10px #38bdf8;
  animation: scanLaser 2s infinite ease-in-out alternate;
  pointer-events: none;
  z-index: 11;
}

@keyframes scanLaser {
  0% {
    top: 5%;
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
  100% {
    top: 92%;
    opacity: 0.3;
  }
}

/* Flash feedback effect */
.flash-success {
  animation: flashSuccess 0.45s ease-out;
}

@keyframes flashSuccess {
  0% { background-color: rgba(34, 197, 94, 0.4); }
  100% { background-color: transparent; }
}

.flash-warning {
  animation: flashWarning 0.5s ease-out;
}

@keyframes flashWarning {
  0% { background-color: rgba(239, 68, 68, 0.4); }
  100% { background-color: transparent; }
}

/* Smooth active state */
button:active {
  transform: scale(0.97);
  transition: transform 0.08s ease;
}
