/* ==========================================================
   endings.css - 끝수(1~9끝, 0끝) 모눈종이 패턴 추적 전용 스타일시트
   (이월수 & 이웃수 carryover.css 규격 호환 + 좌우 드래그 스크롤 및 상세 자료 컬럼 최적화)
   ========================================================== */

/* 카드 헤더 컨트롤 */
.carryover-header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* 색상 범례 아이템 */
.carryover-legend-items {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-badge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 6px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-badge.legend-carry {
  background: #F59E0B;
  color: #000000;
  font-weight: 800;
}

.legend-badge.legend-bonus {
  background: linear-gradient(135deg, #A855F7 0%, #7C3AED 100%);
  color: #FFFFFF;
  font-weight: 800;
}

.legend-badge.legend-win {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93C5FD;
}

/* 상단 가로 스크롤 동기화 바 */
#endingsTopScrollWrap {
  overflow-x: auto !important;
  width: 100%;
  height: 14px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 4px;
}

#endingsTopScrollDummy {
  height: 1px;
}

/* 스크롤바 커스텀 스타일 */
#endingsTopScrollWrap::-webkit-scrollbar,
#endingsScrollContainer::-webkit-scrollbar {
  height: 9px;
}

#endingsTopScrollWrap::-webkit-scrollbar-track,
#endingsScrollContainer::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.65);
  border-radius: 4px;
}

#endingsTopScrollWrap::-webkit-scrollbar-thumb,
#endingsScrollContainer::-webkit-scrollbar-thumb {
  background: rgba(96, 165, 250, 0.5);
  border-radius: 4px;
}

#endingsTopScrollWrap::-webkit-scrollbar-thumb:hover,
#endingsScrollContainer::-webkit-scrollbar-thumb:hover {
  background: #60A5FA;
}

/* 모눈종이 격자 테이블 스크롤 컨테이너 (마우스 드래그 스크롤 지원) */
#endingsScrollContainer {
  overflow-x: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  display: block !important;
  -webkit-overflow-scrolling: touch;
  cursor: grab !important;
  user-select: none !important;
  padding-bottom: 6px;
}

#endingsScrollContainer.is-dragging,
#endingsScrollContainer.is-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

#endingsTableInnerWrap {
  width: max-content !important;
  min-width: 100% !important;
}

/* style.css의 table-layout: fixed 및 contain: paint 오버라이드하여 가로 스크롤 보장 */
.carryover-grid-table.endings-grid-table {
  table-layout: auto !important;
  width: max-content !important;
  min-width: 1620px !important;
  border-collapse: collapse;
  contain: none !important;
}

.carryover-grid-table.endings-grid-table th,
.carryover-grid-table.endings-grid-table td {
  padding: 4px 2px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid-numbers-head {
  color: #93C5FD;
  font-weight: 700;
  font-size: 12.5px;
  background: rgba(15, 23, 42, 0.9);
}

/* 끝수 그룹(1~9끝, 0끝) 좌측 경계선 강조 (끝수 상세 자료와 동일한 하늘색 구분선) */
.carryover-grid-table.endings-grid-table thead tr.grid-header-row th.end-group-head,
.carryover-grid-table.endings-grid-table thead tr.grid-subhead-row th.end-group-start,
.carryover-grid-table.endings-grid-table tbody td.grid-num-cell.end-group-start {
  border-left: 2px solid rgba(56, 189, 248, 0.4) !important;
}

/* 홀수번째/짝수번째 끝수 그룹 배경 미세 교차로 가독성 향상 */
.end-group-head:nth-child(even) {
  background: rgba(30, 41, 59, 0.92) !important;
  color: #BAE6FD !important;
}

.carryover-grid-table.endings-grid-table .grid-head-num {
  font-size: 11px;
  color: #94A3B8;
  width: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  background: rgba(15, 23, 42, 0.75) !important;
}

.carryover-grid-table.endings-grid-table .grid-head-num.end-group-alt {
  background: rgba(30, 41, 59, 0.55) !important;
}

.carryover-grid-table.endings-grid-table .grid-num-cell {
  width: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  height: 28px;
  padding: 2px !important;
}

.carryover-grid-table.endings-grid-table .grid-num-cell.end-group-alt {
  background: rgba(30, 41, 59, 0.18);
}

.carryover-grid-table.endings-grid-table .col-fixed.col-round {
  width: 72px !important;
  min-width: 72px !important;
  max-width: 72px !important;
  position: sticky !important;
  left: 0 !important;
  background: #0F172A !important;
  font-weight: 700;
  white-space: nowrap;
  z-index: 15 !important;
}

/* 우측 끝수 상세 자료 그룹 헤더 및 데이터 셀 */
.end-detail-group-head {
  border-left: 2px solid rgba(56, 189, 248, 0.4) !important;
  background: rgba(15, 23, 42, 0.96) !important;
  color: #38BDF8 !important;
}

.carryover-grid-table.endings-grid-table .grid-head-detail {
  font-size: 11.5px;
  font-weight: 800;
  color: #CBD5E1 !important;
  background: rgba(22, 30, 46, 0.95) !important;
  white-space: nowrap;
  padding: 5px 10px !important;
}

.grid-head-detail.detail-start,
.td-end-detail.detail-start {
  border-left: 2px solid rgba(56, 189, 248, 0.4) !important;
}

.td-end-detail {
  background: rgba(15, 23, 42, 0.65);
  font-size: 11.5px;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Pretendard', sans-serif;
  white-space: nowrap;
  padding: 4px 10px !important;
}

.col-end-same {
  min-width: 140px !important;
  width: 140px !important;
}

.col-end-pattern {
  min-width: 105px !important;
  width: 105px !important;
  color: #94A3B8;
  font-size: 11px;
}

.col-end-sum {
  min-width: 68px !important;
  width: 68px !important;
  color: #38BDF8;
}

.same-end-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  margin: 0 1px;
}

.same-end-tag.tag-2 {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #FBBF24;
}

.same-end-tag.tag-3plus {
  background: rgba(244, 63, 94, 0.22);
  border: 1px solid rgba(244, 63, 94, 0.55);
  color: #FB7185;
}

.grid-empty-dot {
  display: inline-block;
  width: 3px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}

/* 격자 볼 칩 */
.grid-ball-chip {
  width: 20px;
  height: 22px;
  line-height: 22px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 3px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chip-normal {
  background: rgba(59, 130, 246, 0.25);
  border: 1px solid rgba(59, 130, 246, 0.5);
  color: #93C5FD;
}

.chip-carryover {
  background: #F59E0B;
  color: #000000;
  font-weight: 800;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.chip-bonus-normal {
  background: linear-gradient(135deg, #A855F7 0%, #7C3AED 100%);
  color: #FFFFFF;
}

/* 추가 로딩 인디케이터 */
.carryover-scroll-loader {
  padding: 16px 0;
  text-align: center;
  color: #93C5FD;
  font-size: 13px;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.carryover-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2.5px solid rgba(147, 197, 253, 0.3);
  border-top-color: #60A5FA;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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