/* StudData — 全局样式 */
/* 现代简洁白底、卡片布局、圆角 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.6;
}

/* 导航栏 */
#main-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e5e7;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 20px;
  font-weight: 700;
  color: #1d1d1f;
}

.nav-search {
  flex: 1;
  max-width: 400px;
}

.nav-search input {
  width: 100%;
  padding: 8px 16px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.nav-search input:focus {
  border-color: #0071e3;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6e6e73;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.nav-btn:hover {
  background: #f0f0f2;
}

.nav-btn.active {
  background: #0071e3;
  color: #fff;
}

/* 主内容 */
#app {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px;
}

.view {
  animation: fadeIn 0.2s ease;
}

.view.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 卡片 */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 标题 */
h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* 标签 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-turf { background: #d4edda; color: #155724; }
.tag-dirt { background: #fff3cd; color: #856404; }
.tag-sprint { background: #e2e3f1; color: #383d6e; }
.tag-mile { background: #d6eaf8; color: #1b4f72; }
.tag-intermediate { background: #d5f5e3; color: #186a3b; }
.tag-long { background: #fadbd8; color: #78281f; }

/* 按钮 */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover { opacity: 0.8; }
.btn-primary { background: #0071e3; color: #fff; }
.btn-secondary { background: #e5e5e7; color: #1d1d1f; }
.btn-danger { background: #ff3b30; color: #fff; }

/* 搜索结果列表 */
.horse-list {
  display: grid;
  gap: 12px;
}

.horse-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.horse-item:hover {
  background: #f0f0f2;
}

.horse-item .name {
  font-weight: 500;
}

.horse-item .meta {
  font-size: 13px;
  color: #6e6e73;
}

/* === 表单样式 === */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #6e6e73;
}

.form-grid input,
.form-grid select {
  padding: 8px 12px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 14px;
}

.form-grid input:focus,
.form-grid select:focus {
  outline: none;
  border-color: #0071e3;
}

.checkbox-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox-group label {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: #1d1d1f;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.empty {
  color: #6e6e73;
  text-align: center;
  padding: 40px;
}

/* === 血统表 — 表格式 === */
.pedigree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.pedigree-controls {
  display: flex;
  gap: 4px;
}

.pedigree-table-wrap {
  overflow-x: auto;
}

.pedigree-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
  min-width: 800px;
}

.pedigree-table td {
  border: 1px solid #999;
  padding: 4px 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.pedigree-table td.ped-male {
  background: #e8e8ed;
}

.pedigree-table td.ped-female {
  background: #fff;
}

.ped-cell {
  min-width: 120px;
}

/* === 血统表 — 树形图 === */
.pedigree-tree {
  overflow-x: auto;
  padding: 16px;
}

.tree-node-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tree-children {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 8px;
  border-left: 1px solid #d2d2d7;
}

.tree-node {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #d2d2d7;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.tree-node.empty {
  color: #aaa;
  border-style: dashed;
}

/* === Cross 面板 === */
.cross-panel {
  margin-top: 16px;
}

.cross-panel h4 {
  margin-bottom: 8px;
}

.cross-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}

.cross-table th,
.cross-table td {
  padding: 6px 12px;
  border-bottom: 1px solid #e5e5e7;
  text-align: left;
}

.cross-table th {
  font-weight: 600;
  color: #6e6e73;
}

/* === 母系管理 === */
.damline-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}

.damline-sidebar h4 {
  margin-bottom: 12px;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.group-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.group-item:hover { background: #f0f0f2; }
.group-item.active { background: #0071e3; color: #fff; }

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

.mare-card { margin-bottom: 12px; }
.mare-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tree-line {
  padding: 4px 0;
  font-size: 13px;
}

.line-item {
  padding: 4px 0;
  font-size: 13px;
  color: #6e6e73;
}

/* === 配种模拟 === */
.simulate-form {
  display: flex;
  align-items: center;
  gap: 24px;
}

.simulate-pick {
  flex: 1;
  position: relative;
}

.simulate-pick label {
  font-size: 13px;
  color: #6e6e73;
  margin-bottom: 4px;
  display: block;
}

.simulate-pick input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 14px;
}

.simulate-cross-symbol {
  font-size: 32px;
  font-weight: 300;
  color: #6e6e73;
}

.sim-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}

.sim-dropdown:empty { display: none; }

.sim-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}

.sim-option:hover { background: #f0f0f2; }

.sim-selected {
  margin-top: 4px;
  font-size: 12px;
  color: #6e6e73;
}

.simulate-actions {
  margin-top: 16px;
  text-align: center;
}

/* === 通用 === */
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.meta { color: #6e6e73; font-size: 13px; }

/* === 可点击马名链接 === */
.ped-link {
  color: #0071e3;
  cursor: pointer;
  text-decoration: none;
}
.ped-link:hover { text-decoration: underline; }

/* === 搜索提示下拉 === */
.horse-suggest {
  position: absolute;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 50;
  max-height: 150px;
  overflow-y: auto;
}
.horse-suggest:empty { display: none; }
.suggest-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.suggest-item:hover { background: #f0f0f2; }

/* === 完整度指示器 === */
.comp-panel { margin-top: 16px; }
.comp-panel h4 { margin-bottom: 8px; }
.comp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}
.comp-row span:first-child { width: 40px; }
.comp-row span:last-child { width: 40px; text-align: right; color: #6e6e73; }
.comp-bar {
  flex: 1;
  height: 8px;
  background: #e5e5e7;
  border-radius: 4px;
  overflow: hidden;
}
.comp-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

/* === 响应式基础 === */
@media (max-width: 768px) {
  #main-nav {
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav-search { max-width: 100%; order: 3; width: 100%; }
  .nav-links { order: 2; }
  #app { padding: 0 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .damline-layout { grid-template-columns: 1fr; }
  .simulate-form { flex-direction: column; }
  .simulate-cross-symbol { transform: rotate(90deg); }
  .pedigree-table { font-size: 10px; }
  .ped-cell { min-width: 80px; }
  .pedigree-header { flex-direction: column; gap: 8px; }
  /* 设定管理 sidebar 改为横向 */
  .manage-layout { flex-direction: column; }
  .manage-sidebar { width: 100%; flex-direction: row; overflow-x: auto; flex-wrap: nowrap; }
  .sidebar-btn { white-space: nowrap; font-size: 12px; padding: 6px 10px; }
  /* 详情页 */
  .horse-detail-header { flex-direction: column; align-items: flex-start; }
  .horse-detail-actions { margin-left: 0; flex-wrap: wrap; }
  .detail-table { font-size: 12px; }
  .detail-table .dt { width: 60px; }
  /* 赛事表格 */
  .race-record-table { font-size: 11px; }
  .race-record-table th, .race-record-table td { padding: 2px 4px; }
  .entries-table { font-size: 11px; }
  .entries-table input, .entries-table select { font-size: 11px; }
  /* modal */
  .modal-content { min-width: auto; width: 90%; }
  .modal-options { flex-wrap: wrap; }
}

/* === 筛选栏 === */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filter-bar select {
  padding: 6px 10px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

/* === 模式切换按钮 === */
.nav-mode {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid #27ae60;
  color: #27ae60;
}
.nav-mode.mode-strict {
  border-color: #e74c3c;
  color: #e74c3c;
}

/* === 模式标记 === */
.mode-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #d4edda;
  color: #155724;
  vertical-align: middle;
}
.mode-badge.mode-strict {
  background: #f8d7da;
  color: #721c24;
}

/* === 年份警告 === */
.year-warnings { margin-top: 16px; border-left: 3px solid #f39c12; }
.year-warnings h4 { color: #856404; margin-bottom: 8px; }
.year-warnings ul { margin: 0; padding-left: 20px; font-size: 13px; color: #856404; }

/* === 分页 === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

/* === 翻页 === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 0;
}

/* === 扩展字段 === */
.form-section {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
  grid-column: 1 / -1;
}
.form-section legend {
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  padding: 0 6px;
}

/* === PDF Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  min-width: 280px;
  text-align: center;
}
.modal-content h4 { margin: 0 0 12px; }
.modal-options { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.modal-options .btn { min-width: 60px; }

/* === 档案 PDF 渲染 === */
.profile-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.profile-info { width: 100%; border-collapse: collapse; font-size: 13px; }
.profile-info td { padding: 4px 8px; border: 1px solid #dee2e6; }
.profile-info td b { color: #495057; }

/* PDF 渲染容器内血统表缩小字体+禁止换行+列宽自适应 */
.pdf-render-area .pedigree-table { font-size: 9px; width: auto; table-layout: auto; }
.pdf-render-area .pedigree-table td { white-space: nowrap; padding: 1px 3px; }

/* === 设定管理布局 === */
.manage-layout { display: flex; gap: 16px; min-height: 400px; }
.manage-sidebar { width: 120px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.sidebar-btn { text-align: left; padding: 8px 12px; border: none; background: none; cursor: pointer; border-radius: 4px; font-size: 14px; }
.sidebar-btn:hover { background: #f8f9fa; }
.sidebar-btn.active { background: #e9ecef; font-weight: 600; }
.manage-content { flex: 1; min-width: 0; }

/* === 架空马详情页 === */
.horse-detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.horse-detail-header h3 { margin: 0; }
.horse-detail-names { color: #6c757d; font-size: 14px; }
.horse-detail-actions { margin-left: auto; display: flex; gap: 8px; }
.detail-section { margin-bottom: 16px; }
.detail-section h4 { margin: 0 0 8px; padding-bottom: 4px; border-bottom: 1px solid #dee2e6; font-size: 14px; color: #495057; }
.detail-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.detail-table td { padding: 4px 0; vertical-align: top; }
.detail-table .dt { color: #6c757d; width: 80px; }
.detail-table .dd { padding-right: 24px; }
.entity-link { color: #0d6efd; cursor: pointer; text-decoration: underline; }
.entity-link:hover { color: #0a58ca; }

/* === 实体统计 === */
.entity-stats { display: flex; gap: 24px; margin: 12px 0; font-size: 14px; }
.entity-stats span { font-weight: 600; }

/* === 未验证数据标记 === */
.unverified { font-style: italic; opacity: 0.7; }

/* === 赛事系统 === */
.entries-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 12px 0; }
.entries-table th { text-align: left; padding: 4px 6px; border-bottom: 2px solid #dee2e6; font-weight: 600; font-size: 12px; color: #6c757d; }
.entries-table td { padding: 4px 6px; border-bottom: 1px solid #f0f0f0; }
.entries-table input, .entries-table select { width: 100%; padding: 2px 4px; border: 1px solid #ced4da; border-radius: 3px; font-size: 12px; }
.entries-table input[type="number"] { width: 60px; }
.schedule-inputs { display: flex; align-items: center; gap: 4px; }
.schedule-inputs select, .schedule-inputs input { width: auto; }
.race-filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.race-stats { font-size: 14px; font-weight: 600; margin: 8px 0; }
.race-record-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.race-record-table th { text-align: left; padding: 3px 6px; border-bottom: 2px solid #dee2e6; color: #6c757d; }
.race-record-table td { padding: 3px 6px; border-bottom: 1px solid #f0f0f0; }
