/* =========================================================
   Page Components Layer (shared across partial pages)
   Goal: consistent list pages + modals (compact density)
   ========================================================= */

:root {
  --ds-page-title-size: 1rem;
  --ds-table-head-size: 1.05rem; /* bigger field names */
  --ds-table-body-size: 0.9rem;
  --ds-table-head-pad-y: 8px;
  --ds-table-head-pad-x: 10px;
  --ds-table-body-pad-y: 6px;
  --ds-table-body-pad-x: 10px;
  --ds-form-label-size: 1rem; /* bigger form labels */
}

/* ===== Page header (content-header) ===== */
.content-header h6 {
  font-size: var(--ds-page-title-size);
  font-weight: 700;
  margin-bottom: 0;
}

/* ===== Table (list pages) ===== */
.ds-table thead th {
  font-size: var(--ds-table-head-size);
  color: #495057;
  border-top: none;
  border-bottom: 2px solid #dee2e6 !important;
  padding: var(--ds-table-head-pad-y) var(--ds-table-head-pad-x);
  vertical-align: middle;
  text-transform: none; /* 中文為主，不強制全大寫 */
  letter-spacing: normal;
}

.ds-table tbody td {
  font-size: var(--ds-table-body-size);
  padding: var(--ds-table-body-pad-y) var(--ds-table-body-pad-x);
  vertical-align: middle;
  color: #495057;
}

/* Action column alignment */
.ds-table td:last-child,
.ds-table th:last-child {
  white-space: nowrap !important;
  text-align: right;
}

/* Optional: fixed layout + ellipsis for dense tables */
.ds-table.is-fixed {
  table-layout: fixed;
  width: 100% !important;
}

.ds-table.is-fixed th,
.ds-table.is-fixed td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*
 * userMgt #userTable — 橫向捲軸常見成因（DevTools 可對照）：
 * 1) DataTables 預設 table.dataTable { max-width: none !important }，表格會依欄內容無限變寬
 * 2) DT 對 th/td 使用 box-sizing: content-box，padding 另加在寬度外，容易略超 100%
 * 3) 長 email / 單位名稱不換行時，整表最小寬度 > 視窗 → .table-responsive 出現 h-scroll
 * 4) 外層 flex 子項未設 min-width:0 時，寬表會把整頁撐出橫捲（見 layout.css #content-area）
 */
.card-body.p-0 > .table-responsive {
  min-width: 0;
}

.card-body.p-0 > .table-responsive > .dataTables_wrapper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

table.dataTable#userTable {
  max-width: 100% !important;
  width: 100% !important;
}

table.dataTable#userTable th,
table.dataTable#userTable td {
  box-sizing: border-box !important;
}

table.dataTable#userTable thead th:not(:last-child),
table.dataTable#userTable tbody td:not(:last-child) {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ===== Action icon buttons ===== */
.btn-action {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 4px;
  line-height: 1;
}

.btn-action + .btn-action {
  margin-left: 2px;
}

/* ===== Modal/form helpers ===== */
.bg-light-faint {
  background-color: #f8f9fa;
}

/* Compact, consistent form spacing */
.custom-form-gap .form-group {
  margin-bottom: 1rem;
}

/* Form label sizing (project uses 'label.small ...' heavily) */
.form-group label,
.form-group label.small,
label.form-label,
.custom-file-label.small {
  font-size: var(--ds-form-label-size);
}

.required:after {
  content: " *";
  color: #dc3545;
}

/* Reduce overly “shouty” small-caps for CJK UI */
.ds-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #17a2b8; /* Bootstrap info */
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ===== Modal tabs (org pages) ===== */
.nav-tabs-alt {
  border-bottom: none;
}

.nav-tabs-alt .nav-link {
  border: none;
  color: #7f8c8d;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 15px;
  transition: all 0.2s;
}

.nav-tabs-alt .nav-link:hover {
  color: #007bff;
}

.nav-tabs-alt .nav-link.active {
  color: #007bff;
  background: transparent;
  border-bottom: 3px solid #007bff;
}

/* Certificate preview + org badge (org pages) */
.certificate-preview-box {
  border: 2px dashed #dee2e6;
  transition: border-color 0.3s;
}

.certificate-preview-box:hover {
  border-color: #007bff;
}

.badge-org {
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
}

/* ===== Utilities used by awarding pages ===== */
.text-orange { color: #cd7f32; }
.bg-gray-light { background-color: rgba(0,0,0,.05); }

.animate-pulse { animation: ds-pulse 2s infinite; }
@keyframes ds-pulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* ===== Awarding: scoring page table density ===== */
/* Remove number input spinners for score inputs */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

.score-input {
  width: 55px !important;
  text-align: center;
  padding: 2px !important;
}
.ref-adj {
  width: 55px !important;
  text-align: center;
  background-color: #fff3cd !important;
  padding: 2px !important;
}
.rank-input {
  width: 50px !important;
  text-align: center;
  font-weight: 700;
  padding: 2px !important;
}
.final-score {
  font-size: 1.05rem;
  color: #d81b60;
  min-width: 60px;
}
.player-row:focus-within { background-color: #f1f8ff; }

/* Make scoring table extra dense without breaking ds-table defaults */
#scoreTable.ds-table td { padding: 4px 6px !important; }

/* ===== Awarding: progress page sticky first column ===== */
#progressTable td.place-name-col,
#progressTable th.place-name-col {
  background-color: #f8f9fa;
  font-weight: 700;
  min-width: 100px;
  position: sticky;
  left: 0;
  z-index: 10;
  border-right: 2px solid #dee2e6;
}

#progressHead th small {
  display: block;
  font-weight: 400;
  margin-top: 2px;
}

.game-complete {
  background-color: #28a745 !important;
  color: #fff !important;
  font-weight: 700;
}

/* Awarding: org ranking highlights */
#rankingBody tr:nth-child(1) { background-color: rgba(255, 215, 0, 0.05); }
#rankingBody tr:nth-child(2) { background-color: rgba(192, 192, 192, 0.05); }
#rankingBody tr:nth-child(3) { background-color: rgba(205, 127, 50, 0.05); }

/* ===== Event centralAdmin: pills + tab visibility fixes ===== */
#adminQueryTabs + .tab-content > .tab-pane { display: none; }
#adminQueryTabs + .tab-content > .active { display: block !important; }

.custom-pills .nav-link {
  color: #6c757d;
  border: 1px solid transparent;
  transition: all 0.2s;
  font-weight: 600;
  margin-right: 5px;
}
.custom-pills .nav-link.active {
  background-color: #007bff !important;
  color: #fff !important;
  box-shadow: 0 2px 4px rgba(0, 123, 255, 0.25);
}
.custom-pills .nav-link:hover:not(.active) {
  background-color: #e9ecef;
  color: #007bff;
}

/* Ensure game-table headers don't wrap */
.game-table thead th {
  white-space: nowrap;
  vertical-align: middle !important;
}
.game-table td {
  vertical-align: middle !important;
  white-space: normal;
}

/* ===== Event centralAdmin: fee query ===== */
#totalFeeAmount { letter-spacing: 0.3px; }

/* Print: hide interactive UI */
@media print {
  .no-print { display: none !important; }
  .card { border: none !important; box-shadow: none !important; }
}

/* ===== Event centralAdmin: split tables (grouping/draw lots/ungroup) ===== */
table.dataTable tbody tr.selected {
  background-color: rgba(0, 123, 255, 0.15) !important;
}

#dragbar {
  height: 12px;
  width: 100%;
  cursor: row-resize;
  background-color: #eee;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  margin-bottom: 10px;
}
#dragbar:hover { background-color: #e0e0e0; }

#container-top {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#container-top .card {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100% !important;
  margin-bottom: 0 !important;
}
#container-top .card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#container-top .dataTables_wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
#container-top .dataTables_scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
}
#container-top .dataTables_scrollBody { flex: 1 !important; }

body.resizing { cursor: row-resize !important; user-select: none !important; }
body.resizing * { pointer-events: none !important; }
#dragbar.resizing-active { pointer-events: auto !important; }

/* ===== Event centralAdmin: print page iframe ===== */
.print-iframe {
  width: 100%;
  height: 80vh;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #525659;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

/* ===== Event centralAdmin: game items modal (01_eventMgt) ===== */
#gameItemsModal .modal-content {
  height: 85vh;
  display: flex;
  flex-direction: column;
}
#gameItemsModal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding-top: 0;
}
#gameItemsModal .nav-tabs {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1020;
  border-bottom: 2px solid #dee2e6;
  padding-top: 10px;
}
#gameItemsModal .nav-link {
  border: none;
  color: #6c757d;
  font-weight: 600;
  padding: 10px 16px;
}
#gameItemsModal .nav-link:hover { color: #007bff; }
#gameItemsModal .nav-link.active {
  color: #007bff;
  border-bottom: 3px solid #007bff;
  background: transparent;
}
#gameItemsModal thead th {
  position: sticky;
  top: 52px;
  background: #f8f9fa;
  z-index: 10;
  font-weight: 600;
  border-top: none;
}

/* ===== Viewport fill helper (centralAdmin/06_numbering) ===== */
.ds-fill-viewport {
  /* Fill remaining space under the filter bar inside content wrapper */
  min-height: calc(100vh - 220px);
}

/* ===== Org centralAdmin: tab display fix (same pattern as central queries) ===== */
#mainOrgTabs + .tab-content > .tab-pane { display: none; }
#mainOrgTabs + .tab-content > .active { display: block !important; }
#orgForm .tab-content > .tab-pane { display: none; }
#orgForm .tab-content > .active { display: block !important; }

.contact-card {
  background-color: #fff;
  border-left: 4px solid #17a2b8 !important;
  transition: transform 0.2s, box-shadow 0.2s;
}
.contact-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}
.border-dashed { border-style: dashed !important; }

/* ===== Registration: common header bar + event selector ===== */
.bg-light-custom {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}
.event-select-wrapper { min-width: 280px; }
#eventSelect {
  height: calc(1.8125rem + 2px);
  padding: 0.25rem 0.5rem;
  font-size: 0.95rem;
}

/* ===== Registration: transfer UI (registrationMgt) ===== */
.transfer-container {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 15px;
  width: 100%;
}
.transfer-box {
  flex: 1 1 40%;
  max-width: 42%;
  min-width: 0;
}
.transfer-buttons {
  flex: 0 0 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
}
.transfer-buttons .btn {
  width: 100%;
  padding: 10px 5px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.player-list {
  height: 400px !important;
  overflow-y: auto;
  border: 2px solid #e9ecef !important;
  border-radius: 8px !important;
  background-color: #fff;
}
.list-group-item-action {
  cursor: pointer;
  padding: 10px 12px;
  margin-bottom: 2px;
  border: none !important;
  border-bottom: 1px solid #f8f9fa !important;
  font-size: 0.95rem;
}
.list-group-item-action.selected {
  background-color: #007bff !important;
  color: #fff !important;
}
.game-select-wrapper {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  border-left: 5px solid #17a2b8;
}
.game-tab .btnSave { display: none; }

@media (max-width: 992px) {
  .transfer-container { flex-wrap: wrap !important; }
  .transfer-box { flex: 0 0 100%; max-width: 100%; }
  .transfer-buttons { flex: 0 0 100%; flex-direction: row; }
  .transfer-buttons .btn { width: auto; padding: 10px 30px; }
}

/* ===== Player: image wrappers (playerMgt) ===== */
.image-wrapper {
  position: relative;
  background-color: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  transition: all 0.3s ease;
}
.image-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.image-wrapper:hover {
  border-color: #007bff;
  background-color: #f1f7ff;
}
.avatar-wrapper { width: 150px; height: 150px; }
.doc-wrapper { width: 100%; max-width: 280px; height: 180px; }

/* ===== My profile: avatar + soft info alert ===== */
.profile-img-main {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border: 5px solid #f8f9fa;
  transition: transform 0.25s ease;
}
.profile-img-main:hover { transform: scale(1.03); }
.alert-soft-info {
  background-color: #e7f3ff;
  border: none;
  border-radius: 10px;
}

