/* css/training.css */

/* ===============================
   Training Page Layout
   =============================== */

.training-page {
  display: block;
  padding-right: 10px;
}

/* 主分頁：使用 common-ui.css 的 .bh-tabs / .bh-tab */
.training-type-tabs {
  width: 100%;
  margin: 8px 0 18px 0;
}

.training-type-tabs .bh-tabs {
  width: 100% !important;
  display: flex !important;
  overflow: visible !important;
}

.training-type-tabs .bh-tab {
  flex: 1 1 50% !important;
  width: 50% !important;
  min-width: 0 !important;
  max-width: none !important;
}

/* ===============================
   Main Table Card
   =============================== */

.training-main-card {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
  overflow: hidden;
  min-width: 0;
}

/* ===============================
   Toolbar
   =============================== */

.training-table-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  flex-wrap: wrap;
}

.training-status-inline {
  flex: 0 0 100%;
  width: 100%;
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.training-status-inline.error {
  color: #b91c1c;
}

.training-status-inline.success {
  color: #047857;
}

.training-toolbar-right {
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 0;
  flex-wrap: nowrap;
}

/* VIP 歷史選單：放在工具列前段 */
.training-history-tools {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 0;
  margin-right: 0;
}

.training-history-tools[hidden] {
  display: none !important;
}

.training-history-select {
  height: 32px;
  min-width: 92px;
  padding: 4px 28px 4px 12px;
  border: 1px solid #d9e2d6;
  border-radius: 999px;
  background: #f8faf8;
  color: #064b12;
  font-size: 12px;
  font-weight: 700;
  outline: none;
}

.training-history-select:focus {
  border-color: #065f46;
  box-shadow: 0 0 0 2px rgba(6, 95, 70, 0.14);
}

/* VIP 篩選 */
.training-vip-filter-box {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: #f3f5f2;
  border: 1px solid #d9e2d6;
}

.training-filter-btn {
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  background: transparent;
  color: #064b12;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.training-filter-btn:hover {
  background: #e4efe0;
}

.training-filter-btn.active {
  background: rgb(5, 71, 0);
  color: #fff;
}

/* 這個開始推右側工具靠右 */
#trainingSeasonBadge {
  margin-left: auto;
}

.training-season-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3f5f2;
  border: 1px solid #d9e2d6;
  color: #064b12;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.training-action-btn {
  flex: 0 0 auto;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}

.training-action-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.training-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.training-primary-btn {
  background: #145c22;
  color: #fff;
}

.training-secondary-btn {
  background: #374151;
  color: #fff;
}

.training-icon-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: rgb(5, 71, 0);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.training-icon-btn:hover {
  opacity: 0.88;
}

/* ===============================
   BasketPulse-like Table
   =============================== */

.training-table-wrap {
  overflow-x: auto;
  background: #fff;
}

.training-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.training-table th {
  background: rgb(5, 71, 0);
  color: #fff;
  padding: 7px 8px;
  border-bottom: 2px solid rgb(5, 71, 0);
  border-right: 1px solid rgba(255, 255, 255, 0.25);
  text-align: center;
  white-space: nowrap;
  font-weight: 900;
}

.training-table th:last-child {
  border-right: 0;
}

.training-table td {
  padding: 8px 8px;
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #eef2f7;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  color: #000b3d;
}

.training-table td:last-child {
  border-right: 0;
}

.training-table tbody tr:nth-child(even) {
  background: #f3faf1;
}

.training-table tbody tr:hover {
  background: #fff4d6;
}

.training-table tr.training-improved {
  background: #dff2df;
}

.training-table tr.training-improved:hover {
  background: #fff4d6;
}

.training-table tr.training-saved {
  animation: trainingSavedFlash 0.8s ease;
}

@keyframes trainingSavedFlash {
  0% {
    background: #dcfce7;
  }

  100% {
    background: inherit;
  }
}

/* ===============================
   Player Cells
   =============================== */

.training-name-cell {
  text-align: left !important;
  min-width: 105px;
  max-width: 125px;
  color: #111827;
}

.training-name-cell a {
  display: inline-block;
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  color: #111827;
  text-decoration: none;
  font-weight: 800;
}

.training-name-cell a:hover {
  text-decoration: underline;
}

.training-pos {
  font-weight: 900;
  color: #047857;
}

.grade-S {
  color: #dc2626;
  font-weight: 900;
}

.grade-A {
  color: #ea580c;
  font-weight: 900;
}

.grade-B {
  color: #2563eb;
  font-weight: 900;
}

.grade-C,
.grade-D {
  color: #111827;
  font-weight: 800;
}

/* ===============================
   Training Controls
   =============================== */

.training-mode-select,
.training-attr-select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 12px;
  background: #fff;
  outline: none;
}

.training-mode-select:focus,
.training-attr-select:focus {
  border-color: rgb(5, 71, 0);
  box-shadow: 0 0 0 2px rgba(5, 71, 0, 0.12);
}

.training-mode-select {
  min-width: 96px;
}

.training-attr-select {
  min-width: 64px;
  margin: 1px;
}

.training-attr-select:disabled {
  opacity: 0.5;
  background: #f3f4f6;
}

/* 不顯示內部模式說明，避免玩家看到公式感 */
.training-mode-label {
  display: none;
}

/* 訓練項目欄靠左 */
.training-table td.training-focus-cell {
  text-align: left;
}

.training-empty-focus {
  color: #9ca3af;
  font-size: 12px;
  font-weight: 800;
}

/* ===============================
   Ability / EXP / OT Cells
   =============================== */

.training-ability-cell,
.training-exp-wrap,
.training-ot-cell {
  min-height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  line-height: 1.15;
}

.training-ability-value,
.training-exp-level,
.training-ot-value {
  height: 18px;
  line-height: 18px;
  font-size: 14px;
  color: #6f78a0;
}

.training-exp-level {
  font-weight: 700;
}

.training-ot-value {
  font-weight: 400;
}

.training-gain,
.training-exp-gain,
.ot-delta {
  margin-top: 3px;
  min-height: 15px;
  line-height: 15px;
  font-size: 12px;
  font-weight: 800;
  color: #00134d;
}

.training-gain.empty,
.training-exp-gain.empty,
.ot-delta.empty {
  visibility: hidden;
}

.training-gain.up {
  color: #b45309;
  font-weight: 900;
}

.ot-delta.up {
  color: #dc2626;
  font-weight: 900;
}

.training-ability-cell.is-upgraded .training-ability-value,
.training-ot-cell.is-upgraded .training-ot-value {
  font-weight: 900;
  color: #1b4d2b;
}

/* VIP progress */
.training-progress-line {
  margin-top: 2px;
  min-height: 13px;
  line-height: 13px;
  font-size: 10px;
  font-weight: 900;
  color: #047857;
  letter-spacing: 0.2px;
}

.training-ability-cell.is-upgraded .training-progress-line {
  color: #b45309;
}

/* 舊版 attr cell 相容 */
.attr-cell {
  min-width: 46px;
  line-height: 1.15;
}

.attr-value {
  font-size: 14px;
  font-weight: 500;
  color: #7d86a8;
}

.attr-gain {
  margin-top: 4px;
  font-size: 12px;
  color: #000b3d;
  font-weight: 900;
}

.attr-gain.up {
  color: #047857;
}

.training-exp-cell {
  color: #000b3d;
  font-weight: 900;
}

/* ===============================
   Save / Error State
   =============================== */

.training-save-state {
  font-size: 12px;
  color: #6b7280;
  min-width: 54px;
}

.training-save-state.saving {
  color: #d97706;
  font-weight: 900;
}

.training-save-state.saved {
  color: #047857;
  font-weight: 900;
}

.training-save-state.error {
  color: #b91c1c;
  font-weight: 900;
}

.training-row-invalid {
  background: #fee2e2 !important;
}

.training-row-invalid td:first-child::before {
  content: "!";
  color: #dc2626;
  margin-right: 4px;
  font-weight: 900;
}

/* ===============================
   Responsive
   =============================== */

@media (max-width: 1024px) {
  .training-table-tools {
    flex-wrap: wrap;
  }

  .training-status-inline {
    width: 100%;
  }

  .training-toolbar-right {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }

  #trainingSeasonBadge {
    margin-left: 0;
  }
}

@media (max-width: 560px) {
  .training-page {
    padding-right: 0;
  }

  .training-table-tools {
    padding: 10px;
  }

  .training-status-inline {
    width: 100%;
  }

  .training-toolbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .training-action-btn {
    padding: 7px 10px;
    font-size: 12px;
  }

  .training-filter-btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .training-history-select {
    min-width: 84px;
  }
}