/* ═══════════════════════════════════════
   植提产业数据平台 — 共享样式表 v1
   每个页面引入此文件后，只需定义自己的 :root 变量和页面特有样式
   ═══════════════════════════════════════ */

/* ── CSS Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 基础 ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--gray-bg, #f5f7fa);
  color: var(--dark, #1a1d23);
  min-height: 100vh;
}

/* ── 顶栏 ── */
header {
  background: var(--accent, #2d7a4f);
  color: #fff;
  padding: 0 28px;
  display: flex; align-items: center;
  height: 60px; gap: 14px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
header .logo { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
header .subtitle { font-size: 13px; opacity: .8; }
header .spacer { flex: 1; }
header a {
  color: rgba(255,255,255,.8); font-size: 12px; text-decoration: none;
  padding: 4px 10px; border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px; transition: background .15s; white-space: nowrap;
}
header a:hover { background: rgba(255,255,255,.15); }

/* ── 访客横幅 ── */
#guest-banner {
  background: linear-gradient(90deg,#fef3c7,#fde68a); color: #92400e;
  padding: 8px 20px; text-align: center; font-size: 13px; font-weight: 500;
  position: sticky; top: 60px; z-index: 99;
  box-shadow: 0 1px 3px rgba(0,0,0,.1); display: none;
}
#guest-banner a { color: #92400e; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* ── 主内容区 ── */
main { padding: 24px 28px; max-width: 1500px; }

/* ── 统计卡片 ── */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat-card {
  background: var(--white, #fff); border: 1px solid var(--gray-border, #dde1e7);
  border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.stat-card .label { font-size: 12px; color: var(--gray-text, #6b7280); }
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--dark, #1a1d23); }
.stat-card .sub { font-size: 12px; }

/* ── Tab 导航 ── */
.tab-nav {
  display: flex; gap: 2px; margin-bottom: 0; overflow-x: auto;
  background: var(--white, #fff); border-radius: 12px 12px 0 0;
  border: 1px solid var(--gray-border, #dde1e7); border-bottom: none;
  padding: 6px 6px 0 6px;
}
.tab-btn {
  border: none; background: transparent; padding: 10px 18px; font-size: 14px;
  cursor: pointer; color: var(--gray-text, #6b7280); border-radius: 8px 8px 0 0;
  white-space: nowrap; transition: all .15s;
}
.tab-btn.active { background: var(--accent-light, #e8f5ee); color: var(--accent, #2d7a4f); font-weight: 600; }
.tab-btn:hover { color: var(--accent, #2d7a4f); }

/* ── 工具栏 ── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center; background: var(--white, #fff);
  border: 1px solid var(--gray-border, #dde1e7); border-radius: 8px;
  padding: 7px 12px; gap: 8px; flex: 1; min-width: 200px; max-width: 360px;
}
.search-box input { border: none; outline: none; font-size: 16px; width: 100%; background: transparent; }

select, .filter-select {
  background: var(--white, #fff); border: 1px solid var(--gray-border, #dde1e7);
  border-radius: 8px; padding: 7px 12px; font-size: 16px; color: var(--dark, #1a1d23);
  cursor: pointer; outline: none;
}

/* ── 按钮 ── */
.btn {
  border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-weight: 500; transition: opacity .15s; white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent, #2d7a4f); color: #fff; }
.btn-outline { background: var(--white, #fff); border: 1px solid var(--gray-border, #dde1e7); color: var(--dark, #1a1d23); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-danger { background: #fee2e2; color: var(--red, #e53935); }
.btn-edit { background: var(--accent-light, #e8f5ee); color: var(--accent, #2d7a4f); }

/* ── 全局数据更新时间条 ── */
#global-update-time {
  text-align: center; padding: 6px 16px; font-size: 11px;
  background: #f0fdf4; color: #2d7a4f;
  border-bottom: 1px solid #bbf7d0;
  display: none;
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── 权限控制：guest/viewer 隐藏编辑/删除/新增/导出按钮 ── */
body.guest .btn-edit, body.guest .btn-danger, body.guest .btn-add, body.guest .btn-export,
body.viewer .btn-edit, body.viewer .btn-danger, body.viewer .btn-add,
body.viewer .btn-export { display: none !important; }

/* ── 表格 ── */
.table-wrap {
  background: var(--white, #fff); border-radius: 0 0 12px 12px;
  border: 1px solid var(--gray-border, #dde1e7); border-top: none;
  overflow-x: auto; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 800px; }
thead { background: var(--gray-bg, #f5f7fa); position: sticky; top: 0; }
th {
  text-align: left; padding: 10px 10px; font-weight: 600;
  color: var(--gray-text, #6b7280); font-size: 11.5px;
  border-bottom: 2px solid var(--gray-border, #dde1e7);
}
td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; }
tr:hover td { background: var(--accent-light, #fafcff); }
.no-data { text-align: center; color: var(--gray-text, #6b7280); padding: 40px; font-size: 14px; }

/* ── 徽章 ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 5px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green { background: #e8f5ee; color: #2d7a4f; }
.badge-blue { background: #eff6ff; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fef2f2; color: #e53935; }
.badge-purple { background: #f5f3ff; color: #7c3aed; }
.badge-teal { background: #f0fdfa; color: #0d9488; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-pink { background: #fdf2f8; color: #be185d; }

/* ── 分页 ── */
.pagination {
  display: flex; justify-content: center; gap: 6px;
  margin-top: 16px; flex-wrap: wrap;
}
.pagination button {
  border: 1px solid var(--gray-border, #dde1e7); background: var(--white, #fff);
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--dark, #1a1d23);
}
.pagination button.active { background: var(--accent, #2d7a4f); color: #fff; border-color: var(--accent, #2d7a4f); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ── 模态框 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1100; display: none; align-items: center; justify-content: center;
}
.modal-overlay.show, .modal-overlay.open { display: flex; }
.modal-content {
  background: var(--white, #fff); border-radius: 14px; padding: 28px 24px;
  max-width: 420px; width: 90%; position: relative;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.modal-close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none; font-size: 18px; cursor: pointer; color: var(--gray-text, #6b7280);
}

/* ── Toast 提示 ── */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: #2d7a4f; color: #fff; padding: 10px 24px;
  border-radius: 20px; font-size: 13px; z-index: 2000;
  opacity: 0; transition: opacity .3s; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; }

/* ── 链接 ── */
.ref-link { color: var(--blue, #1e40af); font-size: 12px; text-decoration: none; }
.ref-link:hover { text-decoration: underline; }

/* ── 认证锁行 ── */
.auth-lock-row {
  background: linear-gradient(90deg,#fef3c7,#fff7ed); text-align: center; cursor: pointer;
  transition: background .2s;
}
.auth-lock-row:hover { background: linear-gradient(90deg,#fde68a,#fed7aa); }
.auth-lock-row td { padding: 16px !important; color: #92400e !important; font-weight: 600 !important; font-size: 14px !important; }

/* 关联植物 chips（详情/列表） */
.plant-chip { display:inline-block; background:var(--green-light,#e8f5ee); color:var(--green,#2d7a4f); padding:3px 10px; border-radius:6px; margin:2px 4px 2px 0; font-size:13px; font-weight:500; cursor:pointer; transition:all .15s; }
.plant-chip:hover { background:var(--green,#2d7a4f); color:#fff; }
/* 表单多选植物 */
.plant-multi { border:1px solid var(--gray-border,#dde1e7); border-radius:8px; padding:8px; max-height:160px; overflow:auto; background:#fff; }
.plant-opt { display:inline-flex; align-items:center; gap:5px; margin:3px 10px 3px 0; font-size:13px; cursor:pointer; }
.plant-opt input { margin:0; }

/* ── 响应式 ── */
@media (max-width: 768px) {
  /* 顶栏精简 */
  header { padding: 0 12px; gap: 8px; height: 52px; }
  header .logo { font-size: 16px; }
  header .subtitle { display: none; }
  header a { font-size: 10px; padding: 3px 6px; }
  main { padding: 14px 10px; }

  /* Tab导航缩小 */
  .tab-btn { padding: 8px 10px; font-size: 12px; }

  /* 统计卡片 2列 */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-card .value { font-size: 20px; }

  /* 工具栏折叠 */
  .toolbar { gap: 8px; }
  .search-box { max-width: none; min-width: 0; flex: 1 1 100%; }

  /* 表格：横向滚动 + 左阴影提示 */
  .table-wrap {
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 600px; font-size: 12px; }
  th, td { padding: 6px 8px; }

  /* 模态框全屏化 */
  .modal-content {
    max-width: 100vw; width: 94vw; padding: 20px 16px;
    border-radius: 16px 16px 0 0;
    position: fixed; bottom: 0; left: 0; right: 0;
    max-height: 85vh; overflow-y: auto;
  }
  .modal-overlay { align-items: flex-end; }

  /* 按钮触控友好 */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }

  /* 分页简化 */
  .pagination button { padding: 6px 8px; font-size: 12px; }

  /* Toast 不挡底部 */
  .toast { bottom: 80px; }
}

/* 小屏手机 (< 400px) */
@media (max-width: 400px) {
  header { height: 48px; padding: 0 8px; gap: 4px; }
  header .logo { font-size: 14px; }
  header a { font-size: 9px; padding: 2px 5px; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  table { font-size: 11px; }
  th, td { padding: 5px 6px; }
}
