/* public/css/style.css */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* ===== 登录页 ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-container { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-header { text-align: center; margin-bottom: 30px; }
.logo-large { font-size: 64px; }
.login-header h1 { margin: 10px 0 5px; font-size: 22px; }
.login-header p { color: #888; font-size: 14px; }

/* ===== 布局 ===== */
.app-container { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 28px; }
.brand h1 { font-size: 18px; color: #333; }
.user-info { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.badge {
  background: #e8f5e9; color: #2e7d32; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
}
.badge.admin { background: #fff3e0; color: #e65100; }

.layout { display: flex; flex: 1; }
.sidebar {
  width: 220px;
  background: #fff;
  padding: 20px 0;
  border-right: 1px solid #eee;
  min-height: calc(100vh - 60px);
}
.sidebar nav { display: flex; flex-direction: column; }
.nav-item {
  padding: 12px 24px;
  color: #555;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}
.nav-item:hover { background: #f5f5f5; color: #333; }
.nav-item.active { background: #e8f0fe; color: #1a73e8; border-left-color: #1a73e8; font-weight: 500; }

.main-content { flex: 1; padding: 24px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== 卡片 ===== */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  margin-bottom: 20px;
}
.card h2 { font-size: 18px; margin-bottom: 20px; color: #222; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.card-header h2 { margin-bottom: 0; }

/* ===== 计数面板 ===== */
.count-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 30px; }
.count-box {
  text-align: center;
  padding: 24px;
  border-radius: 12px;
  color: #fff;
}
.count-box.total { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.count-box.scanned { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.count-box.missing { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.count-label { font-size: 14px; opacity: 0.9; margin-bottom: 8px; }
.count-value { font-size: 42px; font-weight: bold; }

.scan-section { margin-bottom: 20px; }
.scan-section h3 { font-size: 15px; margin-bottom: 12px; color: #555; }
.scanned-tags {
  min-height: 80px;
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.tag-chip {
  background: #e8f0fe; color: #1a73e8; padding: 4px 12px; border-radius: 16px; font-size: 13px;
  animation: pop 0.3s ease;
}
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.hint { color: #aaa; font-size: 14px; }

.actions { display: flex; gap: 12px; }

.missing-section { margin-top: 20px; }
.missing-section h3 { color: #d32f2f; margin-bottom: 12px; }
.missing-list { list-style: none; max-height: 200px; overflow-y: auto; }
.missing-list li {
  padding: 8px 12px; background: #fff5f5; border-left: 3px solid #f44336;
  margin-bottom: 6px; border-radius: 4px; font-family: monospace; font-size: 14px;
}

/* ===== 表格 ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px; text-align: left; border-bottom: 1px solid #eee; font-size: 14px; }
.data-table th { background: #f8f9fa; font-weight: 600; color: #555; }
.data-table tr:hover { background: #fafafa; }
.status-badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.status-badge.在养 { background: #e8f5e9; color: #2e7d32; }
.status-badge.已售出 { background: #e3f2fd; color: #1565c0; }
.status-badge.已屠宰 { background: #fff3e0; color: #e65100; }
.status-badge.已死亡 { background: #ffebee; color: #c62828; }
.loading { text-align: center; color: #888; padding: 30px; }

/* ===== 按钮 ===== */
.btn {
  padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; transition: 0.2s;
  background: #e0e0e0; color: #333;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #1a73e8; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: #f44336; color: #fff; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; color: #555; font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; transition: border 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: #1a73e8; }
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-row input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid input, .form-grid select { padding: 10px; border: 1px solid #ddd; border-radius: 6px; }

.filter-bar { margin-bottom: 16px; }
.filter-bar select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; }

.hint-text { color: #888; font-size: 12px; }
.mt-2 { margin-top: 10px; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-content {
  background: #fff; padding: 30px; border-radius: 12px; width: 100%; max-width: 500px;
  position: relative; max-height: 90vh; overflow-y: auto;
}
.modal-content .close { position: absolute; top: 15px; right: 20px; font-size: 24px; cursor: pointer; color: #888; }

/* ===== 提示 ===== */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 14px; margin-bottom: 12px; }
.alert-warning { background: #fff8e1; border: 1px solid #ffc107; color: #f57f17; }
.alert-error { background: #ffebee; border: 1px solid #f44336; color: #c62828; }

.admin-section { margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid #eee; }
.admin-section h3 { margin-bottom: 12px; font-size: 15px; color: #444; }

/* ===== 进出方向标签 ===== */
.tag-chip.chip-in { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.tag-chip.chip-out { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }

/* ===== 进出计数盒 ===== */
.count-box.inside { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.count-box.outside { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.alert-info { background: #e3f2fd; border: 1px solid #90caf9; color: #1565c0; }
.alert-success { background: #e8f5e9; border: 1px solid #a5d6a7; color: #2e7d32; }
.alert-error { background: #ffebee; border: 1px solid #ef9a9a; color: #c62828; }

.chip-unknown {
  background: #ff9800;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  margin: 2px;
  font-size: 12px;
}
.tag-chip { display: inline-block; padding: 4px 8px; margin: 2px; border-radius: 4px; font-size: 12px; font-family: monospace; }
.chip-in { background: #4caf50; color: white; }
.chip-out { background: #2196f3; color: white; }
.chip-unknown { background: #ff9800; color: white; padding: 2px 6px; border-radius: 4px; margin: 2px; }

/* 实时扫描标签 */
.scanned-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 60px;
  padding: 12px;
  background: #f5f7fa;
  border-radius: 8px;
  border: 1px dashed #cfd8dc;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 13px;
  font-family: 'Consolas', 'Menlo', monospace;
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #90caf9;
  animation: chipIn 0.25s ease-out;
}
.tag-chip.chip-in {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #a5d6a7;
}
.tag-chip.chip-out {
  background: #fff3e0;
  color: #e65100;
  border-color: #ffcc80;
}
.tag-chip.chip-scan {
  background: #ede7f6;
  color: #6a1b9a;
  border-color: #ce93d8;
}
@keyframes chipIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 实时进出事件流 */
.live-events {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 12px;
  background: #1e1e2f;
  border-radius: 8px;
  font-family: 'Consolas', 'Menlo', monospace;
}
.live-event {
  padding: 6px 8px;
  border-bottom: 1px solid #2c2c44;
  color: #cfd8dc;
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.live-event .ev-time { color: #90a4ae; }
.live-event .ev-dir { margin-left: auto; font-weight: bold; }
.live-event.event-in .ev-dir { color: #66bb6a; }
.live-event.event-out .ev-dir { color: #ffa726; }
.live-event.event-scan .ev-dir { color: #ce93d8; }

/* 计数盒子 */
.count-grid, .live-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.count-box {
  padding: 18px;
  border-radius: 12px;
  text-align: center;
  color: #fff;
}
.count-box.total { background: linear-gradient(135deg, #42a5f5, #1e88e5); }
.count-box.scanned { background: linear-gradient(135deg, #66bb6a, #2e7d32); }
.count-box.missing { background: linear-gradient(135deg, #ef5350, #c62828); }
.count-box.inside { background: linear-gradient(135deg, #26a69a, #00897b); }
.count-box.outside { background: linear-gradient(135deg, #ffa726, #ef6c00); }
.count-box.today-in { background: linear-gradient(135deg, #5c6bc0, #3949ab); }
.count-box.today-out { background: linear-gradient(135deg, #8d6e63, #5d4037); }
.count-label { font-size: 14px; opacity: 0.9; }
.count-value { font-size: 36px; font-weight: 700; margin-top: 8px; }

/* 缺失清单 */
.missing-list {
  list-style: none;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}
.missing-list li {
  padding: 6px 10px;
  border-bottom: 1px dashed #e0e0e0;
  font-family: 'Consolas', 'Menlo', monospace;
}
.hint { color: #90a4ae; font-style: italic; }
.hint-text { color: #90a4ae; font-size: 12px; }

/* ===== 手机自适应 ===== */
@media (max-width: 768px) {
  /* 顶栏 */
  .topbar {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .brand h1 { font-size: 16px; }
  .user-info { flex-wrap: wrap; gap: 6px; font-size: 12px; }
  .user-info .btn-sm { padding: 4px 8px; font-size: 12px; }

  /* 布局：侧边栏改为顶部横向导航 */
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-height: auto;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid #eee;
    overflow-x: auto;
  }
  .sidebar nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-item {
    padding: 10px 14px;
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    font-size: 13px;
  }
  .nav-item.active {
    border-left: none;
    border-bottom-color: #1a73e8;
  }

  /* 主内容区 */
  .main-content { padding: 12px; }
  .card { padding: 14px; border-radius: 8px; }
  .card h2 { font-size: 16px; margin-bottom: 12px; }

  /* 计数盒子：2列 */
  .count-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .count-box { padding: 14px; }
  .count-value { font-size: 28px; }
  .count-label { font-size: 12px; }

  /* 表格：横向滚动 */
  .data-table, .daily-summary-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  .data-table th, .data-table td,
  .daily-summary-table th, .daily-summary-table td {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* 扫描区 */
  .scanned-tags { min-height: 60px; padding: 10px; }
  .tag-chip { font-size: 11px; padding: 3px 8px; }

  /* 按钮 */
  .btn { padding: 6px 12px; font-size: 13px; }
  .btn-sm { padding: 4px 8px; font-size: 12px; }

  /* 筛选栏 */
  .filter-bar { gap: 6px; }
  .filter-bar input,
  .filter-bar select { font-size: 12px; padding: 5px 8px; }

  /* 操作栏 */
  .action-bar { gap: 6px; }

  /* 弹窗 */
  .modal-content {
    padding: 20px;
    max-width: 95%;
    margin: 10px;
  }

  /* 表单 */
  .form-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .form-row input,
  .form-row select { width: 100%; }

  /* 缺失清单 */
  .missing-list { max-height: 200px; }
  .missing-list li { font-size: 12px; padding: 6px 8px; }

  /* 任务信息框 */
  .task-info-box { font-size: 12px; padding: 10px 12px; }

  /* 实时事件流 */
  .live-events { max-height: 200px; font-size: 12px; }

  /* 实时进出统计 */
  .live-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

@media (max-width: 480px) {
  /* 计数盒子：1列 */
  .count-grid { grid-template-columns: 1fr; }

  /* 顶栏简化 */
  .brand .logo { font-size: 22px; }
  .brand h1 { font-size: 14px; }

  /* 侧边栏导航更紧凑 */
  .nav-item { padding: 8px 10px; font-size: 12px; }

  /* 按钮全宽 */
  .action-bar .btn { flex: 1; }
  .actions .btn { flex: 1; }

  /* 隐藏部分次要信息 */
  .user-info .badge { display: none; }
}