<template>
  <div class="header-container">
    <div class="header-left">
      <div class="back-button" @click="$emit('openRegionSelector')">
        {{ selectedRegion || '总部' }}
        <span>···</span>
      </div>
    </div>
    <h1 class="header-title">总部安全管理大屏</h1>
    <div class="header-right">
      {{ currentTime }}
    </div>
  </div>
</template>

<script setup lang="ts">
interface Props {
  currentTime: string
  selectedRegion?: string
}

interface Emits {
  (e: 'openRegionSelector'): void
}

defineProps<Props>()
defineEmits<Emits>()
</script>

<style scoped lang="scss">


/* 响应式设计 */
@media (width <= 1024px) {
  .header-container {
    .header-title {
      font-size: 1.1rem;
    }

    .header-left .back-button {
      min-width: 8vw;
      font-size: 0.8rem;
    }

    .header-right {
      font-size: 0.8rem;
    }
  }
}

@media (width <= 768px) {
  .header-container {
    height: 70px;

    .header-left {
      line-height: 70px;

      .back-button {
        min-width: 12vw;
        padding: 3px 12px;
        font-size: 0.7rem;
      }
    }

    .header-title {
      font-size: 1rem;
      line-height: 35px;
    }

    .header-right {
      margin-right: 15px;
      font-size: 0.7rem;
      line-height: 70px;
    }
  }
}

@media (width <= 480px) {
  .header-container {
    height: 60px;

    .header-left {
      line-height: 60px;

      .back-button {
        min-width: 15vw;
        padding: 2px 10px;
        font-size: 0.65rem;
      }
    }

    .header-title {
      font-size: 0.9rem;
      line-height: 30px;
    }

    .header-right {
      margin-right: 10px;
      font-size: 0.65rem;
      line-height: 60px;
    }
  }
}

.header-container {
  display: flex;
  height: 80px;
  background: url('@/assets/images/top_bg.png') no-repeat;
  background-size: 100%;

  .header-left {
    display: flex;
    padding-left: 1vw;
    line-height: 80px;
    flex: 1;
    align-items: center;

    .back-button {
      display: inline-flex;
      height: 2vh;
      min-width: 6vw;
      padding: 4px 16px;
      margin-left: 0.5vw;
      font-size: 0.9rem;
      cursor: pointer;
      background: rgb(13 24 84 / 80%);
      border: 1px solid rgb(59 130 246 / 40%);
      transition: all 0.3s ease;
      align-items: center;
      justify-content: space-between;
    }

    .back-button:hover {
      background: rgb(59 130 246 / 30%);
      border-color: rgb(59 130 246 / 60%);
    }
  }

  .header-right {
    margin-right: 20px;
    font-size: 0.9rem;
    line-height: 80px;
    text-align: right;
    flex: 1;
  }

  .header-title {
    font-size: 1.3rem;
    font-weight: bold;
    line-height: 40px;
    color: #fff;
    text-align: center;
    flex: 1;
  }
}
</style>
