<template>
  <div v-if="props.open" class="alertModal">
    <div class="alertModal-contant">
      <div class="scan-line"></div>
      <div class="grid-overlay"></div>
      <div class="corner-decoration corner-tl"></div>
      <div class="corner-decoration corner-tr"></div>
      <div class="corner-decoration corner-bl"></div>
      <div class="corner-decoration corner-br"></div>
      <div class="status-led"></div>

      <div class="alert-header">
        <div class="alert-icon">
          <WarningOutlined />
        </div>
        <div>
          <h1 class="alert-title">跌倒警报</h1>
          <p class="alert-subtitle">系统检测到跌倒事件，请及时处理！</p>
        </div>
      </div>

      <div class="alert-body">
        <div class="alert-details">
          <div class="detail-row">
            <div class="detail-label">设备名称</div>
            <div class="detail-value">{{ props.data.devName }}</div>
          </div>
          <div class="detail-row">
            <div class="detail-label">小区名称</div>
            <div class="detail-value">{{ props.data.tenantName }}</div>
          </div>
          <div class="detail-row">
            <div class="detail-label">设备ID</div>
            <div class="detail-value">{{ props.data.clientId }}</div>
          </div>
        </div>
      </div>

      <div class="alert-footer">
        <button class="btn btn-acknowledge" @click="close"> 立即处理 </button>
        <button class="btn btn-view-details" @click="close"> 稍后处理 </button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, defineEmits, withDefaults } from 'vue'
import { WarningOutlined } from '@ant-design/icons-vue'

defineOptions({
  name: 'AlertModal',
})

type Props = {
  open: boolean
  data: {
    devName: string
    tenantName: string
    clientId: string
  }
}
const emit = defineEmits<{
  (e: 'update:open', value: boolean): void
}>()

const props = withDefaults(defineProps<Props>(), {
  open: false,
  data: () => ({
    devName: '',
    tenantName: '',
    clientId: '',
  }),
})

const close = () => {
  emit('update:open', false)
}
</script>

<style scoped lang="less">
.alertModal {
  position: fixed;
  top: 0;
  left: 0;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 10000;

  &-contant {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    border-radius: 10px;
    z-index: 10001;
    width: 500px;

    background: rgba(10, 15, 35, 0.9);
    border: 1px solid rgba(0, 195, 255, 0.3);
    box-shadow:
      0 0 20px rgba(0, 195, 255, 0.5),
      0 0 40px rgba(0, 89, 255, 0.3),
      inset 0 0 15px rgba(0, 195, 255, 0.2);
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(10px);
    transition: all 0.4s ease;

    .alert-header {
      background: linear-gradient(90deg, rgba(0, 80, 120, 0.7) 0%, rgba(0, 150, 200, 0.5) 100%);
      padding: 20px;
      position: relative;
      display: flex;
      align-items: center;
      border-bottom: 1px solid rgba(0, 195, 255, 0.3);
    }

    .alert-icon {
      width: 60px;
      height: 60px;
      background: rgba(255, 40, 40, 0.2);
      border-radius: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-right: 20px;
      animation: pulse 2s infinite;
    }

    .alert-icon {
      font-size: 30px;
      color: #ff2a2a;
      animation: shake 0.8s infinite;
    }

    @keyframes pulse {
      0% {
        box-shadow: 0 0 0 0 rgba(255, 40, 40, 0.4);
      }
      70% {
        box-shadow: 0 0 0 15px rgba(255, 40, 40, 0);
      }
      100% {
        box-shadow: 0 0 0 0 rgba(255, 40, 40, 0);
      }
    }

    @keyframes shake {
      0% {
        transform: translateX(0);
      }
      25% {
        transform: translateX(-3px);
      }
      50% {
        transform: translateX(3px);
      }
      75% {
        transform: translateX(-3px);
      }
      100% {
        transform: translateX(0);
      }
    }

    @keyframes rotate {
      0% {
        transform: rotate(0deg);
      }
      100% {
        transform: rotate(360deg);
      }
    }

    .alert-title {
      font-size: 24px;
      font-weight: 700;
      color: #ff4d4d;
      text-shadow: 0 0 10px rgba(255, 77, 77, 0.7);
      letter-spacing: 1px;
    }

    .alert-subtitle {
      font-size: 16px;
      color: #8fbcff;
      margin-top: 5px;
    }

    .alert-body {
      padding: 25px;
    }

    .alert-content {
      margin-bottom: 25px;
      line-height: 1.6;
    }

    .alert-details {
      background: rgba(0, 30, 60, 0.4);
      border-radius: 10px;
      padding: 15px;
      margin: 20px 0;
      border-left: 3px solid #00c3ff;
    }

    .detail-row {
      display: flex;
      padding: 8px 0;
      border-bottom: 1px solid rgba(0, 195, 255, 0.1);
    }

    .detail-row:last-child {
      border-bottom: none;
    }

    .detail-label {
      width: 40%;
      color: #8fbcff;
      font-weight: 500;
    }

    .detail-value {
      width: 60%;
      color: #ffffff;
      font-weight: 600;
    }

    .critical {
      color: #ff4d4d;
      text-shadow: 0 0 5px rgba(255, 77, 77, 0.5);
    }

    .alert-message {
      background: rgba(255, 40, 40, 0.1);
      border: 1px solid rgba(255, 77, 77, 0.3);
      border-radius: 8px;
      padding: 15px;
      margin: 20px 0;
      color: #ff9999;
      line-height: 1.6;
    }

    .alert-footer {
      display: flex;
      justify-content: flex-end;
      padding: 20px;
      background: rgba(0, 20, 40, 0.5);
      border-top: 1px solid rgba(0, 195, 255, 0.2);
    }

    .btn {
      padding: 12px 30px;
      border-radius: 8px;
      font-weight: 600;
      font-size: 16px;
      cursor: pointer;
      transition: all 0.3s ease;
      border: none;
      outline: none;
      letter-spacing: 1px;
      margin-left: 15px;
    }

    .btn-acknowledge {
      background: linear-gradient(90deg, #00c3ff 0%, #0077ff 100%);
      color: white;
      box-shadow: 0 0 15px rgba(0, 195, 255, 0.4);
    }

    .btn-acknowledge:hover {
      background: linear-gradient(90deg, #00d9ff 0%, #0088ff 100%);
      box-shadow: 0 0 20px rgba(0, 195, 255, 0.7);
      // transform: translateY(-2px);
    }

    .btn-view-details {
      background: transparent;
      color: #00c3ff;
      border: 1px solid #00c3ff;
    }

    .btn-view-details:hover {
      background: rgba(0, 195, 255, 0.1);
      box-shadow: 0 0 15px rgba(0, 195, 255, 0.3);
    }

    .grid-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background:
        linear-gradient(rgba(0, 195, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 195, 255, 0.05) 1px, transparent 1px);
      background-size: 20px 20px;
      pointer-events: none;
      z-index: -1;
    }

    .corner-decoration {
      position: absolute;
      width: 15px;
      height: 15px;
    }

    .corner-tl {
      top: 0;
      left: 0;
      border-top: 2px solid #00c3ff;
      border-left: 2px solid #00c3ff;
    }

    .corner-tr {
      top: 0;
      right: 0;
      border-top: 2px solid #00c3ff;
      border-right: 2px solid #00c3ff;
    }

    .corner-bl {
      bottom: 0;
      left: 0;
      border-bottom: 2px solid #00c3ff;
      border-left: 2px solid #00c3ff;
    }

    .corner-br {
      bottom: 0;
      right: 0;
      border-bottom: 2px solid #00c3ff;
      border-right: 2px solid #00c3ff;
    }

    .scan-line {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 3px;
      background: linear-gradient(90deg, transparent, rgba(0, 195, 255, 0.7), transparent);
      animation: scan 4s linear infinite;
    }

    @keyframes scan {
      0% {
        top: 0;
      }
      100% {
        top: 100%;
      }
    }

    .status-led {
      position: absolute;
      top: 25px;
      right: 25px;
      width: 12px;
      height: 12px;
      background-color: #ff2a2a;
      border-radius: 50%;
      box-shadow: 0 0 10px #ff2a2a;
      animation: blink 1s infinite;
    }
  }
}
</style>
