<template>
  <div class="page-container">
    <!-- 系统标题区域 -->
    <div class="header-section">
      <div class="header-content">
        <h1 class="system-title">韶关市大气重金属污染采样</h1>
        <div class="calculation-selector">
          <span class="selector-title">采样方式：</span>
          <select 
            v-model="calculationMethod" 
            class="calculation-select"
          >
            <option value="weight">按重量采样</option>
            <option value="volume">按体积采样</option>
          </select>
        </div>
      </div>
    </div>
    
    <!-- 地图展示区域 -->
    <div class="dashboard-section ">
      <div class="section-header">
        <div class="section-icon">🗺️</div>
        <h2 class="section-title">采样点地理分布</h2>
      </div>
      <div class="dashboard-card map-card">
        <div class="map-holder">
          <atmsamplemap :calculation-method="calculationMethod" :map-type="mapType"/>
        </div>
      </div>
    </div>
    
    <!-- 数据展示区域 - 上下排列 -->
    <div class="data-section">
      <!-- 数据列表 -->
      <div class="dashboard-section">
        <div class="section-header">
          <div class="section-icon">📋</div>
          <h2 class="section-title">采样点数据详情</h2>
          <div class="data-info">
            <span class="info-item">当前采样方式: {{ calculationMethod === 'weight' ? '按重量' : '按体积' }}</span>
            <span class="info-item">最后更新: 2025-08-16</span>
          </div>
        </div>
        <div class="dashboard-card data-card">
          <div class="table-container">
            <AirsampleLine :calculation-method="calculationMethod"/>
          </div>
        </div>
      </div>
      
      <!-- 图表分析 -->
      <div class="dashboard-section">
        <div class="section-header">
          <div class="section-icon">📊</div>
          <h2 class="section-title">区域污染分析</h2>
        </div>
        <div class="dashboard-card chart-card">
          <div class="chart-header">
            <h3>各区县平均大气重金属污染柱状图</h3>
          </div>
          <div class="chart-container">
            <AirsampleChart :calculation-method="calculationMethod"/>
          </div>
        </div>
      </div>
    </div>
    
  
  </div>
</template>

<script setup>
import { ref } from 'vue'
import AirsampleLine from '@/components/atmpollution/airsampleLine.vue';
import atmsamplemap from '@/components/atmpollution/atmsamplemap.vue';
import AirsampleChart from '@/components/atmpollution/airsampleChart.vue';

const calculationMethod = ref('weight')
const mapType = ref('standard') // standard/satellite

const toggleMapType = () => {
  mapType.value = mapType.value === 'standard' ? 'satellite' : 'standard'
}
</script>

<style scoped>
/* 基础样式重置 */
.page-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f9ff 0%, #e6f7ff 100%);
  padding: 25px;
  gap: 20px;
  position: relative;
  overflow-x: hidden;
}

/* 页眉区域 */
.header-section {
   text-align: center;
  position: relative;
}

.header-content {
 display: flex;
  justify-content: space-between;
  align-items: center;
}

.system-title {
  color: #1a365d;
  font-size: 2.8rem;
  margin-bottom: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.system-subtitle {
  font-size: 1.3rem;
  color: #cbd5e0;
  margin: 0;
}

.calculation-selector {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
}

.selector-icon {
  font-size: 1.8rem;
  color: #4a9ef7;
}

.selector-title {
  font-size: 1.1rem;
  color: black;
  font-weight: 500;
}

.calculation-select {
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: black;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.calculation-select:hover {
  background: rgba(255, 255, 255, 0.25);
}

.calculation-select:focus {
  outline: none;
  border-color: #4a9ef7;
  box-shadow: 0 0 0 2px rgba(74, 158, 247, 0.5);
}

.header-stats {
  display: flex;
  gap: 20px;
}

.stat-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 15px;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-icon {
  font-size: 2.2rem;
  color: #4a9ef7;
}

.stat-info {
  flex: 1;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

.stat-label {
  font-size: 1rem;
  color: #cbd5e0;
  font-weight: 500;
}

/* 地图区域 */
.dashboard-section {
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.section-icon {
  font-size: 2.2rem;
  color: #3a9fd3;
}

.section-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: #1a365d;
  margin: 0;
  position: relative;
  padding-left: 10px;
}

.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 80%;
  background: linear-gradient(to bottom, #4a9ef7, #3acfd5);
  border-radius: 2px;
}

.map-actions {
  margin-left: auto;
  display: flex;
  gap: 15px;
}

.map-action-btn {
  padding: 8px 16px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background: #f0f7ff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.map-action-btn:hover {
  background: #e1f0ff;
  transform: translateY(-2px);
}

/* 卡片设计 */
.dashboard-card {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 20px rgba(0, 60, 120, 0.12);
  transition: all 0.4s ease;
  overflow: hidden;
  position: relative;
}

.dashboard-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(0, 60, 120, 0.18);
}

/* 地图容器 */
.map-card {
  height: 550px;
  position: relative;
}

.map-holder {
  position: relative;
  height: 100%;
  z-index: 100;
}

.map-legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 200;
  display: flex;
  gap: 15px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 10px 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.high-pollution { background-color: #e53e3e; }
.medium-pollution { background-color: #dd6b20; }
.low-pollution { background-color: #38a169; }

/* 数据展示区域 - 上下排列 */
.data-section {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* 数据卡片 - 固定高度滚动条 */
.data-card {
  height: 450px;
  display: flex;
  flex-direction: column;
}

.table-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
}

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.pagination {
  display: flex;
  gap: 10px;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.page-btn:hover {
  background: #edf2f7;
}

.page-btn.active {
  background: #4a9ef7;
  color: white;
  border-color: #4a9ef7;
}

/* 图表卡片 */
.chart-card {
  height: 550px;
  padding: 20px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
}

.chart-container {
  flex: 1;
  min-height: 0; /* 修复flex容器滚动问题 */
}

.data-info {
  display: flex;
  gap: 20px;
  margin-left: 30px;
  font-size: 0.9rem;
  color: #4a5568;
}

.chart-header {
  border-bottom: 1px solid #e2e8f0;
}

.chart-header h3 {
  font-size: 1.4rem;
  color: #1a365d;
  margin: 0 0 5px 0;
  font-weight: 600;
}

.chart-header p {
  font-size: 1rem;
  color: #718096;
  margin: 0;
}

.chart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.data-select {
  padding: 8px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background: white;
  font-size: 0.9rem;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 25px;
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-box {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.cadmium { background-color: #ff6b6b; }
.lead { background-color: #4ecdc4; }
.chromium { background-color: #ffd166; }
.arsenic { background-color: #6a0572; }

/* 页脚区域 */
.footer-section {
  margin-top: 30px;
  padding: 20px 0;
  text-align: center;
  color: #546e7a;
  font-size: 1rem;
  border-top: 1px solid #e2e8f0;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 10px;
  font-size: 0.9rem;
  color: #718096;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .header-stats {
    flex-wrap: wrap;
  }
  
  .stat-card {
    flex: 0 0 calc(50% - 10px);
    margin-bottom: 10px;
  }
}

@media (max-width: 900px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }
  
  .system-title {
    font-size: 2rem;
  }
  
  .section-title {
    font-size: 1.6rem;
  }
}

@media (max-width: 768px) {
  .page-container {
    padding: 15px;
    gap: 20px;
  }
  
  .map-card {
    height: 450px;
  }
  
  .data-card, .chart-card {
    height: 350px;
  }
  
  .section-header {
    flex-wrap: wrap;
  }
  
  .map-actions {
    margin-top: 10px;
    width: 100%;
  }
  
  .data-info {
    margin-left: 0;
    margin-top: 10px;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .system-title {
    font-size: 1.8rem;
  }
  
  .section-title {
    font-size: 1.4rem;
  }
  
  .map-card {
    height: 400px;
  }
  
  .data-card, .chart-card {
    height: 300px;
  }
  
  .footer-links {
    flex-direction: column;
    gap: 5px;
  }
  
  .header-stats {
    gap: 10px;
  }
  
  .stat-card {
    flex: 0 0 100%;
  }
}
</style>