/* ============================================================================
 * scanner.css —— 扫码枪适配层的视觉反馈（v18.25）
 * 依赖：scanner.js
 * 三端共用：admin.html / staff.html / h5/verify.html
 * 设计口径：只做「反馈层」，不改各端既有主题色
 *   · 成功闪绿 #00B42A、失败闪红 #F53F3F（与小程序 --success / --danger 一致）
 *   · 遮罩用半透明白 + 细描边，避免盖住券信息
 * ==========================================================================*/

/* ---------- 1. 输入框边框闪烁 ---------- */
@keyframes scanFlashOk {
  0%   { box-shadow: 0 0 0 0 rgba(0, 180, 42, .55); border-color: #00B42A; }
  40%  { box-shadow: 0 0 0 6px rgba(0, 180, 42, .22); border-color: #00B42A; }
  100% { box-shadow: 0 0 0 0 rgba(0, 180, 42, 0); }
}
@keyframes scanFlashFail {
  0%   { box-shadow: 0 0 0 0 rgba(245, 63, 63, .55); border-color: #F53F3F; }
  40%  { box-shadow: 0 0 0 6px rgba(245, 63, 63, .22); border-color: #F53F3F; }
  100% { box-shadow: 0 0 0 0 rgba(245, 63, 63, 0); }
}

.scan-flash-ok {
  border-color: #00B42A !important;
  animation: scanFlashOk .72s cubic-bezier(.2, .9, .25, 1);
}
.scan-flash-fail {
  border-color: #F53F3F !important;
  animation: scanFlashFail .72s cubic-bezier(.2, .9, .25, 1);
}

/* 扫码枪就绪的常驻呼吸光标（挂在输入框外层容器上，可选） */
.scan-ready::after {
  content: '';
  position: absolute;
  right: 14px; top: 50%;
  width: 8px; height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: #00B42A;
  box-shadow: 0 0 0 0 rgba(0, 180, 42, .6);
  animation: scanPulse 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes scanPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 180, 42, .6); }
  70%  { box-shadow: 0 0 0 8px rgba(0, 180, 42, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 180, 42, 0); }
}

/* ---------- 2. Loading 遮罩 ---------- */
.scan-mask {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: inherit;
  z-index: 20;
  cursor: progress;
}
.scan-mask.on { display: flex; }

.scan-mask-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .1);
}
.scan-mask-tx {
  font-size: 13px;
  font-weight: 600;
  color: #1F2329;
  letter-spacing: .2px;
}
.scan-spin {
  width: 15px; height: 15px;
  border: 2px solid rgba(22, 119, 255, .22);
  border-top-color: #1677FF;
  border-radius: 50%;
  animation: scanSpin .7s linear infinite;
  flex: none;
}
@keyframes scanSpin { to { transform: rotate(360deg); } }

/* 按钮忙态 */
.btn.is-busy, button.is-busy {
  opacity: .72;
  cursor: progress;
  pointer-events: none;
}

/* ---------- 3. 摄像头降级扫码 ---------- */
.scan-cam {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: #0B0D10;
  color: #fff;
  animation: scanCamIn .22s ease;
}
@keyframes scanCamIn {
  from { opacity: 0; transform: scale(.98); }
  to   { opacity: 1; transform: scale(1); }
}
.scan-cam-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  flex: none;
}
.scan-cam-t { font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.scan-cam-x {
  width: 34px; height: 34px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff; font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.scan-cam-body {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.scan-cam-body video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.scan-cam-frame {
  position: absolute;
  width: min(68vw, 300px);
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .5);
  pointer-events: none;
}
.scan-cam-frame i {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background:
    linear-gradient(90deg, #00E07A 0 22px, transparent 22px) 0 0 / 100% 3px no-repeat,
    linear-gradient(90deg, transparent calc(100% - 22px), #00E07A calc(100% - 22px)) 0 0 / 100% 3px no-repeat,
    linear-gradient(90deg, #00E07A 0 22px, transparent 22px) 0 100% / 100% 3px no-repeat,
    linear-gradient(90deg, transparent calc(100% - 22px), #00E07A calc(100% - 22px)) 0 100% / 100% 3px no-repeat,
    linear-gradient(180deg, #00E07A 0 22px, transparent 22px) 0 0 / 3px 100% no-repeat,
    linear-gradient(180deg, transparent calc(100% - 22px), #00E07A calc(100% - 22px)) 0 0 / 3px 100% no-repeat,
    linear-gradient(180deg, #00E07A 0 22px, transparent 22px) 100% 0 / 3px 100% no-repeat,
    linear-gradient(180deg, transparent calc(100% - 22px), #00E07A calc(100% - 22px)) 100% 0 / 3px 100% no-repeat;
  animation: scanFramePulse 2s ease-in-out infinite;
}
@keyframes scanFramePulse {
  0%, 100% { opacity: .55; }
  50%      { opacity: 1; }
}
.scan-cam-tip {
  flex: none;
  padding: 14px 20px max(20px, env(safe-area-inset-bottom));
  font-size: 12.5px;
  color: rgba(255, 255, 255, .68);
  text-align: center;
  line-height: 1.6;
}

/* ---------- 4. 输入框旁扫码按钮（通用小样式） ---------- */
.scan-cam-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(0, 0, 0, .1);
  background: #fff;
  border-radius: 10px;
  height: 40px;
  padding: 0 12px;
  font-size: 13px;
  color: #4E5969;
  cursor: pointer;
  transition: all .18s;
  flex: none;
}
.scan-cam-btn:hover { border-color: #1677FF; color: #1677FF; background: #F5F9FF; }
.scan-cam-btn:active { transform: scale(.97); }

/* ---------- 5. 「支持扫码枪直扫」提示 ---------- */
.scan-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #86909C;
  line-height: 1.5;
}
.scan-hint b { color: #4E5969; font-weight: 600; }
.scan-hint-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 4px;
  background: #EAF2FF;
  color: #1677FF;
  font-size: 10px;
  flex: none;
}

/* ---------- 6. 移动端细调 ---------- */
@media (max-width: 640px) {
  .scan-cam-btn { width: 44px; height: 44px; padding: 0; }
  .scan-cam-btn .tx { display: none; }
  .scan-mask-tx { font-size: 12.5px; }
}

/* ---------- 7. 降级：不支持 backdrop-filter 的旧浏览器 ---------- */
@supports not (backdrop-filter: blur(2px)) {
  .scan-mask { background: rgba(255, 255, 255, .94); }
}
