/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25em;
  font-size: 1rem;
}

/* 标题样式 */
.header {
  text-align: center;
  margin-bottom: 2.5em;
  padding: 15% 1.25em;
  background: url('../medical_image.jpg') center/cover no-repeat;
  color: white;
  border-radius: 0.625em;
  box-shadow: 0 0.25em 0.375em rgba(0, 0, 0, 0.1);
  position: relative;
  min-height: 15em;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 0.625em;
  z-index: 1;
}

.header h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  margin-bottom: 0.625em;
  font-weight: 600;
  letter-spacing: 0.0625em;
  position: relative;
  z-index: 2;
  text-shadow: 0.0625em 0.0625em 0.125em rgba(0, 0, 0, 0.8);
}

.subtitle {
  font-size: clamp(0.875rem, 2vw, 1.25rem);
  opacity: 0.9;
  font-weight: 300;
  letter-spacing: 0.0625em;
  position: relative;
  z-index: 2;
  text-shadow: 0.0625em 0.0625em 0.125em rgba(0, 0, 0, 0.8);
}

/* 图表区域样式 */
.chart-section {
  background: white;
  border-radius: 0.625em;
  padding: 1.875em;
  margin-bottom: 1.875em;
  box-shadow: 0 0.125em 0.5em rgba(0, 0, 0, 0.1);
}

.chart-section h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  margin-bottom: 0.625em;
  color: #667eea;
  font-weight: 600;
  letter-spacing: 0.0625em;
}

.chart-description {
  color: #666;
  margin-bottom: 1.25em;
  font-size: clamp(0.875rem, 1.5vw, 1rem);
  font-weight: 300;
}

.chart-container {
  width: 100%;
  min-height: 37.5em;
  position: relative;
}

/* 控件样式 */
.controls {
  margin-bottom: 1.25em;
  display: flex;
  align-items: center;
  gap: 0.625em;
  flex-wrap: wrap;
}

.controls label {
  font-weight: 600;
  color: #555;
  font-size: clamp(0.875rem, 1.2vw, 1rem);
}

.metric-selector,
.province-filter {
  padding: 0.5em 0.75em;
  border: 0.125em solid #ddd;
  border-radius: 0.3125em;
  font-size: clamp(0.875rem, 1.2vw, 1rem);
  background: white;
  cursor: pointer;
  transition: border-color 0.3s;
}

.metric-selector:hover,
.metric-selector:focus,
.province-filter:hover,
.province-filter:focus {
  border-color: #667eea;
  outline: none;
}

.province-filter {
  min-width: 12.5em;
}

.hint {
  font-size: clamp(0.75rem, 1vw, 0.875rem);
  color: #999;
  margin-left: 0.625em;
}

/* 加载指示器 */
.loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.spinner {
  width: 3.125em;
  height: 3.125em;
  border: 0.3125em solid #f3f3f3;
  border-top: 0.3125em solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-indicator p {
  margin-top: 1.25em;
  font-size: clamp(0.875rem, 1.5vw, 1rem);
  color: #667eea;
}

/* 错误提示样式 */
.error-container {
  position: fixed;
  top: 1.25em;
  left: 50%;
  transform: translateX(-50%);
  max-width: 37.5em;
  width: 90%;
  z-index: 10000;
}

.error-box {
  padding: 1.25em;
  border-radius: 0.5em;
  box-shadow: 0 0.25em 0.75em rgba(0, 0, 0, 0.15);
  margin-bottom: 0.625em;
}

.error-level-error {
  background: #fee;
  border-left: 0.25em solid #f44;
}

.error-level-warning {
  background: #fffbea;
  border-left: 0.25em solid #f90;
}

.error-box h3 {
  margin-bottom: 0.625em;
  color: #c00;
  font-size: clamp(1rem, 1.5vw, 1.125rem);
}

.error-message {
  margin-bottom: 0.625em;
  font-size: clamp(0.875rem, 1.2vw, 1rem);
}

.error-box details {
  margin: 0.625em 0;
  font-size: clamp(0.75rem, 1vw, 0.875rem);
}

.error-box summary {
  cursor: pointer;
  color: #667eea;
  font-weight: 600;
}

.error-box pre {
  background: #f5f5f5;
  padding: 0.625em;
  border-radius: 0.25em;
  overflow-x: auto;
  font-size: clamp(0.75rem, 1vw, 0.875rem);
}

.error-action {
  margin-top: 0.625em;
  font-weight: 600;
  color: #555;
  font-size: clamp(0.875rem, 1.2vw, 1rem);
}

/* Tooltip样式 */
.tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 0.75em 1em;
  border-radius: 0.375em;
  font-size: clamp(0.75rem, 1.2vw, 0.875rem);
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 0.25em 0.5em rgba(0, 0, 0, 0.2);
  max-width: 18.75em;
}

.tooltip h4 {
  margin-bottom: 0.5em;
  font-size: clamp(0.875rem, 1.3vw, 1rem);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 0.3125em;
}

.tooltip p {
  margin: 0.25em 0;
}

.tooltip strong {
  color: #ffd700;
}

/* 页脚样式 */
.footer {
  text-align: center;
  padding: 1.25em;
  color: #999;
  font-size: clamp(0.75rem, 1.2vw, 0.875rem);
  margin-top: 2.5em;
}

/* SVG样式 */
svg {
  display: block;
}

.state {
  stroke: #fff;
  stroke-width: 1px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.state:hover {
  opacity: 0.8;
  stroke: #333;
  stroke-width: 2px;
}

.bar {
  cursor: pointer;
  transition: opacity 0.2s;
}

.bar:hover {
  opacity: 0.8;
}

.line {
  fill: none;
  stroke-width: 2px;
  transition: stroke-width 0.2s;
}

.line:hover {
  stroke-width: 3px;
}

.axis {
  font-size: clamp(0.75rem, 1.2vw, 0.875rem);
}

.axis path,
.axis line {
  stroke: #ccc;
}

.axis text {
  fill: #666;
}

.legend {
  font-size: clamp(0.75rem, 1.2vw, 0.875rem);
}

.legend-item {
  cursor: pointer;
}

.legend-item:hover text {
  font-weight: bold;
}

/* 响应式布局 */
@media (max-width: 768px) {
  .container {
    width: 95%;
    padding: 0.625em;
  }

  .header {
    padding: 10% 1em;
    min-height: 12em;
  }

  .header h1 {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
  }

  .subtitle {
    font-size: clamp(0.75rem, 2.5vw, 1rem);
  }

  .chart-section {
    padding: 1.25em;
  }

  .chart-section h2 {
    font-size: clamp(1.125rem, 3vw, 1.5rem);
  }

  .chart-container {
    min-height: 18em;
  }

  .controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .metric-selector,
  .province-filter {
    width: 100%;
  }

  .hint {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.625em;
  }

  .header {
    padding: 8% 0.9375em;
  }

  .header h1 {
    font-size: clamp(1rem, 5vw, 1.5rem);
  }

  .chart-section {
    padding: 0.9375em;
  }

  .chart-container {
    min-height: 15em;
  }
}

