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

/* 主体样式 */
body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding-top: 70px;
}

/* 导航栏样式 */
.main-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.nav-brand {
  font-size: 1.4em;
  font-weight: bold;
  color: #667eea;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-brand:hover {
  color: #5568d3;
  transform: scale(1.05);
}

.nav-menu {
  display: flex;
  gap: 10px;
}

.nav-item {
  padding: 8px 20px;
  border-radius: 20px;
  text-decoration: none;
  color: #4a5568;
  font-weight: 500;
  transition: all 0.3s ease;
}

.nav-item:hover {
  background: #f7fafc;
  color: #667eea;
}

.nav-item.active {
  background: #667eea;
  color: white;
}

/* 主页样式 */
.home-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.home-header {
  text-align: center;
  margin-bottom: 60px;
  color: white;
}

.home-header h1 {
  font-size: 3em;
  margin-bottom: 15px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  max-width: 900px;
  margin: 0 auto;
}

.tool-card {
  background: white;
  border-radius: 15px;
  padding: 40px 30px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  cursor: pointer;
}

.tool-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
}

.tool-icon {
  font-size: 4em;
  margin-bottom: 20px;
}

.tool-card h3 {
  color: #2d3748;
  margin-bottom: 15px;
  font-size: 1.5em;
}

.tool-card p {
  color: #718096;
  margin-bottom: 25px;
  line-height: 1.6;
}

.tool-card .btn {
  margin: 0;
}

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

/* 头部样式 */
header {
  text-align: center;
  margin-bottom: 40px;
  color: white;
}

header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
  font-size: 1.1em;
  opacity: 0.9;
  font-weight: 300;
}

/* 区块通用样式 */
section {
  background: white;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

section:hover {
  transform: translateY(-2px);
}

section h2 {
  color: #4a5568;
  margin-bottom: 20px;
  font-size: 1.4em;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

/* 导出按钮样式 */
.export-btn {
  font-size: 0.8em !important;
  padding: 6px 12px !important;
  min-width: auto !important;
  margin: 0 !important;
}

/* 总分排行榜 */
.scoreboard {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.scoreboard h2 {
  color: white;
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.score-item {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  transition: transform 0.3s ease;
}

.score-item:hover {
  transform: scale(1.05);
}

.score-item .group-name {
  font-size: 1.5em;
  font-weight: bold;
  margin-bottom: 5px;
}

.score-item .total-score {
  font-size: 2em;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.score-item .rank {
  font-size: 0.9em;
  opacity: 0.8;
  margin-top: 5px;
}

/* 当前轮次 */
.current-round {
  border-left: 4px solid #3182ce;
}

.round-content {
  margin-top: 20px;
}

.round-hint {
  text-align: center;
  color: #718096;
  font-style: italic;
  padding: 40px 20px;
  background: #f7fafc;
  border-radius: 8px;
}

.participant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.participant-item {
  background: #f7fafc;
  border-radius: 10px;
  padding: 15px;
  border: 2px solid #e2e8f0;
  transition: all 0.3s ease;
  min-width: 200px;
}

.participant-item:hover {
  border-color: #3182ce;
  box-shadow: 0 4px 12px rgba(49, 130, 206, 0.15);
}

.participant-item h3 {
  color: #2d3748;
  margin-bottom: 10px;
  text-align: center;
  font-size: 1.2em;
}

.rank-label {
  text-align: center;
  color: #4a5568;
  font-size: 0.9em;
  margin-bottom: 15px;
  font-weight: 500;
}

.rank-selector {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.rank-btn {
  padding: 8px 6px;
  border: 2px solid #e2e8f0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  min-width: 45px;
  max-width: 60px;
  text-align: center;
  font-size: 0.75em;
  line-height: 1.1;
  flex: 1;
}

.rank-btn:hover {
  border-color: #3182ce;
  background: #ebf8ff;
  transform: translateY(-2px);
}

.rank-btn.selected {
  background: #3182ce;
  color: white;
  border-color: #3182ce;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
}

.rank-btn small {
  display: block;
  font-size: 0.7em;
  opacity: 0.8;
  margin-top: 2px;
}

.rank-btn.gold.selected {
  background: linear-gradient(145deg, #ffd700, #ffa500);
  color: #000;
  border-color: #ffd700;
}
.rank-btn.silver.selected {
  background: linear-gradient(145deg, #c0c0c0, #a8a8a8);
  color: #000;
  border-color: #c0c0c0;
}
.rank-btn.bronze.selected {
  background: linear-gradient(145deg, #cd7f32, #a0522d);
  color: #fff;
  border-color: #cd7f32;
}
.rank-btn.fourth.selected {
  background: linear-gradient(145deg, #4a5568, #2d3748);
  color: #fff;
  border-color: #4a5568;
}

/* 控制按钮 */
.controls {
  text-align: center;
}

.button-group {
  margin-bottom: 15px;
}

.button-group:last-child {
  margin-bottom: 0;
}

.btn {
  padding: 12px 24px;
  margin: 0 8px 8px 0;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  min-width: 120px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
  background: #3182ce;
  color: white;
}

.btn-primary:hover {
  background: #2c5aa0;
}

.btn-success {
  background: #38a169;
  color: white;
}

.btn-success:hover {
  background: #2f855a;
}

.btn-secondary {
  background: #718096;
  color: white;
}

.btn-secondary:hover {
  background: #4a5568;
}

.btn-warning {
  background: #d69e2e;
  color: white;
}

.btn-warning:hover {
  background: #b7791f;
}

.btn-danger {
  background: #e53e3e;
  color: white;
}

.btn-danger:hover {
  background: #c53030;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* 历史记录 */
.history-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  background: #f7fafc;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 10px;
  border-left: 4px solid #3182ce;
}

.history-round {
  font-weight: bold;
  color: #2d3748;
  margin-bottom: 8px;
}

.history-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  font-size: 0.9em;
}

.history-result {
  background: white;
  padding: 5px 10px;
  border-radius: 4px;
  text-align: center;
}

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.modal-content h3 {
  margin-bottom: 15px;
  color: #2d3748;
}

.modal-content p {
  margin-bottom: 20px;
  color: #4a5568;
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* 页脚 */
footer {
  text-align: center;
  color: white;
  opacity: 0.8;
  margin-top: 40px;
  font-size: 0.9em;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }

  header h1 {
    font-size: 2em;
  }

  section {
    padding: 20px;
    margin-bottom: 20px;
  }

  section h2 {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .participant-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .score-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .btn {
    min-width: 100px;
    margin: 0 4px 8px 0;
  }

  .modal-content {
    padding: 20px;
    margin: 20px;
  }

  .modal-buttons {
    flex-direction: column;
  }

  .rank-selector {
    justify-content: center;
    flex-wrap: nowrap;
  }

  .rank-btn {
    min-width: 45px;
    max-width: 60px;
    font-size: 0.75em;
    padding: 6px 8px;
  }

  .rank-selector {
    gap: 4px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.8em;
  }

  .score-grid {
    grid-template-columns: 1fr 1fr;
  }

  .btn {
    width: 100%;
    margin: 0 0 8px 0;
  }

  .button-group {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .rank-btn {
    min-width: 40px;
    max-width: 55px;
    font-size: 0.7em;
    padding: 5px 6px;
  }

  .rank-selector {
    gap: 3px;
  }

  .participant-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }

  .participant-item {
    min-width: 240px;
  }
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

/* 滚动条美化 */
.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 体测数据对比系统样式 */
.compare-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.compare-container h2 {
  color: #4a5568;
  margin-bottom: 20px;
  font-size: 1.8em;
  text-align: center;
}

/* 顶部工具栏样式 */
.compare-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.toolbar-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
}

.save-status {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9em;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  transition: all 0.3s ease;
}

.save-status.saved {
  background: rgba(56, 161, 105, 0.3);
  color: #e6fffa;
}

.save-status.unsaved {
  background: rgba(237, 137, 54, 0.3);
  color: #fffaf0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* 工作区标签栏样式 */
.workspace-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 10px;
  background: #f7fafc;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  overflow-x: auto;
}

.tabs-container {
  display: flex;
  gap: 5px;
  flex: 1;
  overflow-x: auto;
}

.workspace-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  min-width: 100px;
  max-width: 200px;
}

.workspace-tab:hover {
  background: #edf2f7;
  border-color: #cbd5e0;
  transform: translateY(-2px);
}

.workspace-tab.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tab-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  user-select: none;
}

.workspace-tab.active .tab-name {
  color: white;
}

.tab-close {
  padding: 2px 6px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #718096;
  transition: all 0.2s ease;
}

.tab-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #e53e3e;
}

.workspace-tab.active .tab-close {
  color: white;
}

.workspace-tab.active .tab-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fed7d7;
}

.btn-add-workspace {
  padding: 8px 16px;
  background: #3182ce;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.btn-add-workspace:hover {
  background: #2c5aa0;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
}

/* 自定义Modal样式 */
.custom-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease-out;
}

.custom-modal-content {
  background: white;
  border-radius: 16px;
  padding: 30px 35px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 450px;
  width: 90%;
  animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.custom-modal-content h3 {
  color: #2d3748;
  font-size: 1.5em;
  margin-bottom: 15px;
  text-align: center;
}

.custom-modal-content p {
  color: #4a5568;
  margin-bottom: 20px;
  line-height: 1.6;
  text-align: center;
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 20px;
  transition: all 0.3s ease;
  font-family: inherit;
}

.modal-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.custom-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.custom-modal-buttons .btn {
  flex: 1;
  min-width: 100px;
  margin: 0;
}

.compare-controls {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.compare-controls label {
  font-weight: 500;
  color: #4a5568;
}

.compare-controls input[type="text"],
.compare-controls input[type="number"] {
  padding: 8px 12px;
  font-size: 14px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  transition: border-color 0.3s ease;
}

.compare-controls input[type="text"]:focus,
.compare-controls input[type="number"]:focus {
  outline: none;
  border-color: #667eea;
}

#dataTable {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

#dataTable th,
#dataTable td {
  border: 1px solid #e2e8f0;
  padding: 10px;
  text-align: center;
}

#dataTable th {
  background: #f7fafc;
  color: #2d3748;
  font-weight: 600;
  position: relative;
}

/* 拖拽排序相关样式 */
#dataTable tbody tr {
  transition: background-color 0.2s;
}

#dataTable tbody tr:hover {
  background-color: #f7fafc;
}

#dataTable tbody tr.dragging {
  opacity: 0.5;
  background-color: #e2e8f0;
}

#dataTable tbody tr.drag-over {
  border-top: 3px solid #667eea;
}

/* 拖拽手柄样式 */
.drag-handle {
  cursor: grab;
  font-size: 18px;
  color: #94a3b8;
  user-select: none;
  padding: 8px;
}

.drag-handle:hover {
  color: #667eea;
}

.drag-handle:active {
  cursor: grabbing;
}

#dataTable input[type="text"],
#dataTable input[type="number"] {
  padding: 6px 10px;
  font-size: 14px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  text-align: center;
  transition: all 0.3s ease;
}

#dataTable input[type="text"]:hover,
#dataTable input[type="number"]:hover {
  border-color: #cbd5e0;
  background: #f7fafc;
}

#dataTable input[type="text"]:focus,
#dataTable input[type="number"]:focus {
  outline: none;
  border-color: #667eea;
  background: white;
}

.seriesName {
  font-weight: bold;
  padding: 4px 8px;
}

.deleteSeriesBtn,
.deleteBtn {
  padding: 4px 10px;
  font-size: 12px;
  background: #e53e3e;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.deleteSeriesBtn:hover,
.deleteBtn:hover {
  background: #c53030;
}

#chart {
  width: 100%;
  height: 600px;
  margin-top: 20px;
  border-radius: 8px;
  background: white;
}

/* 响应式设计补充 */
@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    height: auto;
    padding: 10px;
  }

  .nav-brand {
    margin-bottom: 10px;
  }

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

  .nav-item {
    flex: 1;
    text-align: center;
  }

  .home-header h1 {
    font-size: 2em;
  }

  .tool-cards {
    grid-template-columns: 1fr;
  }

  /* 工具栏响应式 */
  .compare-toolbar {
    flex-direction: column;
    gap: 10px;
  }

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

  .toolbar-left .btn {
    flex: 1;
    min-width: auto;
  }

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

  /* 工作区标签响应式 */
  .workspace-tabs {
    flex-direction: column;
    gap: 10px;
  }

  .tabs-container {
    width: 100%;
  }

  .workspace-tab {
    min-width: 80px;
    max-width: 150px;
  }

  .btn-add-workspace {
    width: 100%;
  }

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

  .compare-controls button {
    width: 100%;
  }

  .compare-controls label {
    width: 100%;
  }

  .compare-controls label input {
    width: 100% !important;
    margin-top: 5px;
  }

  #chart {
    height: 400px;
  }

  /* 自定义Modal响应式 */
  .custom-modal-content {
    padding: 25px;
    max-width: 95%;
  }

  .custom-modal-content h3 {
    font-size: 1.3em;
  }

  .custom-modal-buttons {
    flex-direction: column;
  }

  .custom-modal-buttons .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .home-header h1 {
    font-size: 1.8em;
  }

  .tool-icon {
    font-size: 3em;
  }

  .compare-container {
    padding: 15px;
  }

  #dataTable {
    font-size: 12px;
  }

  #dataTable th,
  #dataTable td {
    padding: 6px;
  }

  /* 移动端Modal优化 */
  .custom-modal-content {
    padding: 20px;
  }

  .custom-modal-content h3 {
    font-size: 1.2em;
  }

  .modal-input {
    font-size: 14px;
    padding: 10px 12px;
  }
}
