<template>
  <div class="safety-events">
    <div class="events-container">
      <!-- 左侧事件列表 -->
      <div class="events-left">
        <div
          v-for="event in leftEvents"
          :key="event.id"
          class="event-item"
          :class="`level-${event.level}`"
        >
          <div class="event-time">{{ event.time }}</div>
          <div class="event-content">
            <div class="event-level">
              <span class="level-icon">⚠</span>
              <span class="level-text">{{ event.levelText }}</span>
            </div>
            <div class="event-description">{{ event.description }}</div>
          </div>
        </div>
      </div>

      <!-- 右侧状态统计 -->
      <div class="events-right">
        <div class="status-item">
          <div class="status-count processed">{{ processedCount }}</div>
          <div class="status-label">已处理</div>
        </div>
        <div class="status-item">
          <div class="status-count pending">{{ pendingCount }}</div>
          <div class="status-label">待处理</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'SafetyEvents',
  data() {
    return {
      safetyEventsData: [
        {
          id: 1,
          time: '2022-11-23 11:37:25',
          level: 1,
          levelText: 'I级',
          description: 'xxxx段发生严重xx，请立即前往处理！',
          status: 'processed'
        },
        {
          id: 2,
          time: '2022-11-23 09:37:25',
          level: 2,
          levelText: 'II级',
          description: 'xxxx发生xxx，请立即前往处理！',
          status: 'pending'
        }
      ]
    }
  },
  computed: {
    leftEvents() {
      return this.safetyEventsData
    },
    processedCount() {
      return this.safetyEventsData.filter(event => event.status === 'processed').length
    },
    pendingCount() {
      return this.safetyEventsData.filter(event => event.status === 'pending').length
    }
  }
}
</script>

<style lang="less" scoped>
.safety-events {
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #1e3a8a;
  border-radius: 8px;
  padding: 16px;
  overflow: hidden; /* 不显示滚动条 */

  .events-container {
    display: flex;
    height: 100%;
    gap: 20px;

    .events-left {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 12px;
      overflow: hidden; /* 不显示滚动条 */

      .event-item {
        background: linear-gradient(126.97deg, rgba(6, 11, 40, 0.74) 28.26%, rgba(10, 14, 35, 0.71) 91.2%);
        border: 1px solid #3675c9;
        border-radius: 6px;
        padding: 12px;
        display: flex;
        flex-direction: column;
        gap: 8px;

        &.level-1 {
          border-left: 4px solid #ef4444;

          .level-icon {
            color: #ef4444;
          }

          .event-description {
            background: linear-gradient(90deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.05) 100%);
          }
        }

        &.level-2 {
          border-left: 4px solid #f59e0b;

          .level-icon {
            color: #f59e0b;
          }

          .event-description {
            background: linear-gradient(90deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.05) 100%);
          }
        }

        .event-time {
          color: #60a5fa;
          font-family: 'DingTalk JinBuTi';
          font-size: 14px;
          font-weight: 400;
          text-align: center;
          margin-bottom: 4px;
        }

        .event-content {
          display: flex;
          flex-direction: column;
          gap: 8px;

          .event-level {
            display: flex;
            align-items: center;
            gap: 6px;
            justify-content: center;

            .level-icon {
              font-size: 16px;
              font-weight: bold;
            }

            .level-text {
              color: #ffffff;
              font-family: 'DingTalk JinBuTi';
              font-size: 14px;
              font-weight: 500;
              background: rgba(255, 255, 255, 0.1);
              padding: 2px 8px;
              border-radius: 4px;
            }
          }

          .event-description {
            color: #e2e8f0;
            font-family: 'DingTalk JinBuTi';
            font-size: 14px;
            font-weight: 400;
            line-height: 1.4;
            padding: 8px 12px;
            border-radius: 4px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            text-align: center;
          }
        }
      }
    }

    .events-right {
      width: 120px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: 30px;

      .status-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;

        .status-count {
          width: 60px;
          height: 60px;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          font-family: 'DingTalk JinBuTi';
          font-size: 24px;
          font-weight: 600;
          color: #ffffff;

          &.processed {
            background: #10b981;
          }

          &.pending {
            background: #f59e0b;
          }
        }

        .status-label {
          color: #60a5fa;
          font-family: 'DingTalk JinBuTi';
          font-size: 14px;
          font-weight: 400;
          text-align: center;
        }
      }
    }
  }
}
</style>
