<!--日常巡检-->
<template>
  <div class="prototype-container">
    <!-- 头部 -->
    <div class="header">
      <div class="logo">
        <h2>📋 日常巡检管理系统</h2>
        <p>巡检任务管理 | 问题跟踪 | 闭环处理 | 多维度查询</p>
      </div>
      <div class="header-stats">
        <div class="stat-card pending">
          <span class="stat-value">{{ pendingCount }}</span>
          <span class="stat-label">待处理</span>
        </div>
        <div class="stat-card processing">
          <span class="stat-value">{{ processingCount }}</span>
          <span class="stat-label">处理中</span>
        </div>
        <div class="stat-card completed">
          <span class="stat-value">{{ completedCount }}</span>
          <span class="stat-label">已完成</span>
        </div>
      </div>
    </div>

    <div class="main-layout">
      <!-- 左侧：新增巡检表单 -->
      <div class="left-panel">
        <div class="card">
          <div class="card-header">
            ➕ 新增日常巡检
            <span class="card-tip">请填写巡检信息</span>
          </div>
          <div class="card-body">
            <form @submit.prevent="addInspection">
              <div class="form-group">
                <label class="form-label">巡检内容 *</label>
                <textarea v-model="newInspection.content" class="form-textarea" rows="2" placeholder="请输入巡检内容，如：泵房设备检查、仪表读数记录、管道巡查等..."></textarea>
              </div>
              <div class="form-row">
                <div class="form-group half">
                  <label class="form-label">巡检时间 *</label>
                  <input type="datetime-local" v-model="newInspection.inspectTime" class="form-input" required>
                </div>
                <div class="form-group half">
                  <label class="form-label">巡检人员</label>
                  <input v-model="newInspection.inspector" class="form-input" placeholder="巡检人姓名">
                </div>
              </div>
              <div class="form-group">
                <label class="form-label">巡检问题</label>
                <textarea v-model="newInspection.issue" class="form-textarea" rows="2" placeholder="如发现问题请详细描述，无问题可不填..."></textarea>
              </div>
              <div class="form-group">
                <label class="form-label">处理过程</label>
                <textarea v-model="newInspection.process" class="form-textarea" rows="2" placeholder="问题处理过程描述..."></textarea>
              </div>
              <div class="form-row">
                <div class="form-group half">
                  <label class="form-label">是否处理完成</label>
                  <select v-model="newInspection.isCompleted" class="form-select">
                    <option :value="false">未完成</option>
                    <option :value="true">已完成</option>
                  </select>
                </div>
                <div class="form-group half">
                  <label class="form-label">完成时间</label>
                  <input type="datetime-local" v-model="newInspection.completeTime" class="form-input" :disabled="!newInspection.isCompleted">
                </div>
              </div>
              <div class="form-actions">
                <button type="submit" class="btn-primary">✅ 提交巡检记录</button>
                <button type="button" @click="resetForm" class="btn-outline">重置</button>
              </div>
            </form>
          </div>
        </div>

        <!-- 快速统计 -->
        <div class="card">
          <div class="card-header">📊 巡检统计概览</div>
          <div class="card-body">
            <div class="stats-grid">
              <div class="stat-circle">
                <div class="circle-num">{{ completionRate }}%</div>
                <div class="circle-label">完成率</div>
              </div>
              <div class="stat-list">
                <div class="stat-row"><span>本月巡检</span><span>{{ monthlyCount }}</span></div>
                <div class="stat-row"><span>本周巡检</span><span>{{ weeklyCount }}</span></div>
                <div class="stat-row"><span>问题发现率</span><span>{{ issueRate }}%</span></div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 右侧：巡检列表 -->
      <div class="right-panel">
        <div class="card">
          <div class="card-header">
            📋 日常巡检记录列表
            <span class="list-count">共 {{ filteredInspections.length }} 条记录</span>
          </div>
          <div class="card-body">
            <!-- 查询筛选栏 -->
            <div class="filter-bar">
              <div class="filter-group">
                <label class="filter-label">巡检时间范围</label>
                <div class="date-range">
                  <input type="date" v-model="queryParams.startDate" class="filter-input" placeholder="开始日期">
                  <span class="filter-sep">至</span>
                  <input type="date" v-model="queryParams.endDate" class="filter-input" placeholder="结束日期">
                </div>
              </div>
              <div class="filter-group">
                <label class="filter-label">完成状态</label>
                <select v-model="queryParams.status" class="filter-select">
                  <option value="">全部</option>
                  <option value="pending">待处理</option>
                  <option value="processing">处理中</option>
                  <option value="completed">已完成</option>
                </select>
              </div>
              <div class="filter-group">
                <label class="filter-label">关键词</label>
                <input type="text" v-model="queryParams.keyword" class="filter-input" placeholder="巡检内容/问题">
              </div>
              <div class="filter-actions">
                <button @click="searchInspections" class="btn-primary btn-sm">🔍 查询</button>
                <button @click="resetQuery" class="btn-outline btn-sm">重置</button>
              </div>
            </div>

            <!-- 巡检列表表格 -->
            <div class="inspection-table-wrapper">
              <table class="data-table">
                <thead>
                <tr>
                  <th>巡检时间</th>
                  <th>巡检内容</th>
                  <th>巡检人员</th>
                  <th>巡检问题</th>
                  <th>处理过程</th>
                  <th>完成状态</th>
                  <th>完成时间</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="item in paginatedInspections" :key="item.id">
                  <td class="time-cell">{{ formatDateTime(item.inspectTime) }}</td>
                  <td class="content-cell">{{ truncateText(item.content, 40) }}</td>
                  <td>{{ item.inspector || '-' }}</td>
                  <td class="issue-cell">
                    <span v-if="item.issue" class="issue-badge">有</span>
                    <span v-else class="no-issue">无</span>
                    <span class="issue-text">{{ truncateText(item.issue, 30) }}</span>
                  </td>
                  <td class="process-cell">{{ truncateText(item.process, 30) || '-' }}</td>
                  <td>
                      <span class="status-badge" :class="getStatusClass(item)">
                        {{ getStatusText(item) }}
                      </span>
                  </td>
                  <td class="time-cell">{{ formatDateTime(item.completeTime) || '-' }}</td>
                  <td class="action-cell">
                    <button @click="viewDetail(item)" class="btn-view">查看</button>
                    <button v-if="!item.isCompleted" @click="openProcessModal(item)" class="btn-process">处理</button>
                    <button @click="editInspection(item)" class="btn-edit">编辑</button>
                    <button @click="deleteInspection(item)" class="btn-delete">删除</button>
                  </td>
                </tr>
                <tr v-if="filteredInspections.length === 0">
                  <td colspan="8" class="empty-row">暂无巡检记录，请点击新增进行添加</td>
                </tr>
                </tbody>
              </table>
            </div>

            <!-- 分页 -->
            <div class="pagination" v-if="totalPages > 1">
              <button v-for="page in totalPages" :key="page" class="page-btn" :class="{ active: currentPage === page }"
                      @click="currentPage = page">{{ page }}</button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 查看详情模态框 -->
    <div v-if="detailModalVisible" class="modal-overlay" @click.self="closeDetailModal">
      <div class="modal-content">
        <h3>📋 巡检详情</h3>
        <div class="detail-info">
          <div class="info-row"><span class="label">巡检时间：</span>{{ formatDateTime(currentItem?.inspectTime) }}</div>
          <div class="info-row"><span class="label">巡检人员：</span>{{ currentItem?.inspector || '-' }}</div>
          <div class="info-row"><span class="label">巡检内容：</span>{{ currentItem?.content }}</div>
          <div class="info-row"><span class="label">巡检问题：</span>{{ currentItem?.issue || '无' }}</div>
          <div class="info-row"><span class="label">处理过程：</span>{{ currentItem?.process || '-' }}</div>
          <div class="info-row"><span class="label">完成状态：</span>
            <span class="status-badge" :class="getStatusClass(currentItem)">{{ getStatusText(currentItem) }}</span>
          </div>
          <div class="info-row"><span class="label">完成时间：</span>{{ formatDateTime(currentItem?.completeTime) || '-' }}</div>
          <div class="info-row" v-if="currentItem?.remark"><span class="label">备注：</span>{{ currentItem?.remark }}</div>
        </div>
        <div class="form-actions">
          <button @click="closeDetailModal" class="btn-primary">关闭</button>
        </div>
      </div>
    </div>

    <!-- 处理模态框 -->
    <div v-if="processModalVisible" class="modal-overlay" @click.self="closeProcessModal">
      <div class="modal-content" style="width:500px;">
        <h3>🔧 处理巡检问题</h3>
        <div class="process-info-summary">
          <div><span class="label">巡检时间：</span>{{ formatDateTime(currentItem?.inspectTime) }}</div>
          <div><span class="label">巡检内容：</span>{{ currentItem?.content }}</div>
          <div><span class="label">巡检问题：</span>{{ currentItem?.issue }}</div>
        </div>
        <div class="form-group">
          <label class="form-label">处理过程 *</label>
          <textarea v-model="processData.process" class="form-textarea" rows="3" placeholder="请详细描述处理过程..."></textarea>
        </div>
        <div class="form-group">
          <label class="form-label">是否完成</label>
          <select v-model="processData.isCompleted" class="form-select">
            <option :value="true">已完成</option>
            <option :value="false">未完成（继续跟进）</option>
          </select>
        </div>
        <div class="form-group" v-if="processData.isCompleted">
          <label class="form-label">完成时间</label>
          <input type="datetime-local" v-model="processData.completeTime" class="form-input">
        </div>
        <div class="form-actions">
          <button @click="closeProcessModal" class="btn-outline">取消</button>
          <button @click="submitProcess" class="btn-primary">提交处理</button>
        </div>
      </div>
    </div>

    <!-- 编辑模态框 -->
    <div v-if="editModalVisible" class="modal-overlay" @click.self="closeEditModal">
      <div class="modal-content" style="width:550px;">
        <h3>✏️ 编辑巡检记录</h3>
        <form @submit.prevent="saveEdit">
          <div class="form-group">
            <label class="form-label">巡检内容 *</label>
            <textarea v-model="editForm.content" class="form-textarea" rows="2" required></textarea>
          </div>
          <div class="form-row">
            <div class="form-group half">
              <label class="form-label">巡检时间 *</label>
              <input type="datetime-local" v-model="editForm.inspectTime" class="form-input" required>
            </div>
            <div class="form-group half">
              <label class="form-label">巡检人员</label>
              <input v-model="editForm.inspector" class="form-input">
            </div>
          </div>
          <div class="form-group">
            <label class="form-label">巡检问题</label>
            <textarea v-model="editForm.issue" class="form-textarea" rows="2"></textarea>
          </div>
          <div class="form-group">
            <label class="form-label">处理过程</label>
            <textarea v-model="editForm.process" class="form-textarea" rows="2"></textarea>
          </div>
          <div class="form-row">
            <div class="form-group half">
              <label class="form-label">是否处理完成</label>
              <select v-model="editForm.isCompleted" class="form-select">
                <option :value="false">未完成</option>
                <option :value="true">已完成</option>
              </select>
            </div>
            <div class="form-group half">
              <label class="form-label">完成时间</label>
              <input type="datetime-local" v-model="editForm.completeTime" class="form-input" :disabled="!editForm.isCompleted">
            </div>
          </div>
          <div class="form-actions">
            <button type="button" @click="closeEditModal" class="btn-outline">取消</button>
            <button type="submit" class="btn-primary">保存修改</button>
          </div>
        </form>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'

// ==================== 巡检数据 ====================
const inspections = ref([
  {
    id: 1,
    content: "城东泵房日常巡检：检查设备运行状态、仪表读数",
    inspectTime: "2025-05-08T09:00:00",
    inspector: "张建国",
    issue: "2号水泵有异响，需进一步检查",
    process: "已联系维修人员，待拆解检查",
    isCompleted: false,
    completeTime: null,
    remark: ""
  },
  {
    id: 2,
    content: "化工园区燃气管道巡查",
    inspectTime: "2025-05-08T14:30:00",
    inspector: "李卫东",
    issue: "",
    process: "",
    isCompleted: true,
    completeTime: "2025-05-08T16:30:00",
    remark: "管道运行正常"
  },
  {
    id: 3,
    content: "城南枢纽流量计校准检查",
    inspectTime: "2025-05-07T10:15:00",
    inspector: "王敏",
    issue: "流量计显示偏差较大",
    process: "已重新校准，数据恢复正常",
    isCompleted: true,
    completeTime: "2025-05-07T11:45:00",
    remark: ""
  },
  {
    id: 4,
    content: "北环加压站设备巡检",
    inspectTime: "2025-05-07T15:20:00",
    inspector: "陈方",
    issue: "压力表读数异常",
    process: "正在排查原因",
    isCompleted: false,
    completeTime: null,
    remark: ""
  },
  {
    id: 5,
    content: "城西换热站温度传感器检查",
    inspectTime: "2025-05-06T11:00:00",
    inspector: "赵伟",
    issue: "温度传感器数据滞后",
    process: "已更换传感器，恢复正常",
    isCompleted: true,
    completeTime: "2025-05-06T15:30:00",
    remark: ""
  }
])

// 新增表单数据
const newInspection = ref({
  content: '',
  inspectTime: new Date().toISOString().slice(0, 16),
  inspector: '',
  issue: '',
  process: '',
  isCompleted: false,
  completeTime: ''
})

// 查询参数
const queryParams = ref({
  startDate: '',
  endDate: '',
  status: '',
  keyword: ''
})

// 分页
const currentPage = ref(1)
const pageSize = 6

// 模态框状态
const detailModalVisible = ref(false)
const processModalVisible = ref(false)
const editModalVisible = ref(false)
const currentItem = ref(null)

// 处理表单数据
const processData = ref({
  process: '',
  isCompleted: true,
  completeTime: new Date().toISOString().slice(0, 16)
})

// 编辑表单数据
const editForm = ref({
  id: null,
  content: '',
  inspectTime: '',
  inspector: '',
  issue: '',
  process: '',
  isCompleted: false,
  completeTime: ''
})

// ==================== 辅助函数 ====================
const formatDateTime = (dateTimeStr) => {
  if (!dateTimeStr) return ''
  return dateTimeStr.replace('T', ' ')
}

const truncateText = (text, maxLen) => {
  if (!text) return ''
  return text.length > maxLen ? text.substring(0, maxLen) + '...' : text
}

// 计算统计
const pendingCount = computed(() => inspections.value.filter(i => !i.isCompleted && i.issue).length)
const processingCount = computed(() => inspections.value.filter(i => !i.isCompleted && i.process).length)
const completedCount = computed(() => inspections.value.filter(i => i.isCompleted).length)

const monthlyCount = computed(() => {
  const now = new Date()
  const month = now.getMonth()
  const year = now.getFullYear()
  return inspections.value.filter(i => {
    const d = new Date(i.inspectTime)
    return d.getMonth() === month && d.getFullYear() === year
  }).length
})

const weeklyCount = computed(() => {
  const now = new Date()
  const weekStart = new Date(now)
  weekStart.setDate(now.getDate() - now.getDay())
  return inspections.value.filter(i => new Date(i.inspectTime) >= weekStart).length
})

const issueRate = computed(() => {
  const withIssue = inspections.value.filter(i => i.issue).length
  return inspections.value.length === 0 ? 0 : Math.round((withIssue / inspections.value.length) * 100)
})

const completionRate = computed(() => {
  return inspections.value.length === 0 ? 0 : Math.round((completedCount.value / inspections.value.length) * 100)
})

// 获取状态文本
const getStatusText = (item) => {
  if (item.isCompleted) return '已完成'
  if (item.process) return '处理中'
  if (item.issue) return '待处理'
  return '正常'
}

const getStatusClass = (item) => {
  if (item.isCompleted) return 'status-completed'
  if (item.process) return 'status-processing'
  if (item.issue) return 'status-pending'
  return 'status-normal'
}

// 过滤后的巡检列表
const filteredInspections = computed(() => {
  let result = [...inspections.value]

  if (queryParams.value.startDate) {
    result = result.filter(i => i.inspectTime >= queryParams.value.startDate)
  }
  if (queryParams.value.endDate) {
    result = result.filter(i => i.inspectTime <= queryParams.value.endDate + 'T23:59:59')
  }
  if (queryParams.value.status) {
    result = result.filter(i => {
      if (queryParams.value.status === 'pending') return !i.isCompleted && i.issue && !i.process
      if (queryParams.value.status === 'processing') return !i.isCompleted && i.process
      if (queryParams.value.status === 'completed') return i.isCompleted
      return true
    })
  }
  if (queryParams.value.keyword) {
    const kw = queryParams.value.keyword.toLowerCase()
    result = result.filter(i =>
        i.content.toLowerCase().includes(kw) ||
        (i.issue && i.issue.toLowerCase().includes(kw))
    )
  }
  // 按巡检时间倒序
  return result.sort((a, b) => new Date(b.inspectTime) - new Date(a.inspectTime))
})

const paginatedInspections = computed(() => {
  const start = (currentPage.value - 1) * pageSize
  return filteredInspections.value.slice(start, start + pageSize)
})

const totalPages = computed(() => Math.ceil(filteredInspections.value.length / pageSize))

// ==================== 新增巡检 ====================
const addInspection = () => {
  if (!newInspection.value.content) {
    alert('请填写巡检内容')
    return
  }
  if (!newInspection.value.inspectTime) {
    alert('请选择巡检时间')
    return
  }

  const newId = Math.max(...inspections.value.map(i => i.id), 0) + 1
  const newRecord = {
    id: newId,
    content: newInspection.value.content,
    inspectTime: newInspection.value.inspectTime,
    inspector: newInspection.value.inspector || '',
    issue: newInspection.value.issue || '',
    process: newInspection.value.process || '',
    isCompleted: newInspection.value.isCompleted,
    completeTime: newInspection.value.isCompleted ? newInspection.value.completeTime : null,
    remark: ''
  }

  inspections.value.unshift(newRecord)
  alert('巡检记录已添加')
  resetForm()
  currentPage.value = 1
}

const resetForm = () => {
  newInspection.value = {
    content: '',
    inspectTime: new Date().toISOString().slice(0, 16),
    inspector: '',
    issue: '',
    process: '',
    isCompleted: false,
    completeTime: ''
  }
}

// ==================== 查询 ====================
const searchInspections = () => {
  currentPage.value = 1
}

const resetQuery = () => {
  queryParams.value = {
    startDate: '',
    endDate: '',
    status: '',
    keyword: ''
  }
  currentPage.value = 1
}

// ==================== 查看详情 ====================
const viewDetail = (item) => {
  currentItem.value = item
  detailModalVisible.value = true
}

const closeDetailModal = () => {
  detailModalVisible.value = false
  currentItem.value = null
}

// ==================== 处理巡检 ====================
const openProcessModal = (item) => {
  currentItem.value = item
  processData.value = {
    process: item.process || '',
    isCompleted: true,
    completeTime: new Date().toISOString().slice(0, 16)
  }
  processModalVisible.value = true
}

const closeProcessModal = () => {
  processModalVisible.value = false
  currentItem.value = null
}

const submitProcess = () => {
  if (!processData.value.process && processData.value.isCompleted) {
    alert('请填写处理过程')
    return
  }

  if (currentItem.value) {
    currentItem.value.process = processData.value.process
    currentItem.value.isCompleted = processData.value.isCompleted
    if (processData.value.isCompleted) {
      currentItem.value.completeTime = processData.value.completeTime || new Date().toISOString()
    }
    alert('处理记录已更新')
    closeProcessModal()
  }
}

// ==================== 编辑巡检 ====================
const editInspection = (item) => {
  editForm.value = {
    id: item.id,
    content: item.content,
    inspectTime: item.inspectTime,
    inspector: item.inspector || '',
    issue: item.issue || '',
    process: item.process || '',
    isCompleted: item.isCompleted,
    completeTime: item.completeTime || ''
  }
  editModalVisible.value = true
}

const closeEditModal = () => {
  editModalVisible.value = false
}

const saveEdit = () => {
  if (!editForm.value.content || !editForm.value.inspectTime) {
    alert('请填写巡检内容和巡检时间')
    return
  }

  const index = inspections.value.findIndex(i => i.id === editForm.value.id)
  if (index !== -1) {
    inspections.value[index] = {
      ...editForm.value,
      completeTime: editForm.value.isCompleted ? editForm.value.completeTime : null
    }
    alert('巡检记录已更新')
    closeEditModal()
  }
}

// ==================== 删除巡检 ====================
const deleteInspection = (item) => {
  if (confirm(`确定删除巡检记录吗？`)) {
    const index = inspections.value.findIndex(i => i.id === item.id)
    if (index !== -1) {
      inspections.value.splice(index, 1)
      alert('巡检记录已删除')
    }
  }
}
</script>

<style scoped>
* { margin: 0; padding: 0; box-sizing: border-box; }

.prototype-container {
  max-width: 1600px;
  margin: 0 auto;
  background: #f0f4f8;
  border-radius: 28px;
  box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* 头部 */
.header {
  background: #0a2b3c;
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 3px solid #3498db;
}

.logo h2 { color: white; font-weight: 600; font-size: 1.3rem; }
.logo p { color: #bdd8e8; font-size: 0.7rem; }

.header-stats { display: flex; gap: 12px; }
.stat-card { background: rgba(255,255,255,0.15); padding: 6px 14px; border-radius: 40px; text-align: center; color: white; }
.stat-card.pending { background: #f39c12; }
.stat-card.processing { background: #3498db; }
.stat-card.completed { background: #27ae60; }
.stat-value { font-weight: 700; font-size: 1.2rem; margin-right: 6px; }
.stat-label { font-size: 0.65rem; opacity: 0.9; }

/* 布局 */
.main-layout { display: flex; flex-wrap: wrap; }
.left-panel { width: 400px; background: #f9fbfd; padding: 20px; }
.right-panel { flex: 1; background: #ffffff; padding: 20px; min-width: 600px; }

/* 卡片 */
.card { background: white; border-radius: 20px; border: 1px solid #e6edf3; margin-bottom: 20px; overflow: hidden; }
.card-header { background: #f9fafc; padding: 14px 18px; border-bottom: 1px solid #eef2f6; font-weight: 700; font-size: 0.85rem; color: #1d5a78; display: flex; justify-content: space-between; align-items: center; }
.card-body { padding: 16px; }
.card-tip { font-size: 0.65rem; font-weight: normal; color: #6f8ea8; }

/* 表单 */
.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 12px; margin-bottom: 14px; }
.form-group.half { flex: 1; }
.form-label { font-size: 0.7rem; font-weight: 600; margin-bottom: 4px; display: block; color: #2c5a72; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 12px; border-radius: 12px; border: 1px solid #cbdde6; font-size: 0.75rem; }
.form-textarea { resize: vertical; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.btn-primary { background: #3498db; border: none; color: white; padding: 8px 20px; border-radius: 30px; font-size: 0.75rem; cursor: pointer; }
.btn-primary:hover { background: #2980b9; }
.btn-outline { background: white; border: 1px solid #3498db; color: #3498db; padding: 6px 16px; border-radius: 30px; font-size: 0.7rem; cursor: pointer; }
.btn-sm { padding: 4px 12px; font-size: 0.65rem; }

/* 筛选栏 */
.filter-bar { background: #f8fafc; border-radius: 16px; padding: 12px; margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 0.65rem; font-weight: 600; color: #2c5a72; }
.date-range { display: flex; align-items: center; gap: 6px; }
.filter-input { padding: 6px 10px; border-radius: 20px; border: 1px solid #cbdde6; font-size: 0.7rem; }
.filter-select { padding: 6px 10px; border-radius: 20px; border: 1px solid #cbdde6; font-size: 0.7rem; min-width: 100px; }
.filter-sep { font-size: 0.7rem; color: #6f8ea8; }
.filter-actions { display: flex; gap: 8px; }

/* 表格 */
.inspection-table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.7rem; }
.data-table th { background: #f8fafc; padding: 10px 8px; text-align: left; font-weight: 600; color: #2c5a72; border-bottom: 1px solid #e2edf2; }
.data-table td { padding: 10px 8px; border-bottom: 1px solid #f0f4f7; vertical-align: middle; }
.time-cell { white-space: nowrap; font-family: monospace; }
.content-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issue-cell { max-width: 180px; }
.issue-badge { display: inline-block; background: #fef3c7; color: #f39c12; padding: 2px 6px; border-radius: 12px; font-size: 0.6rem; margin-right: 6px; }
.no-issue { display: inline-block; background: #d5f5e3; color: #27ae60; padding: 2px 6px; border-radius: 12px; font-size: 0.6rem; margin-right: 6px; }
.issue-text { color: #5a6e7e; }
.process-cell { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-cell { white-space: nowrap; display: flex; gap: 6px; }
.empty-row { text-align: center; padding: 30px; color: #8aaec2; }
.list-count { font-size: 0.65rem; font-weight: normal; color: #6f8ea8; }

/* 状态标签 */
.status-badge { padding: 2px 10px; border-radius: 20px; font-size: 0.65rem; }
.status-pending { background: #fef3c7; color: #f39c12; }
.status-processing { background: #e3f2fd; color: #3498db; }
.status-completed { background: #d5f5e3; color: #27ae60; }
.status-normal { background: #e8f4fd; color: #3498db; }

/* 操作按钮 */
.btn-view { background: #95a5a6; color: white; border: none; padding: 4px 10px; border-radius: 20px; font-size: 0.65rem; cursor: pointer; }
.btn-process { background: #3498db; color: white; border: none; padding: 4px 10px; border-radius: 20px; font-size: 0.65rem; cursor: pointer; }
.btn-edit { background: #f39c12; color: white; border: none; padding: 4px 10px; border-radius: 20px; font-size: 0.65rem; cursor: pointer; }
.btn-delete { background: #e74c3c; color: white; border: none; padding: 4px 10px; border-radius: 20px; font-size: 0.65rem; cursor: pointer; }

/* 分页 */
.pagination { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.page-btn { background: white; border: 1px solid #cbdde6; padding: 4px 10px; border-radius: 20px; font-size: 0.7rem; cursor: pointer; }
.page-btn.active { background: #3498db; color: white; border-color: #3498db; }

/* 统计区域 */
.stats-grid { display: flex; gap: 20px; align-items: center; }
.stat-circle { text-align: center; }
.circle-num { font-size: 2rem; font-weight: 700; color: #3498db; }
.circle-label { font-size: 0.65rem; color: #6f8ea8; }
.stat-list { flex: 1; }
.stat-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.7rem; border-bottom: 1px solid #eef2f6; }
.stat-row span:first-child { color: #6f8ea8; }
.stat-row span:last-child { font-weight: 600; color: #2c5a72; }

/* 模态框 */
.modal-overlay { 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: white; border-radius: 24px; width: 500px; max-width: 90%; padding: 24px; max-height: 85vh; overflow-y: auto; }
.detail-info { background: #f8fafc; border-radius: 16px; padding: 16px; margin-top: 8px; }
.info-row { margin-bottom: 10px; font-size: 0.75rem; }
.info-row .label { font-weight: 600; width: 90px; display: inline-block; color: #2c5a72; }
.process-info-summary { background: #f8fafc; border-radius: 12px; padding: 12px; margin-bottom: 16px; font-size: 0.7rem; }
.process-info-summary .label { font-weight: 600; }
</style>