/* ============================================
   联祥发检测站 - 管理后台样式
   ============================================ */

:root {
  --primary: #07C160;
  --primary-dark: #06AD56;
  --danger: #FA5151;
  --warning: #FFC300;
  --info: #10AEFF;
  --bg: #F5F6FA;
  --sidebar-bg: #1E2A3A;
  --card-bg: #FFFFFF;
  --text: #333333;
  --text-secondary: #666666;
  --text-light: #999999;
  --border: #E5E7EB;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ========== 登录页 ========== */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #07C160 0%, #06AD56 100%);
}

.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { font-size: 48px; margin-bottom: 8px; }
.login-logo h1 { font-size: 24px; color: var(--primary); margin-bottom: 4px; }
.login-logo p { font-size: 14px; color: var(--text-light); }

.login-error {
  background: #FFF0F0;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ========== 表单 ========== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7,193,96,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; gap: 14px; }
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.col-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: #FF9800; color: #fff; }
.btn-warning:hover { background: #F57C00; opacity: 1; }
.btn-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(7,193,96,0.05); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-block { width: 100%; }

/* ========== 布局 ========== */
.main-page { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand .brand-icon { font-size: 28px; }
.sidebar-brand .brand-text { font-size: 16px; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-item.active {
  color: var(--primary);
  background: rgba(7,193,96,0.1);
  border-left-color: var(--primary);
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.sidebar-footer .user-info { color: rgba(255,255,255,0.7); }
.sidebar-footer .btn-outline {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.2);
  padding: 4px 12px;
  font-size: 12px;
}
.sidebar-footer .btn-outline:hover { color: #fff; border-color: #fff; }

/* 主内容区 */
.main-content { margin-left: 220px; flex: 1; display: flex; flex-direction: column; }

.topbar {
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h2 { font-size: 20px; color: var(--text); }

.content-body { padding: 24px 28px; flex: 1; }

/* ========== 统计卡片 ========== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon { font-size: 36px; line-height: 1; }
.stat-info h3 { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.stat-info p { font-size: 13px; color: var(--text-light); }

/* ========== 卡片/面板 ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 16px; color: var(--text); }
.card-body { padding: 20px; }

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table th {
  background: #FAFBFC;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
table tr:hover td { background: #FAFBFC; }

/* 状态标签 */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.tag-done { background: #E8F8EE; color: #07C160; }
.tag-processing { background: #FFF5E6; color: #F0A030; }
.tag-paid { background: #E8F8EE; color: #07C160; }
.tag-unpaid { background: #FFEEEE; color: #FA5151; }
.tag-deleted { background: #F5F5F5; color: #999; }

/* ========== [新增] OCR处理状态标签 ========== */
.tag-ocr-success { background: #E8F8EE; color: #07C160; font-weight: 600; }
.tag-ocr-failed { background: #FFEEEE; color: #FA5151; font-weight: 600; cursor: help; }
.tag-ocr-no-pdf { background: #F5F5F5; color: #999; }
.tag-ocr-pending { background: #F0F0F0; color: #888; }
.tag-ocr-processing { background: #E6F4FF; color: #1890FF; font-weight: 600; }

/* ========== [新增] OCR 统计条 ========== */
.ocr-stat-item {
  text-align: center;
  min-width: 80px;
}
.ocr-stat-num {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}
.ocr-stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ========== [新增] OCR 详情展开行 ========== */
.ocr-detail-row td {
  font-size: 13px;
}

/* ========== 搜索栏 ========== */
.search-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
}
.search-bar .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }
.search-bar .form-group input,
.search-bar .form-group select { padding: 8px 12px; font-size: 13px; }

/* ========== 分页 ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}
.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: all 0.2s;
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 13px; color: var(--text-light); margin: 0 8px; }

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ========== 加载态 ========== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}
.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Toast 提示 ========== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  z-index: 9999;
  animation: slideDown 0.3s ease;
  pointer-events: none;
}
.toast-success { background: #07C160; }
.toast-error { background: #FA5151; }
.toast-warning { background: #F0A030; }

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h3 { font-size: 18px; margin-bottom: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand .brand-text,
  .nav-item span:last-child,
  .sidebar-footer .user-info { display: none; }
  .sidebar-brand { justify-content: center; padding: 16px 10px; }
  .nav-item { justify-content: center; padding: 12px 10px; border-left: none; }
  .sidebar-footer { justify-content: center; padding: 12px 10px; }
  .main-content { margin-left: 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row.col-2, .form-row.col-3, .form-row.col-4 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .search-bar { flex-direction: column; }
}

/* ========== [新增] 导出按钮 ========== */
.btn-export {
  background: #10AEFF;
  color: #fff;
  border: none;
}
.btn-export:hover {
  background: #0D9AE8;
  opacity: 1;
}

/* ========== [新增] OCR Tab 切换 ========== */
.ocr-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: #FAFBFC;
  border-radius: var(--radius) var(--radius) 0 0;
}
.ocr-tab {
  flex: 1;
  padding: 14px 20px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.ocr-tab:hover {
  color: var(--primary);
  background: rgba(7,193,96,0.04);
}
.ocr-tab.active {
  color: var(--primary);
  background: #fff;
}
.ocr-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

/* ========== [新增] 操作类型标签 ========== */
.tag-action {
  background: #EEF2FF;
  color: #4A6CF7;
  font-family: monospace;
  font-size: 11px;
}

/* ========== [新增] 表格详情列截断 ========== */
.td-detail {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ========== [新增] 邮箱配置指南步骤 ========== */
.email-guide .guide-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.guide-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.guide-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 3px;
}
.guide-step strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}
.guide-step p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* ========== [新增] 邮箱测试结果 ========== */
.email-test-success {
  background: #E8F8EE !important;
  color: #07C160 !important;
  border: 1px solid #B7EBC8;
}
.email-test-failed {
  background: #FFEEEE !important;
  color: #FA5151 !important;
  border: 1px solid #FFC8C8;
}
