<template>
  <div class="dashboard-header">
    <div class="header-top">
        <div class="header-left">
            <img src="/src/assets/images/header-left@1x.png"></img>
            <div class="left-tabs">
                <template v-if="isOverviewOrMonitor">
                    <div 
                      class="tab-item overview-tab" 
                      :class="{active: activeTab === 'overview'}"
                      @click="handleTabClick('overview')"
                    >
                        数据总览
                    </div>
                    <div 
                      class="tab-item monitor-tab" 
                      :class="{active: activeTab === 'monitor'}"
                      @click="handleTabClick('monitor')"
                    >
                        监控视角
                    </div>
                </template>
                <img 
                  v-else
                  src="/src/assets/images/st-home@1x.png"
                  @click="handleTabClick('overview')"
                  class="home-icon"
                ></img>
            </div>
        </div>
        <div class="header-center">
            <div class="center-top">
                <img class="out-bg" src="/src/assets/images/header-center-out.png"></img>
                <img class="in-bg"src="/src/assets/images/header-center-in@1x.png"></img>
                <div class="l-lx">
                    <img src="/src/assets/images/l-lx@1x.png" ></img>
                    <img src="/src/assets/images/l-lx@1x.png" ></img>
                    <img src="/src/assets/images/l-lx@1x.png" ></img>
                </div>
                <div class="r-lx">
                    <img src="/src/assets/images/r-lx@1x.png" ></img>
                    <img src="/src/assets/images/r-lx@1x.png" ></img>
                    <img src="/src/assets/images/r-lx@1x.png" ></img>
                </div>
                <div class="title">视频智能分析系统</div>
            </div>
        </div>
        <div class="header-right">
            <img src="/src/assets/images/header-right@1x.png"></img>
        </div>
    </div>
    <div class="center-tabs">
        <img src="/src/assets/images/header-tab-bg@1x.png"></img>
        <div class="item">
            <a @click="handleTabClick('devices')">设备管理</a>
            <a @click="handleTabClick('algorithms')">算法中心</a>
            <a class="has-alarm" @click="handleTabClick('alarms')">
              告警管理<span class="alarm-badge">99</span>
            </a>
            <a @click="handleTabClick('events')">事件中心</a>
        </div>
    </div>
  </div>
</template>

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

const props = defineProps({
  activeTab: {
    type: String,
    default: 'overview'
  }
})

const emit = defineEmits(['tab-change'])

const isOverviewOrMonitor = computed(() => {
  return props.activeTab === 'overview' || props.activeTab === 'monitor'
})

const handleTabClick = (tab) => {
  emit('tab-change', tab)
}
</script>

<style lang="scss" scoped>
.dashboard-header {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    .header-top{
        width: 95%;
        margin: 0 auto;
        position: relative;
        display: flex;
        flex-direction: row;
        background: #0a1d3c;
        .header-left{
            width: 28%;
            img{
                width: 100%;
                height: auto;
            }
            .left-tabs {
                position: absolute;
                left: 10px;
                bottom: 0;
                display: flex;
                gap: 10px;
                align-items: center;
                
                .tab-item {
                    padding: 0 30px;
                    height: 30px;
                    line-height: 30px;
                    color: rgba(16,16,16,1);
                    font-size: 14px;
                    text-align: center;  
                    color: rgba(255,255,255,1);
                    cursor: pointer;
                    border: 1px solid white;
                    border-radius: 2px;
                    &.overview-tab{
                        background-color: #3a3a42;
                        opacity: 0.8;
                        &:hover {
                        opacity: 1;
                        }
                    }
                    &.overview-tab.active {
                        background-color: rgba(38,140,140,1);
                    }
                    &.monitor-tab {
                        background-color: #3a3a42;
                        opacity: 0.8;
                        &:hover {
                        opacity: 1;
                        }
                    }
                    &.monitor-tab.active {
                        background-color: rgba(38,140,140,1);
                    }
                }
                
                .home-icon {
                    cursor: pointer;
                    transition: all 0.3s;
                    height: 24px;
                    width: auto;
                    
                    &:hover {
                        opacity: 0.8;
                        transform: scale(1.05);
                    }
                }
            }
        }
        .header-center{
            width:48%;
            position: relative;
            display: flex;
            flex-direction: column;
            .center-top{
                .out-bg{
                    position: absolute;
                    width: 104%;
                    height: auto; 
                    left: -2%;
                }
                .in-bg{
                    position: absolute;
                    width: 102%;
                    height: auto; 
                    top:8%;
                    left: -1%;
                }
                .l-lx{
                    position: absolute;
                    bottom: 25%;
                    display: flex;
                    justify-content:flex-end;
                    align-items: right;
                    img{
                        width: 25%;
                        margin-right: 0;
                    }
                }
                .r-lx{
                    position: absolute;
                    bottom: 25%;
                    display: flex;
                    right: -0.5%;
                    justify-content:flex-start;
                    img{
                        width: 25%;
                        margin-left: 0;
                    }
                }
                .title{
                    position: absolute;
                    left: 50%;
                    top: 15px;
                    transform: translateX(-50%);
                    width: 400px;
                    text-align: center;
                    width: 100%;
                    height: 50px;
                    font-size: 24px;
                    font-weight: 500;
                    color: #7cd0ff;
                    text-shadow: 0 0 10px rgba(124, 208, 255, 0.7);
                    letter-spacing: 0.5em;
                }
            }
            
        }
        .header-right{
            width: 28%;
            img{
                width: 100%;
                height: auto;
            }
        } 
    }
    .center-tabs{
        width: 32%;
        position: relative;
        margin-top: -4px;
        img{
            width: 100%;
        }
        .item {
            position: absolute;
            top: 40%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            justify-content: center;
            align-items: center;
            width: 80%;
            
            a {
                position: relative;
                color: white;
                font-size: 14px;
                padding: 8px 10px;
                margin: 0 5px;
                text-align: center;
                cursor: pointer;
                transition: all 0.3s;
                
                &:hover {
                    color: #7cd0ff;
                    text-shadow: 0 0 8px rgba(124, 208, 255, 0.7);
                    }
                
                &.has-alarm {
                    .alarm-badge {
                        position: absolute;
                        top: -8px;
                        right: 2px;
                        background-color: #ff4d4f;
                        color: white;
                        border-radius: 50%;
                        width: 20px;
                        height: 20px;
                        font-size: 12px;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        box-shadow: 0 0 4px rgba(255, 0, 0, 0.5);
                    }
                }
            }
        }
    }
}
</style>