/* J5019: 手机全屏 APP (PWA) + 钉钉免登按钮 + 双引擎真摄像头扫码弹窗 + 手机底部 5 键导航栏 */
/* OPUS55: 苹果级精修——iOS 毛玻璃悬浮底栏、激光扫描取景框、底部抽屉式（Bottom Sheet）确认面板。
 * 只改视觉；所有 id / class / data-scan-action / data-mobile-tab 与按钮文案保持不变。 */

:root {
  --ms-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ms-dur: 180ms;
  --ms-laser: #22d3ee;
  --ms-corner: #38bdf8;
  --ms-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 钉钉按钮基础态（登录页的企业蓝渐变大按钮由 styles.css 的 #dingtalk-login-btn 精修覆盖） */
.dingtalk-login-btn {
  margin-top: 10px;
  min-height: 48px;
  border-color: #0b63f6;
  color: #fff;
  background: linear-gradient(135deg, #1a8cff 0%, #0b63f6 55%, #2f54eb 100%);
  font-weight: 700;
}

.dingtalk-login-btn:hover {
  background: linear-gradient(135deg, #3399ff 0%, #0b63f6 50%, #2340d0 100%);
  border-color: #0a58dc;
}

.mobile-scan-inline-wrap {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.mobile-scan-inline-wrap > input {
  flex: 1 1 auto;
  min-width: 0;
}

.mobile-scan-trigger-btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #0369a1;
  background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 4px 12px rgba(2, 132, 199, 0.22);
  transition: transform var(--ms-dur) var(--ms-ease), box-shadow var(--ms-dur) var(--ms-ease), background-color var(--ms-dur) var(--ms-ease);
}

.mobile-scan-trigger-btn:hover,
.btn.mobile-scan-trigger-btn:hover:not(:disabled) {
  color: #fff;
  border-color: #075985;
  background: linear-gradient(180deg, #0ea5e9 0%, #0369a1 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 8px 18px rgba(2, 132, 199, 0.3);
}

.mobile-scan-trigger-btn:active,
.btn.mobile-scan-trigger-btn:active:not(:disabled) {
  transform: scale(0.96);
}

/* 摄像头扫码全屏/卡片弹窗 */
.mobile-scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 2200;
  background: rgba(2, 6, 23, 0.72);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: ms-fade-in 220ms var(--ms-ease) both;
}

.mobile-scanner-dialog {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, #0f172a 0%, #0b1120 100%);
  color: #f8fafc;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 30px 80px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  animation: ms-pop-in 280ms var(--ms-ease) both;
}

.mobile-scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.mobile-scanner-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f8fafc;
}

.mobile-scanner-close {
  min-height: 40px;
  min-width: 64px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--ms-dur) var(--ms-ease), transform var(--ms-dur) var(--ms-ease);
}

.mobile-scanner-close:hover { background: rgba(255, 255, 255, 0.14); }
.mobile-scanner-close:active { transform: scale(0.95); }

.mobile-scanner-viewport {
  position: relative;
  width: 100%;
  height: 280px;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(56, 189, 248, 0.1), transparent 70%),
    #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 取景提示：在取景框下方居中 */
.mobile-scanner-viewport::after {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 2;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.55);
  color: #bae6fd;
  content: "将中转筐二维码 / 批次条码置于框内";
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.mobile-scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 四角高光取景框 + 激光扫描线 */
.mobile-scanner-reticle {
  position: absolute;
  width: 210px;
  height: 210px;
  border: 0;
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.5), inset 0 0 0 1px rgba(56, 189, 248, 0.16);
  pointer-events: none;
  background:
    linear-gradient(var(--ms-corner), var(--ms-corner)) top left / 30px 3px no-repeat,
    linear-gradient(var(--ms-corner), var(--ms-corner)) top left / 3px 30px no-repeat,
    linear-gradient(var(--ms-corner), var(--ms-corner)) top right / 30px 3px no-repeat,
    linear-gradient(var(--ms-corner), var(--ms-corner)) top right / 3px 30px no-repeat,
    linear-gradient(var(--ms-corner), var(--ms-corner)) bottom left / 30px 3px no-repeat,
    linear-gradient(var(--ms-corner), var(--ms-corner)) bottom left / 3px 30px no-repeat,
    linear-gradient(var(--ms-corner), var(--ms-corner)) bottom right / 30px 3px no-repeat,
    linear-gradient(var(--ms-corner), var(--ms-corner)) bottom right / 3px 30px no-repeat;
}

.mobile-scanner-reticle::before {
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 2px;
  content: "";
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--ms-laser) 18%, #cffafe 50%, var(--ms-laser) 82%, transparent);
  box-shadow: 0 0 12px 2px rgba(34, 211, 238, 0.7), 0 0 28px 6px rgba(34, 211, 238, 0.25);
  animation: ms-laser 2.4s ease-in-out infinite alternate;
}

.mobile-scanner-reticle::after {
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 46px;
  content: "";
  background: linear-gradient(180deg, rgba(34, 211, 238, 0), rgba(34, 211, 238, 0.16));
  animation: ms-laser-trail 2.4s ease-in-out infinite alternate;
}

.mobile-scanner-body {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-scanner-status {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid rgba(56, 189, 248, 0.16);
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.06);
  font-size: 13px;
  color: #a5b4c8;
  line-height: 1.5;
}

.mobile-scanner-manual-row {
  display: flex;
  gap: 8px;
}

.mobile-scanner-manual-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 46px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
  font-size: 15px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  transition: border-color var(--ms-dur) var(--ms-ease), box-shadow var(--ms-dur) var(--ms-ease);
}

.mobile-scanner-manual-input::placeholder { color: #64748b; font-family: inherit; }

.mobile-scanner-manual-input:focus {
  outline: 0;
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
}

.mobile-scanner-confirm-btn {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 18px rgba(14, 165, 233, 0.35);
  transition: transform var(--ms-dur) var(--ms-ease), box-shadow var(--ms-dur) var(--ms-ease);
}

.mobile-scanner-confirm-btn:active { transform: scale(0.96); }

.mobile-scanner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mobile-scanner-actions button {
  flex: 1 1 120px;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--ms-dur) var(--ms-ease), transform var(--ms-dur) var(--ms-ease);
}

.mobile-scanner-actions button:hover { background: rgba(255, 255, 255, 0.09); }
.mobile-scanner-actions button:active { transform: scale(0.97); }

/* 扫码成功后的快捷动作面板（整筐领用 / 部分领用 / 去交接点数确认） */
.mobile-scan-action-sheet {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--ms-safe-bottom));
  transform: translateX(-50%);
  z-index: 2150;
  width: calc(100% - 24px);
  max-width: 460px;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  color: #0f172a;
  border-radius: 22px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 24px 60px rgba(15, 23, 42, 0.28);
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: ms-sheet-center 320ms var(--ms-ease) both;
}

/* 抽屉把手 */
.mobile-scan-action-sheet::before {
  display: block;
  width: 40px;
  height: 5px;
  margin: 2px auto 0;
  content: "";
  border-radius: 999px;
  background: #cbd5e1;
}

.mobile-scan-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mobile-scan-sheet-title {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.mobile-scan-sheet-close {
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 0;
  background: rgba(15, 23, 42, 0.06);
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--ms-dur) var(--ms-ease);
}

.mobile-scan-sheet-close:hover { background: rgba(15, 23, 42, 0.1); }

.mobile-scan-sheet-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.mobile-scan-sheet-btn {
  position: relative;
  min-height: 56px;
  padding: 12px 44px 12px 16px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: transform var(--ms-dur) var(--ms-ease), box-shadow var(--ms-dur) var(--ms-ease), border-color var(--ms-dur) var(--ms-ease), background-color var(--ms-dur) var(--ms-ease);
}

.mobile-scan-sheet-btn::after {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  content: "›";
  color: #94a3b8;
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.mobile-scan-sheet-btn:hover { border-color: #93c5fd; box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08); }
.mobile-scan-sheet-btn:active { transform: scale(0.98); }

.mobile-scan-sheet-btn[data-scan-action="consume-partial"] {
  border-color: #fcd34d;
  background: linear-gradient(90deg, #fffbeb, #fff 70%);
  box-shadow: inset 4px 0 0 #f59e0b, 0 1px 2px rgba(15, 23, 42, 0.05);
}

.mobile-scan-sheet-btn[data-scan-action="handoff-confirm"] {
  border-color: #a7f3d0;
  background: linear-gradient(90deg, #ecfdf5, #fff 70%);
  box-shadow: inset 4px 0 0 #10b981, 0 1px 2px rgba(15, 23, 42, 0.05);
}

.mobile-scan-sheet-btn.primary {
  border-color: #1d4ed8;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 10px 24px rgba(37, 99, 235, 0.32);
}

.mobile-scan-sheet-btn.primary::after { color: rgba(255, 255, 255, 0.85); }
.mobile-scan-sheet-btn.primary:hover { border-color: #1e40af; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 14px 30px rgba(37, 99, 235, 0.38); }

/* 手机端底部 5 大高频动作导航栏（仅 <=820px 显示） */
.mobile-bottom-tabbar {
  display: none;
}

@media (max-width: 820px) {
  .mobile-bottom-tabbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + var(--ms-safe-bottom));
    z-index: 1050;
    height: 64px;
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    padding: 0 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 0 0 0.5px rgba(15, 23, 42, 0.08), 0 12px 32px rgba(15, 23, 42, 0.18);
  }

  .mobile-bottom-tab {
    position: relative;
    min-height: 52px;
    border: none;
    border-radius: 18px;
    background: transparent;
    color: #64748b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--ms-dur) var(--ms-ease), background-color var(--ms-dur) var(--ms-ease), transform var(--ms-dur) var(--ms-ease);
  }

  .mobile-bottom-tab:active {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.06);
    transform: scale(0.94);
  }

  .mobile-bottom-tab.is-active {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
  }

  /* 激活态：顶部荧光指示条 */
  .mobile-bottom-tab.is-active::before {
    position: absolute;
    top: 0;
    left: 50%;
    width: 24px;
    height: 3px;
    margin-left: -12px;
    content: "";
    border-radius: 0 0 3px 3px;
    background: #2563eb;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.85), 0 0 2px rgba(59, 130, 246, 1);
  }

  .mobile-bottom-tab-icon {
    font-size: 19px;
    line-height: 1.1;
    filter: grayscale(0.85) opacity(0.72);
    transition: filter var(--ms-dur) var(--ms-ease), transform var(--ms-dur) var(--ms-ease);
  }

  .mobile-bottom-tab.is-active .mobile-bottom-tab-icon {
    filter: none;
    animation: ms-tab-bounce 460ms var(--ms-ease) both;
  }

  .mobile-bottom-tab-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-bottom-tab:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
    box-shadow: none;
  }

  .layout .main-column {
    padding-bottom: calc(88px + var(--ms-safe-bottom));
  }

  /* 手机端：底部抽屉贴边，位于悬浮底栏之上 */
  .mobile-scan-action-sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    transform: none;
    padding: 8px 16px calc(92px + var(--ms-safe-bottom));
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 -12px 40px rgba(15, 23, 42, 0.22);
    animation: ms-sheet-up 340ms var(--ms-ease) both;
  }
}

/* 手机全屏扫码：弹窗改为自底部升起的全宽卡片 */
@media (max-width: 560px) {
  .mobile-scanner-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .mobile-scanner-dialog {
    max-width: none;
    max-height: 100dvh;
    overflow-y: auto;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    padding-bottom: var(--ms-safe-bottom);
    animation: ms-sheet-up 320ms var(--ms-ease) both;
  }

  .mobile-scanner-viewport {
    height: min(52vh, 360px);
  }

  .mobile-scanner-reticle {
    width: min(64vw, 240px);
    height: min(64vw, 240px);
  }
}

@keyframes ms-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ms-pop-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes ms-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes ms-sheet-center { from { opacity: 0; transform: translate(-50%, 24px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes ms-laser { from { transform: translateY(10px); } to { transform: translateY(calc(min(64vw, 240px) - 12px)); } }
@keyframes ms-laser-trail {
  from { transform: translateY(-36px); opacity: 0; }
  25% { opacity: 0.9; }
  to { transform: translateY(calc(min(64vw, 240px) - 58px)); opacity: 0.9; }
}
@keyframes ms-tab-bounce {
  0% { transform: scale(1); }
  35% { transform: translateY(-3px) scale(1.2); }
  65% { transform: translateY(0) scale(0.95); }
  100% { transform: scale(1); }
}

@media (min-width: 561px) {
  /* 桌面/平板固定 210px 取景框：扫描线行程与框高一致 */
  .mobile-scanner-reticle::before { animation-name: ms-laser-desktop; }
  .mobile-scanner-reticle::after { animation-name: ms-laser-trail-desktop; }
}
@keyframes ms-laser-desktop { from { transform: translateY(10px); } to { transform: translateY(198px); } }
@keyframes ms-laser-trail-desktop {
  from { transform: translateY(-36px); opacity: 0; }
  25% { opacity: 0.9; }
  to { transform: translateY(152px); opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-scanner-overlay,
  .mobile-scanner-dialog,
  .mobile-scan-action-sheet,
  .mobile-bottom-tab.is-active .mobile-bottom-tab-icon,
  .mobile-scanner-reticle::after {
    animation: none !important;
  }
  .mobile-scanner-reticle::before {
    animation: none !important;
    top: 50%;
  }
  .mobile-bottom-tab,
  .mobile-scan-sheet-btn,
  .mobile-scan-trigger-btn {
    transition: none !important;
  }
}
