<!--设备预警-->
<template>
  <div class="prototype-container">
    <!-- 头部 -->
    <div class="header">
      <div class="logo">
        <h2>⚠️ 设备预警与处理系统</h2>
        <p>普通预警 | 特殊预警 | 预警确认 | 预警处理 | 物联感知一张图</p>
      </div>
      <div class="header-stats">
        <div class="stat-card">
          <span class="stat-value">{{ unconfirmedCount }}</span>
          <span class="stat-label">待确认</span>
        </div>
        <div class="stat-card warning">
          <span class="stat-value">{{ processingCount }}</span>
          <span class="stat-label">处理中</span>
        </div>
        <div class="stat-card success">
          <span class="stat-value">{{ todayCount }}</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="live-badge">● 实时预警</span>
          </div>
          <div class="card-body">
            <div class="iot-map" id="iotMap">
              <div class="map-container">
                <!-- 模拟管网地图 -->
                <svg class="map-svg" viewBox="0 0 600 400">
                  <!-- 管网线路 -->
                  <path d="M50,200 L150,200 L250,150 L350,150 L450,200 L550,200" stroke="#7f8c8d" stroke-width="3" fill="none" stroke-dasharray="6,3"/>
                  <path d="M150,200 L150,300 L250,350 L350,350 L450,300 L450,200" stroke="#7f8c8d" stroke-width="3" fill="none" stroke-dasharray="6,3"/>
                  <path d="M250,150 L250,80 L350,80 L350,150" stroke="#7f8c8d" stroke-width="3" fill="none" stroke-dasharray="6,3"/>

                  <!-- 设备节点 -->
                  <circle v-for="point in mapPoints" :key="point.id" :cx="point.x" :cy="point.y" r="12"
                          :fill="getMapPointColor(point.status)" stroke="white" stroke-width="2"
                          @click="showDeviceOnMap(point)" style="cursor:pointer;">
                    <title>{{ point.name }}</title>
                  </circle>
                  <text v-for="point in mapPoints" :key="'t'+point.id" :x="point.x-10" :y="point.y-12" fill="white" font-size="8">{{ point.name }}</text>

                  <!-- 特殊预警闪烁点 -->
                  <circle v-for="alert in specialAlertsOnMap" :key="'a'+alert.id" :cx="alert.x" :cy="alert.y" r="18"
                          fill="none" stroke="#e74c3c" stroke-width="2" class="pulse-ring">
                    <animate attributeName="r" values="12;22;12" dur="1.5s" repeatCount="indefinite"/>
                    <animate attributeName="opacity" values="1;0;1" dur="1.5s" repeatCount="indefinite"/>
                  </circle>
                </svg>

                <!-- 图例 -->
                <div class="map-legend">
                  <div><span class="legend-dot normal"></span> 正常设备</div>
                  <div><span class="legend-dot offline"></span> 离线/普通预警</div>
                  <div><span class="legend-dot special"></span> 特殊预警</div>
                  <div><span class="legend-dot processing"></span> 处理中</div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 预警统计图表 -->
        <div class="card">
          <div class="card-header">📊 预警趋势统计</div>
          <div class="card-body">
            <div class="trend-chart">
              <div v-for="(count, idx) in weeklyStats" :key="idx" class="trend-bar">
                <div class="bar" :style="{ height: (count / maxWeeklyCount) * 60 + 'px' }"></div>
                <div class="bar-label">{{ ['一', '二', '三', '四', '五', '六', '日'][idx] }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 右侧：预警列表与管理 -->
      <div class="right-panel">
        <!-- 查询筛选栏 -->
        <div class="card">
          <div class="card-header">
            🔍 预警查询
            <div class="filter-group">
              <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="结束日期">
              <select v-model="queryParams.status" class="filter-select">
                <option value="">全部状态</option>
                <option value="unconfirmed">待确认</option>
                <option value="confirmed">已确认</option>
                <option value="processing">处理中</option>
                <option value="resolved">已清除</option>
                <option value="misreport">误报</option>
              </select>
              <select v-model="queryParams.type" class="filter-select">
                <option value="">全部类型</option>
                <option value="normal">普通预警</option>
                <option value="special">特殊预警</option>
              </select>
              <button @click="searchAlerts" class="btn-primary btn-sm">查询</button>
              <button @click="resetQuery" class="btn-outline btn-sm">重置</button>
            </div>
          </div>
        </div>

        <!-- 预警列表（普通+特殊） -->
        <div class="card">
          <div class="card-header">
            📋 设备预警列表
            <span class="list-count">共 {{ filteredAlerts.length }} 条</span>
          </div>
          <div class="card-body">
            <div class="alert-table">
              <table class="data-table">
                <thead>
                <tr><th>预警时间</th><th>设备名称</th><th>设备位置</th><th>预警类型</th><th>预警内容</th><th>状态</th><th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="alert in paginatedAlerts" :key="alert.id">
                  <td class="time-cell">{{ alert.time }}</td>
                  <td>{{ alert.deviceName }}</td>
                  <td>{{ alert.location }}</td>
                  <td>
                      <span class="alert-type" :class="alert.type === 'normal' ? 'type-normal' : 'type-special'">
                        {{ alert.type === 'normal' ? '普通预警' : '特殊预警' }}
                      </span>
                  </td>
                  <td class="content-cell">{{ alert.content }}</td>
                  <td>
                      <span class="status-badge" :class="getStatusClass(alert.status)">
                        {{ getStatusText(alert.status) }}
                      </span>
                  </td>
                  <td class="action-cell">
                    <button v-if="alert.status === 'unconfirmed'" @click="confirmAlert(alert)" class="btn-confirm">确认</button>
                    <button v-if="alert.status === 'unconfirmed'" @click="markMisreport(alert)" class="btn-misreport">误报</button>
                    <button v-if="alert.status === 'confirmed'" @click="assignHandler(alert)" class="btn-assign">分配处理</button>
                    <button v-if="alert.status === 'processing'" @click="processAlert(alert)" class="btn-process">处理反馈</button>
                    <button v-if="alert.status === 'processing'" @click="viewDetail(alert)" class="btn-view">查看</button>
                    <span v-if="alert.status === 'resolved' || alert.status === 'misreport'" class="completed-badge">✓ 已完成</span>
                  </td>
                </tr>
                <tr v-if="paginatedAlerts.length === 0">
                  <td colspan="7" 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="confirmModalVisible" class="modal-overlay" @click.self="closeConfirmModal">
      <div class="modal-content">
        <h3>⚠️ 预警信息确认</h3>
        <div class="confirm-info">
          <div class="info-row"><span class="label">设备名称：</span>{{ currentAlert?.deviceName }}</div>
          <div class="info-row"><span class="label">预警时间：</span>{{ currentAlert?.time }}</div>
          <div class="info-row"><span class="label">预警内容：</span>{{ currentAlert?.content }}</div>
        </div>
        <div class="form-group">
          <label class="form-label">确认类型</label>
          <select v-model="confirmType" class="form-select">
            <option value="device">设备异常预警（需处理）</option>
            <option value="misreport">误报（网络等因素）</option>
          </select>
        </div>
        <div class="form-group" v-if="confirmType === 'device'">
          <label class="form-label">分配处理人员</label>
          <select v-model="assignedPerson" class="form-select">
            <option value="张工">张工（设备技术组）</option>
            <option value="李工">李工（运维组）</option>
            <option value="王工">王工（抢修组）</option>
          </select>
        </div>
        <div class="form-actions">
          <button @click="closeConfirmModal" class="btn-outline">取消</button>
          <button @click="submitConfirm" 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">
          <div class="info-row"><span class="label">设备：</span>{{ currentAlert?.deviceName }}</div>
          <div class="info-row"><span class="label">预警内容：</span>{{ currentAlert?.content }}</div>
        </div>
        <div class="form-group">
          <label class="form-label">处理结果</label>
          <textarea v-model="processResult" class="form-textarea" rows="3" placeholder="请描述处理过程及结果..."></textarea>
        </div>
        <div class="form-group">
          <label class="form-label">附件上传</label>
          <div class="upload-area">
            <label class="upload-btn">
              📎 选择文件
              <input type="file" @change="handleFileUpload" accept="image/*,.pdf" hidden multiple>
            </label>
            <div class="file-list">
              <span v-for="(file, idx) in uploadedFiles" :key="idx" class="file-tag">
                {{ file.name }}
                <button @click="removeFile(idx)" class="remove-file">✖</button>
              </span>
            </div>
          </div>
        </div>
        <div class="form-actions">
          <button @click="closeProcessModal" class="btn-outline">取消</button>
          <button @click="submitProcess" class="btn-success">提交处理</button>
        </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>{{ currentAlert?.deviceName }}</div>
          <div class="info-row"><span class="label">预警时间：</span>{{ currentAlert?.time }}</div>
          <div class="info-row"><span class="label">确认时间：</span>{{ currentAlert?.confirmTime || '-' }}</div>
          <div class="info-row"><span class="label">处理人员：</span>{{ currentAlert?.handler || '-' }}</div>
          <div class="info-row"><span class="label">处理结果：</span>{{ currentAlert?.processResult || '-' }}</div>
          <div class="info-row" v-if="currentAlert?.attachments?.length">
            <span class="label">附件：</span>
            <div class="attachment-list">
              <span v-for="(att, idx) in currentAlert.attachments" :key="idx" class="attachment">{{ att.name }}</span>
            </div>
          </div>
        </div>
        <button @click="closeDetailModal" class="btn-primary" style="margin-top:16px;">关闭</button>
      </div>
    </div>
  </div>
</template>

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

// ==================== 预警数据模拟 ====================
const alerts = ref([
  { id: 1, deviceName: "压力传感器-PS001", location: "城东泵站", type: "normal", content: "设备离线，超过30分钟未回传数据", time: "2025-05-08 14:23:15", status: "unconfirmed", confirmTime: null, handler: null, processResult: null, attachments: [] },
  { id: 2, deviceName: "流量监测仪-FL002", location: "城南枢纽", type: "normal", content: "设备在线异常，数据波动较大", time: "2025-05-08 13:45:22", status: "unconfirmed", confirmTime: null, handler: null, processResult: null, attachments: [] },
  { id: 3, deviceName: "泄漏检测仪-LD005", location: "化工园区", type: "special", content: "可燃气浓度超阈值报警，当前值35%LEL", time: "2025-05-08 13:30:12", status: "processing", confirmTime: "2025-05-08 13:35:00", handler: "张工", processResult: null, attachments: [] },
  { id: 4, deviceName: "温度传感器-TP003", location: "城西换热站", type: "normal", content: "设备离线", time: "2025-05-08 12:15:08", status: "confirmed", confirmTime: "2025-05-08 12:20:00", handler: null, processResult: null, attachments: [] },
  { id: 5, deviceName: "水位监测仪-WL006", location: "东区排水口", type: "special", content: "水位超警戒线，当前水位3.2m", time: "2025-05-08 11:50:33", status: "resolved", confirmTime: "2025-05-08 11:55:00", handler: "李工", processResult: "已启动排水泵，水位降至正常", attachments: [{ name: "处理现场.jpg", url: "" }] },
  { id: 6, deviceName: "压力传感器-PS008", location: "北环加压站", type: "normal", content: "设备离线（网络波动）", time: "2025-05-08 10:30:45", status: "misreport", confirmTime: "2025-05-08 10:35:00", handler: null, processResult: "网络恢复后设备正常，确认误报", attachments: [] },
  { id: 7, deviceName: "燃气探测器-GD004", location: "城南调压站", type: "special", content: "燃气浓度异常波动", time: "2025-05-08 09:20:18", status: "confirmed", confirmTime: "2025-05-08 09:25:00", handler: null, processResult: null, attachments: [] }
])

// 地图点位数据（模拟）
const mapPoints = ref([
  { id: 1, name: "PS001", x: 150, y: 200, status: "offline" },
  { id: 2, name: "FL002", x: 250, y: 150, status: "normal" },
  { id: 3, name: "LD005", x: 350, y: 150, status: "special" },
  { id: 4, name: "TP003", x: 450, y: 200, status: "normal" },
  { id: 5, name: "WL006", x: 350, y: 300, status: "processing" },
  { id: 6, name: "PS008", x: 250, y: 300, status: "normal" },
  { id: 7, name: "GD004", x: 150, y: 300, status: "special" }
])

// 特殊预警地图标记
const specialAlertsOnMap = computed(() => {
  const specialAlerts = alerts.value.filter(a => a.type === 'special' && (a.status === 'unconfirmed' || a.status === 'confirmed' || a.status === 'processing'))
  return specialAlerts.map((alert, idx) => {
    const point = mapPoints.value.find(p => alert.deviceName.includes(p.name))
    return { id: alert.id, x: point?.x || 200 + idx * 50, y: point?.y || 250, name: alert.deviceName }
  })
})

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

const currentPage = ref(1)
const pageSize = 8

// 过滤后的预警列表
const filteredAlerts = computed(() => {
  let result = [...alerts.value]

  if (queryParams.value.startDate) {
    result = result.filter(a => a.time >= queryParams.value.startDate)
  }
  if (queryParams.value.endDate) {
    result = result.filter(a => a.time <= queryParams.value.endDate + ' 23:59:59')
  }
  if (queryParams.value.status) {
    result = result.filter(a => a.status === queryParams.value.status)
  }
  if (queryParams.value.type) {
    result = result.filter(a => a.type === queryParams.value.type)
  }

  // 时间倒序
  return result.sort((a, b) => new Date(b.time) - new Date(a.time))
})

// 分页数据
const paginatedAlerts = computed(() => {
  const start = (currentPage.value - 1) * pageSize
  return filteredAlerts.value.slice(start, start + pageSize)
})

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

// 统计数据
const unconfirmedCount = computed(() => alerts.value.filter(a => a.status === 'unconfirmed').length)
const processingCount = computed(() => alerts.value.filter(a => a.status === 'processing').length)
const todayCount = computed(() => {
  const today = new Date().toISOString().slice(0, 10)
  return alerts.value.filter(a => a.time.startsWith(today)).length
})

// 周统计
const weeklyStats = computed(() => {
  const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  return days.map(() => Math.floor(Math.random() * 8) + 2)
})
const maxWeeklyCount = computed(() => Math.max(...weeklyStats.value, 10))

// ==================== 辅助函数 ====================
const getStatusText = (status) => {
  const map = {
    unconfirmed: '待确认',
    confirmed: '已确认',
    processing: '处理中',
    resolved: '已清除',
    misreport: '误报'
  }
  return map[status] || status
}

const getStatusClass = (status) => {
  const map = {
    unconfirmed: 'status-unconfirmed',
    confirmed: 'status-confirmed',
    processing: 'status-processing',
    resolved: 'status-resolved',
    misreport: 'status-misreport'
  }
  return map[status] || ''
}

const getMapPointColor = (status) => {
  const map = {
    normal: '#27ae60',
    offline: '#e74c3c',
    special: '#e74c3c',
    processing: '#f39c12'
  }
  return map[status] || '#95a5a6'
}

const showDeviceOnMap = (point) => {
  const alert = alerts.value.find(a => a.deviceName.includes(point.name))
  if (alert) {
    alert(`设备: ${point.name}\n状态: ${alert.status}\n预警内容: ${alert.content}`)
  }
}

// 查询相关
const searchAlerts = () => {
  currentPage.value = 1
}

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

// ==================== 预警确认 ====================
const confirmModalVisible = ref(false)
const currentAlert = ref(null)
const confirmType = ref('device')
const assignedPerson = ref('张工')

const confirmAlert = (alert) => {
  currentAlert.value = alert
  confirmModalVisible.value = true
}

const markMisreport = (alert) => {
  if (confirm('确认标记为误报吗？')) {
    alert.status = 'misreport'
    alert.confirmTime = new Date().toLocaleString()
    alert.processResult = '网络/环境因素导致误报'
    addSystemLog(alert, '误报确认')
  }
}

const closeConfirmModal = () => {
  confirmModalVisible.value = false
  currentAlert.value = null
}

const submitConfirm = () => {
  if (currentAlert.value) {
    if (confirmType.value === 'misreport') {
      currentAlert.value.status = 'misreport'
      currentAlert.value.processResult = '确认误报'
    } else {
      currentAlert.value.status = 'confirmed'
      currentAlert.value.handler = assignedPerson.value
    }
    currentAlert.value.confirmTime = new Date().toLocaleString()
    addSystemLog(currentAlert.value, confirmType.value === 'device' ? '确认设备异常' : '误报确认')
    closeConfirmModal()
  }
}

// ==================== 分配处理 ====================
const assignHandler = (alert) => {
  const handler = prompt('请指定处理人员（设备技术员）', '张工')
  if (handler) {
    alert.status = 'processing'
    alert.handler = handler
    addSystemLog(alert, `分配处理人员: ${handler}`)
  }
}

// ==================== 预警处理 ====================
const processModalVisible = ref(false)
const processResult = ref('')
const uploadedFiles = ref([])

const processAlert = (alert) => {
  currentAlert.value = alert
  processResult.value = alert.processResult || ''
  uploadedFiles.value = alert.attachments || []
  processModalVisible.value = true
}

const handleFileUpload = (event) => {
  const files = Array.from(event.target.files)
  files.forEach(file => {
    uploadedFiles.value.push({ name: file.name, size: file.size, url: URL.createObjectURL(file) })
  })
}

const removeFile = (idx) => {
  uploadedFiles.value.splice(idx, 1)
}

const closeProcessModal = () => {
  processModalVisible.value = false
  currentAlert.value = null
  processResult.value = ''
  uploadedFiles.value = []
}

const submitProcess = () => {
  if (currentAlert.value) {
    currentAlert.value.status = 'resolved'
    currentAlert.value.processResult = processResult.value
    currentAlert.value.attachments = [...uploadedFiles.value]
    addSystemLog(currentAlert.value, '处理完成，预警已清除')
    closeProcessModal()
  }
}

// ==================== 查看详情 ====================
const detailModalVisible = ref(false)

const viewDetail = (alert) => {
  currentAlert.value = alert
  detailModalVisible.value = true
}

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

// 模拟系统日志
const addSystemLog = (alert, action) => {
  console.log(`[日志] ${new Date().toLocaleString()} - ${alert.deviceName}: ${action}`)
  // 实际可扩展为独立日志组件
}

// 地图点击处理
</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 #e74c3c;
}

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

.header-stats { display: flex; gap: 16px; }
.stat-card { background: rgba(255,255,255,0.15); padding: 6px 16px; border-radius: 40px; text-align: center; color: white; }
.stat-card.warning { background: #e74c3c; }
.stat-card.success { background: #27ae60; }
.stat-value { font-weight: 700; font-size: 1.2rem; margin-right: 6px; }
.stat-label { font-size: 0.7rem; opacity: 0.9; }

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

/* 卡片 */
.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; }

/* 物联感知地图 */
.iot-map { background: #1a3a4a; border-radius: 16px; padding: 12px; }
.map-container { position: relative; }
.map-svg { width: 100%; height: 280px; background: linear-gradient(135deg, #1a3a4a 0%, #0e2a32 100%); border-radius: 12px; cursor: pointer; }
.map-legend { display: flex; gap: 16px; margin-top: 12px; padding: 8px 12px; background: rgba(0,0,0,0.6); border-radius: 20px; color: white; font-size: 0.65rem; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.legend-dot.normal { background: #27ae60; }
.legend-dot.offline { background: #e74c3c; }
.legend-dot.special { background: #e74c3c; box-shadow: 0 0 8px #e74c3c; }
.legend-dot.processing { background: #f39c12; }
.pulse-ring { animation: pulse-ring 1.5s infinite; }

/* 趋势图 */
.trend-chart { display: flex; justify-content: space-around; align-items: flex-end; height: 100px; gap: 8px; }
.trend-bar { display: flex; flex-direction: column; align-items: center; flex: 1; }
.bar { background: #3498db; width: 100%; border-radius: 4px 4px 0 0; transition: height 0.3s; }
.bar-label { font-size: 0.6rem; margin-top: 4px; color: #6f8ea8; }

/* 筛选栏 */
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-input, .filter-select { padding: 6px 10px; border-radius: 20px; border: 1px solid #cbdde6; font-size: 0.7rem; }
.filter-sep { font-size: 0.7rem; color: #6f8ea8; }
.btn-primary, .btn-outline, .btn-sm { padding: 5px 12px; border-radius: 30px; font-size: 0.7rem; cursor: pointer; }
.btn-primary { background: #3498db; border: none; color: white; }
.btn-outline { background: white; border: 1px solid #3498db; color: #3498db; }
.btn-confirm { background: #27ae60; color: white; border: none; padding: 4px 10px; border-radius: 20px; font-size: 0.65rem; cursor: pointer; }
.btn-misreport { background: #95a5a6; color: white; border: none; padding: 4px 10px; border-radius: 20px; font-size: 0.65rem; cursor: pointer; }
.btn-assign { background: #f39c12; 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-view { background: #1abc9c; color: white; border: none; padding: 4px 10px; border-radius: 20px; font-size: 0.65rem; cursor: pointer; }
.btn-success { background: #27ae60; color: white; border: none; padding: 8px 16px; border-radius: 30px; cursor: pointer; }

/* 表格 */
.alert-table { 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; }
.action-cell { white-space: nowrap; display: flex; gap: 6px; flex-wrap: wrap; }
.empty-row { text-align: center; padding: 30px; color: #8aaec2; }
.list-count { font-size: 0.65rem; font-weight: normal; color: #6f8ea8; }

/* 状态标签 */
.alert-type { padding: 2px 8px; border-radius: 20px; font-size: 0.65rem; }
.type-normal { background: #e8f4fd; color: #3498db; }
.type-special { background: #fef3c7; color: #f39c12; }
.status-badge { padding: 2px 8px; border-radius: 20px; font-size: 0.65rem; }
.status-unconfirmed { background: #fef3c7; color: #f39c12; }
.status-confirmed { background: #e3f2fd; color: #3498db; }
.status-processing { background: #fce4ec; color: #e74c3c; }
.status-resolved { background: #d5f5e3; color: #27ae60; }
.status-misreport { background: #f5f5f5; color: #95a5a6; }
.completed-badge { color: #27ae60; font-size: 0.65rem; }

/* 分页 */
.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; }

/* 模态框 */
.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: 450px; max-width: 90%; padding: 24px; }
.form-group { margin-bottom: 16px; }
.form-label { font-size: 0.7rem; font-weight: 600; margin-bottom: 6px; display: block; color: #2c5a72; }
.form-select, .form-textarea { width: 100%; padding: 8px 12px; border-radius: 12px; border: 1px solid #cbdde6; font-size: 0.75rem; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.confirm-info, .process-info, .detail-info { background: #f8fafc; border-radius: 16px; padding: 12px; margin-bottom: 16px; }
.info-row { font-size: 0.75rem; margin-bottom: 8px; }
.info-row .label { font-weight: 600; width: 90px; display: inline-block; color: #2c5a72; }

/* 上传区域 */
.upload-area { border: 1px dashed #cbdde6; border-radius: 12px; padding: 12px; }
.upload-btn { background: #3498db; color: white; padding: 6px 14px; border-radius: 30px; font-size: 0.7rem; cursor: pointer; display: inline-block; }
.file-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-tag { background: #eef2fa; padding: 4px 8px; border-radius: 20px; font-size: 0.65rem; display: inline-flex; align-items: center; gap: 6px; }
.remove-file { background: none; border: none; color: #e74c3c; cursor: pointer; }

.live-badge { font-size: 0.65rem; background: #e74c3c; color: white; padding: 2px 10px; border-radius: 20px; animation: blink 1s infinite; }

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
@keyframes pulse-ring { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
</style>