/* ============================================
   扫菲系统 - 全局样式
   Mobile First · Bootstrap 5 Overrides
   ============================================ */

:root {
  --jh-primary: #1a73e8;
  --jh-success: #34a853;
  --jh-warning: #fbbc04;
  --jh-danger: #ea4335;
  --jh-bg: #f5f7fa;
  --jh-card-bg: #ffffff;
  --jh-text: #1f2937;
  --jh-muted: #6b7280;
  --jh-border: #e5e7eb;
  --jh-radius: 12px;
  --jh-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ---- Base ---- */
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--jh-bg);
  color: var(--jh-text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- Typography ---- */
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--jh-text);
  padding: 0.75rem 0 0.5rem;
  border-bottom: 2px solid var(--jh-primary);
  margin-bottom: 1rem;
}

/* ---- Cards ---- */
.card {
  border: none;
  border-radius: var(--jh-radius);
  box-shadow: var(--jh-shadow);
  margin-bottom: 0.75rem;
}
.card-body { padding: 1rem; }
.card + .card { margin-top: 12px; }

/* ---- Buttons (large touch targets) ---- */
.btn {
  border-radius: 10px;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  min-height: 44px;
  min-width: 80px;
  transition: all 0.15s ease;
}
.btn + .btn { margin-left: 8px; }
.btn-lg { font-size: 1.125rem; padding: 0.75rem 1.5rem; min-height: 50px; }
.btn-xl {
  font-size: 1.25rem;
  padding: 1rem 2rem;
  border-radius: 14px;
  min-height: 56px;
}
.btn-primary { background: var(--jh-primary); border-color: var(--jh-primary); }
.btn-primary:hover, .btn-primary:active { background: #1557b0; border-color: #1557b0; }
.btn-success { background: var(--jh-success); border-color: var(--jh-success); }
.btn-success:hover, .btn-success:active { background: #2d8f47; border-color: #2d8f47; }
.btn-warning { background: var(--jh-warning); border-color: var(--jh-warning); color: #333; }
.btn-warning:hover, .btn-warning:active { background: #e5aa00; border-color: #e5aa00; color: #333; }
.btn-danger { background: var(--jh-danger); border-color: var(--jh-danger); }
.btn-danger:hover, .btn-danger:active { background: #d33426; border-color: #d33426; }
.btn-outline-primary { border-color: var(--jh-primary); color: var(--jh-primary); }
.btn-outline-primary:hover, .btn-outline-primary:active { background: var(--jh-primary); color: #fff; }

/* 禁用按钮状态 */
.btn:disabled, .btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* ---- Forms ---- */
.form-label { font-weight: 600; font-size: 0.875rem; margin-bottom: 0.25rem; }
.form-control, .form-select {
  border-radius: 10px;
  border: 1.5px solid var(--jh-border);
  padding: 0.7rem 1rem;
  font-size: 1rem;
  min-height: 48px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--jh-primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
.form-check-input { width: 1.3em; height: 1.3em; margin-top: 0.15em; }
.form-check-input:checked { background-color: var(--jh-primary); border-color: var(--jh-primary); }
.input-group-text { border-radius: 10px; background: var(--jh-bg); border: 1.5px solid var(--jh-border); }

/* ---- Badges / Tags ---- */
.badge {
  font-weight: 600;
  padding: 0.35em 0.7em;
  border-radius: 8px;
  font-size: 0.8rem;
}
.badge-pill { border-radius: 50px; }

/* ---- Progress Bar ---- */
.progress {
  height: 22px;
  border-radius: 50px;
  background: #e9ecef;
}
.progress-bar {
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 22px;
}

/* ---- Table ---- */
.table {
  font-size: 0.95rem;
  margin-bottom: 0;
}
.table th {
  background: #eef1f5;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--jh-text);
  border-bottom: 2px solid var(--jh-border);
  padding: 0.65rem 0.6rem;
  line-height: 1.3;
}
.table td {
  padding: 0.55rem 0.6rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--jh-border);
  line-height: 1.4;
}
/* 表格行高 */
.table tbody tr { min-height: 40px; }
.table thead tr { min-height: 48px; }
/* 悬停高亮 */
.table tbody tr:hover {
  background: #f0f7ff !important;
  transition: background 0.12s;
}

/* ---- List Group ---- */
.list-group-item {
  border: none;
  border-radius: 10px !important;
  margin-bottom: 6px;
  padding: 0.9rem 1rem;
  background: var(--jh-card-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ---- Header / Nav ---- */
.app-header {
  background: var(--jh-primary);
  color: #fff;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1050;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.app-header h1 {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 700;
}
.app-header .btn-back {
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 0.5rem;
  text-decoration: none;
}
.app-footer-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--jh-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.4rem 0;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 1050;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.app-footer-nav .nav-item {
  text-align: center;
  color: var(--jh-muted);
  font-size: 0.7rem;
  text-decoration: none;
  flex: 1;
  padding: 0.25rem 0;
}
.app-footer-nav .nav-item.active { color: var(--jh-primary); }
.app-footer-nav .nav-item i { font-size: 1.4rem; display: block; margin-bottom: 2px; }

/* ---- Worker Page (极简大字) ---- */
.worker-page {
  background: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.worker-page .worker-header {
  background: var(--jh-primary);
  color: #fff;
  text-align: center;
  padding: 1.5rem 1rem;
}
.worker-page .worker-header h1 { font-size: 1.8rem; font-weight: 800; }
.worker-page .worker-header p { font-size: 1.1rem; opacity: 0.85; margin: 0; }
.worker-page .worker-body {
  flex: 1;
  padding: 1.25rem;
}
.worker-page .worker-btn {
  display: block;
  width: 100%;
  padding: 1.25rem;
  font-size: 1.4rem;
  font-weight: 700;
  border-radius: 16px;
  text-align: center;
  margin-bottom: 1rem;
}
.worker-page .worker-card {
  background: var(--jh-card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--jh-shadow);
  border-left: 5px solid var(--jh-primary);
}
.worker-page .worker-card h3 { font-size: 1.3rem; font-weight: 700; }
.worker-page .worker-card .info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--jh-border);
}
.worker-page .worker-card .info-row:last-child { border-bottom: none; }
.worker-page .worker-card .label { color: var(--jh-muted); font-weight: 500; }
.worker-page .worker-card .value { font-weight: 700; }
.worker-page .process-check-list label {
  display: flex;
  align-items: center;
  padding: 1rem;
  margin-bottom: 8px;
  background: #f8fafc;
  border-radius: 14px;
  font-size: 1.2rem;
  font-weight: 600;
  border: 2px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}
.worker-page .process-check-list label:active,
.worker-page .process-check-list label.selected {
  border-color: var(--jh-primary);
  background: #eef4ff;
}
.worker-page .process-check-list input[type="checkbox"] {
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 1rem;
  accent-color: var(--jh-primary);
}
.worker-page .worker-big-number {
  font-size: 3rem;
  font-weight: 800;
  color: var(--jh-primary);
  text-align: center;
  line-height: 1;
}

/* ---- Modal ---- */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-header {
  border-bottom: 1px solid var(--jh-border);
  padding: 1rem 1.25rem;
}
.modal-footer { border-top: 1px solid var(--jh-border); padding: 1rem 1.25rem; }
.modal-title { font-weight: 700; }
.modal-body { padding: 1.25rem; }

/* ---- Print Label (单张打印) ---- */
@media print {
  body { background: #fff; padding: 0; margin: 0.5in; }
  .no-print { display: none !important; }
  .label-page { page-break-after: always; }
}

.label-card {
  border: 2px solid #000;
  border-radius: 8px;
  padding: 1rem;
  background: #fff;
  max-width: 400px;
  margin: 0 auto 1rem;
}
.label-card .factory-name {
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}
.label-card .label-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.label-card .label-grid .item {
  display: flex;
  justify-content: space-between;
}
.label-card .label-grid .item .k { font-weight: 600; color: #555; }
.label-card .label-grid .item .v { font-weight: 700; }
.label-card .qr-area {
  text-align: center;
  margin: 0.5rem 0;
}
.label-card .qr-area svg, .label-card .qr-area img { width: 120px; height: 120px; }
.label-card .qr-area .qr-label { font-size: 0.7rem; color: #888; margin-top: 2px; }

/* ---- Dashboard ---- */
.stat-card {
  text-align: center;
  padding: 1.25rem 0.75rem;
  border-radius: var(--jh-radius);
  background: #fff;
  box-shadow: var(--jh-shadow);
}
.stat-card .stat-number {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--jh-primary);
  line-height: 1.2;
}
.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--jh-muted);
  font-weight: 500;
  margin-top: 4px;
}
/* 看板卡片布局间隙 */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* ---- Style List ---- */
.style-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--jh-border);
}
.style-item:last-child { border-bottom: none; }
.style-item .style-code {
  font-weight: 700;
  font-size: 1rem;
  flex: 1;
}
.style-item .style-progress {
  width: 80px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--jh-muted);
}

/* ---- QR Code Placeholder (纯CSS二维码方块) ---- */
.qr-placeholder {
  display: inline-block;
  width: 120px;
  height: 120px;
  background:
    linear-gradient(45deg, #000 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(-45deg, #000 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(45deg, transparent 75%, #000 75%) 0 0 / 20px 20px,
    linear-gradient(-45deg, transparent 75%, #000 75%) 0 0 / 20px 20px;
  background-color: #fff;
  image-rendering: pixelated;
  border: 2px solid #333;
  border-radius: 4px;
  position: relative;
}
.qr-placeholder::after {
  content: "◆";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: #000;
}

/* ---- 桌面端：容器宽度规则 ---- */
@media (min-width: 576px) {
  .container { max-width: 540px; }
}
@media (min-width: 768px) {
  .container { max-width: 720px; }
}

/* ---- 移动端适配 (max-width: 768px) ---- */
@media (max-width: 768px) {
  /* 表格→垂直卡片 */
  .table-responsive-stack table,
  .table-responsive-stack thead,
  .table-responsive-stack tbody,
  .table-responsive-stack th,
  .table-responsive-stack td,
  .table-responsive-stack tr {
    display: block;
  }
  .table-responsive-stack thead { display: none; }
  .table-responsive-stack tbody tr {
    background: var(--jh-card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    padding: 12px 14px;
    margin-bottom: 8px;
    border: none !important;
  }
  .table-responsive-stack td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none !important;
    font-size: 0.95rem;
  }
  .table-responsive-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--jh-muted);
    margin-right: 12px;
    flex-shrink: 0;
  }
  /* 堆叠卡片 */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .dashboard-grid .stat-card {
    padding: 18px 14px;
  }
  .dashboard-grid .stat-card .stat-number {
    font-size: 1.5rem;
  }
  /* 按钮自适应 */
  .btn { white-space: normal; word-break: break-word; }
}

@media (max-width: 576px) {
  .btn-xl { font-size: 1.15rem; padding: 0.85rem 1.5rem; }
  .worker-page .worker-header h1 { font-size: 1.5rem; }
  .worker-page .worker-btn { font-size: 1.2rem; padding: 1rem; }
}

/* ---- 视觉层次：提示信息 ---- */
.alert-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.alert-tip.warning { background: #fff3e0; color: #e65100; border-left: 4px solid #ff9800; }
.alert-tip.success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid #4caf50; }
.alert-tip.danger { background: #fce4ec; color: #c62828; border-left: 4px solid #e53935; }
.alert-tip.info { background: #e3f2fd; color: #1565c0; border-left: 4px solid #2196f3; }

/* ---- Utilities ---- */
.text-muted { color: var(--jh-muted) !important; }
.bg-soft-primary { background: #eef4ff; }
.bg-soft-success { background: #e6f7ee; }
.bg-soft-warning { background: #fff8e1; }
.border-dashed { border-style: dashed !important; }
.cursor-pointer { cursor: pointer; }
.min-h-100 { min-height: 100vh; }
.pb-safe { padding-bottom: calc(4rem + env(safe-area-inset-bottom)); }
.mt-safe { margin-top: env(safe-area-inset-top); }
.fw-700 { font-weight: 700 !important; }
.text-primary-dark { color: var(--jh-primary) !important; font-weight: 700; }
.text-success-dark { color: var(--jh-success) !important; font-weight: 700; }
