<template>
  <div class="status-item status-button" @click="show">
    <i-lucide-camera class="status-icon" />
    <span class="status-label">摄像头状态:</span>
    <span class="status-value error">{{ cameraStatus }}</span>
  </div>

  <a-modal v-model:open="dialogVisible" :title="modalTitle" :footer="null">
    <a-row :gutter="[0, 12]">
      <template v-for="(item, index) in modalItems" :key="index">
        <a-col :span="8" class="modal-label">{{ item.label }}</a-col>
        <a-col :span="16" class="modal-value">{{ item.value }}</a-col>
      </template>
    </a-row>
  </a-modal>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useDialog } from '@/utils/useDialog';

// useDialog管理弹窗状态
const { visible: dialogVisible, show, hide } = useDialog();

const cameraStatus = ref('异常');
const modalTitle = '摄像头状态';
const modalItems = ref([
  { label: '当前状态', value: cameraStatus.value },
  { label: '摄像头型号', value: '待赋值' },
  { label: 'IP地址', value: '待赋值' },
  { label: '分辨率', value: '待赋值' },
  { label: '错误信息', value: '待赋值' },
  { label: '最后在线', value: '待赋值' }
]);

// 暴露方法
defineExpose({
  show,
  hide
});
</script>

<style scoped lang="scss">
@use "@/assets/styles/variables" as *;

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s ease;
  
  &.status-button {
    cursor: pointer;
    
    &:hover {
      background-color: rgba(255, 255, 255, 0.1);
    }
  }
  
  .status-icon {
    width: 16px;
    height: 16px;
    color: #8395B6;
    
    &.success {
      color: $success-color;
    }
    
    &.error {
      color: $error-color;
    }
    
    &.warning {
      color: $warning-color;
    }
  }
  
  .status-label {
    font-size: 13px;
    color: #8395B6;
    white-space: nowrap;
  }
  
  .status-value {
    font-size: 13px;
    font-weight: 500;
    
    &.success {
      color: $success-color;
    }
    
    &.error {
      color: $error-color;
    }
    
    &.warning {
      color: $warning-color;
    }
  }
}

.modal-label {
  font-size: $text-size;
  font-weight: bold;
}
</style>