/* ============================================================
   PYP 设备扫码采集系统 —— 全站样式
   覆盖：移动端竖屏（用户端）+ 桌面后台 + 登录页 + 通用组件
   ============================================================ */

/* ---------- 基础与变量 ---------- */
:root {
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --bg: #f5f6f8;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
  color: #fff;
  background: var(--primary);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:not(:disabled):active {
  transform: translateY(1px);
}
.btn-block {
  display: flex;
  width: 100%;
}
.btn-primary {
  background: var(--primary);
}
.btn-primary:not(:disabled):hover {
  background: var(--primary-dark);
}
.btn-success {
  background: var(--success);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--danger);
}

/* ---------- 输入框 ---------- */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

/* ---------- Toast 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 10%;
  transform: translate(-50%, -20px);
  max-width: 86%;
  padding: 10px 18px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  background: rgba(17, 24, 39, 0.92);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  text-align: center;
  word-break: break-all;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast-error {
  background: var(--danger);
}
.toast-success {
  background: var(--success);
}
.toast-warn {
  background: var(--warn);
}

/* ============================================================
   用户端（移动竖屏）
   ============================================================ */
.mobile-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  padding: 24px 16px;
}

.mobile-page .card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  margin-top: 8vh;
}

.title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}
.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin: 6px 0 22px;
}

/* ---------- 扫码页 ---------- */
.scan-header {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.scan-userinfo {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  color: var(--text-secondary);
  overflow: hidden;
}
.scan-userinfo span:first-child {
  color: var(--text);
  font-weight: 600;
}

.scan-main {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scan-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 10px;
  font-size: 13px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
}

/* ---------- 缩放滑杆 ---------- */
.zoom-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
}
.zoom-wrap label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.zoom-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.sn-list-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 6px;
}
.sn-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}
.sn-list {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
}
.sn-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.sn-list li:last-child {
  border-bottom: none;
}
.sn-index {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sn-text {
  word-break: break-all;
}

.scan-footer {
  width: 100%;
  max-width: 420px;
  margin-top: 14px;
}

/* ============================================================
   后台登录页
   ============================================================ */
.admin-login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 30px;
}
.login-card h1 {
  font-size: 22px;
  text-align: center;
}
.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin: -6px 0 14px;
  text-align: center;
}

/* ============================================================
   管理后台（桌面）
   ============================================================ */
.admin-page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.admin-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-header h1 {
  font-size: 18px;
}
.admin-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tab {
  border: none;
  background: transparent;
  padding: 8px 16px;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab.active {
  background: rgba(22, 119, 255, 0.1);
  color: var(--primary);
  font-weight: 600;
}

.admin-main {
  flex: 1;
  padding: 24px 28px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}
.panel h2 {
  font-size: 16px;
  margin-bottom: 16px;
}
.hidden {
  display: none !important;
}

.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table thead th {
  background: #fafbfc;
  color: var(--text-secondary);
  font-weight: 600;
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.data-table td.empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px 16px;
}
.data-table td {
  word-break: break-all;
}

/* ---------- 白名单管理 ---------- */
.wl-add {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  max-width: 460px;
}
.wl-add input {
  flex: 1;
  padding: 11px 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.wl-add input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}
.wl-list {
  list-style: none;
  max-width: 460px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.wl-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.wl-list li:last-child {
  border-bottom: none;
}
.wl-list li.empty {
  color: var(--text-secondary);
  justify-content: center;
}
.remove-btn {
  border: 1px solid #fecaca;
  background: #fff1f1;
  color: var(--danger);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.remove-btn:hover {
  background: var(--danger);
  color: #fff;
}

/* ---------- 响应式：窄屏适配 ---------- */
@media (max-width: 640px) {
  .admin-header {
    padding: 12px 16px;
  }
  .admin-main {
    padding: 16px;
  }
  .data-table th,
  .data-table td {
    padding: 10px 8px;
    font-size: 13px;
  }
}
