/* 基础样式 */
:root {
  --primary: #2E7D32;
  --primary-dark: #1B5E20;
  --primary-light: #4CAF50;
  --secondary: #FF6F00;
  --background: #f5f7fa;
  --surface: #ffffff;
  --text-primary: #212121;
  --text-secondary: #757575;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 头部 */
.header {
  background: var(--surface);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 32px;
}

.logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.logo-sub {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 8px;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  padding: 8px 16px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
  background: rgba(46, 125, 50, 0.1);
}

/* 位置选择区 */
.location-section {
  padding: 30px 0;
}

.location-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.location-card h2 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.location-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.select-group label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.select-group select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  min-width: 150px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s;
}

.select-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.select-group select:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: #f5f5f5;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e8e8e8;
}

.btn-small {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-icon {
  font-size: 16px;
}

.location-info {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

/* 区域 */
.section {
  padding: 40px 0;
}

.section-alt {
  background: white;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 600;
}

.section-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.filter-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* 观察记录网格 */
.observations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.observation-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.observation-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.observation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.bird-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.bird-name-en {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}

.bird-count {
  background: var(--primary-light);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.observation-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-icon {
  font-size: 14px;
}

.observation-date {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.notable-badge {
  display: inline-block;
  background: var(--secondary);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-left: 8px;
}

/* 热点地区 */
.hotspots-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 16px;
}

.hotspot-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hotspot-info h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.hotspot-location {
  font-size: 13px;
  color: var(--text-secondary);
}

.hotspot-stats {
  text-align: right;
}

.hotspot-num {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.hotspot-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 物种网格 */
.species-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 30px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.species-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
}

.species-item:hover {
  background: var(--primary);
  color: white;
}

.species-item:hover .species-name-en {
  color: rgba(255,255,255,0.8);
}

.species-name {
  font-weight: 500;
  font-size: 14px;
}

.species-name-en {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 2px;
}

/* 搜索面板 */
.search-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.search-form {
  margin-bottom: 24px;
}

.search-input-group {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input-group input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
}

.search-input-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-filters {
  display: flex;
  gap: 20px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.search-results {
  min-height: 200px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 15px;
}

/* 加载状态 */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.9);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-small {
  max-width: 450px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-secondary);
  z-index: 10;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-header {
  padding: 24px 24px 0;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 0 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* 鸟类详情 */
.bird-detail {
  padding: 24px;
}

.bird-detail-header {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.bird-image {
  width: 200px;
  height: 200px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  flex-shrink: 0;
}

.bird-detail-info h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.bird-detail-info .scientific-name {
  font-size: 16px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 16px;
}

.bird-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.bird-tag {
  padding: 4px 12px;
  background: rgba(46, 125, 50, 0.1);
  color: var(--primary);
  border-radius: 20px;
  font-size: 13px;
}

.bird-description {
  color: var(--text-secondary);
  line-height: 1.8;
}

.bird-detail-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.bird-detail-section h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

/* API Key Banner */
.apikey-banner {
  display: none;
  background: #FFF3E0;
  padding: 12px 0;
  font-size: 14px;
}

.apikey-banner.active {
  display: block;
}

.apikey-banner .container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.apikey-info {
  margin-bottom: 16px;
  font-size: 14px;
}

.apikey-info a {
  color: var(--primary);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.apikey-note {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 错误提示 */
.error-message {
  background: #FFEBEE;
  color: #C62828;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin: 20px 0;
}

/* 页脚 */
.footer {
  background: var(--surface);
  padding: 30px 0;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer p {
  font-size: 14px;
  color: var(--text-secondary);
}

.footer a {
  color: var(--primary);
}

.footer-note {
  margin-top: 8px;
  font-size: 12px;
}

/* 响应式 */
@media (max-width: 768px) {
  .header .container {
    flex-direction: column;
    height: auto;
    padding: 16px 20px;
    gap: 12px;
  }

  .nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .location-controls {
    flex-direction: column;
  }

  .select-group {
    width: 100%;
  }

  .select-group select {
    width: 100%;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

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

  .filter-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .observations-grid,
  .hotspots-list {
    grid-template-columns: 1fr;
  }

  .species-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bird-detail-header {
    flex-direction: column;
    text-align: center;
  }

  .bird-image {
    margin: 0 auto;
  }
}
