<script setup lang="ts">
import type { MetaResponse } from '../../types/api'
import { formatMarketState } from '../../utils/formatters'

defineProps<{
  meta: MetaResponse
}>()
</script>

<template>
  <header class="app-header">
    <div class="app-header__identity">
      <p class="app-header__eyebrow">Southbound Flow Console</p>
      <h1 class="app-header__title">{{ meta.product_name }}</h1>
      <p class="app-header__note">{{ meta.note }}</p>
    </div>

    <div class="app-header__meta">
      <div class="app-header__badge">
        <span class="app-header__badge-label">市场状态</span>
        <strong>{{ formatMarketState(meta.market_state) }}</strong>
      </div>
      <div class="app-header__badge">
        <span class="app-header__badge-label">交易日</span>
        <strong>{{ meta.current_trade_date }}</strong>
      </div>
      <div class="app-header__badge">
        <span class="app-header__badge-label">主数据源</span>
        <strong>{{ meta.source_name }}</strong>
      </div>
    </div>
  </header>
</template>

<style scoped>
.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(135deg, rgba(225, 197, 117, 0.14), rgba(13, 23, 41, 0.1)),
    rgba(8, 14, 26, 0.86);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
}

.app-header__eyebrow {
  margin: 0 0 0.25rem;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.74rem;
}

.app-header__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.2vw, 2.3rem);
  font-weight: 700;
  line-height: 1;
}

.app-header__note {
  margin: 0.45rem 0 0;
  max-width: 44rem;
  color: var(--color-text-muted);
  line-height: 1.55;
}

.app-header__meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(9rem, 1fr));
  gap: 1rem;
}

.app-header__badge {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 4.8rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid rgba(225, 197, 117, 0.18);
  background: rgba(8, 16, 30, 0.84);
}

.app-header__badge-label {
  color: var(--color-text-subtle);
  font-size: 0.78rem;
}

@media (max-width: 960px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .app-header__meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header__meta {
    grid-template-columns: 1fr;
  }
}
</style>
