/* 변수 정의 */
:root {
  /* 색상 */
  --primary-color: #2196f3;
  --success-color: #4caf50;
  --danger-color: #c80000;
  --border-color: #ddd;
  --bg-light: #f8f9fa;
  --bg-lighter: #e9ecef;
  --text-muted: #666;

  /* 여백 */
  --spacing-sm: 8px;
  --spacing-md: 5px;
  --spacing-lg: 20px;

  /* 기타 */
  --border-radius: 4px;
  --shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
  --transition-speed: 0.3s;
}

/* 기본 레이아웃 */
.scheduler-wrapper {
  padding: var(--spacing-lg);
  background: #fff;
}

.search-section {
  margin-bottom: var(--spacing-lg);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.filter-select {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 14px;
  min-width: 200px;
}

/* 테이블 레이아웃 */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--spacing-lg);
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--border-color);
  padding: var(--spacing-md);
}

.time-header,
.court-header {
  background: var(--bg-lighter);
  font-weight: bold;
  text-align: center;
}

.time-cell {
  background: var(--bg-lighter);
  text-align: center;
  width: 80px;
  white-space: nowrap;
}

.court-matches {
  min-height: 100px;
  vertical-align: top;
  width: 25%;
  max-width: 300px;
  transition: background-color 0.3s ease;
}

/* 매치 카드 */
.match-item {
  border: 1px solid #ddd;
  border-radius: 8px;
  margin: 5px;
  padding: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  max-width: 240px;
}

.match-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
}

.match-info {
  font-weight: bold;
  font-size: 16px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-details {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #444;
  margin-top: 4px;
}

.match-teams {
  display: flex;
  flex-direction: column;
}

.team {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.score {
  font-weight: bold;
  margin-left: 5px;
}

/* 부서 태그 */
.dept-item {
  font-weight: bold;
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 4px;
  border-radius: 4px;
}

.match-time {
  font-size: 12px;
  color: #999;
}

/* 부서별 색상 */
.dept-1 {
  background-color: var(--success-color);
}
.dept-2 {
  background-color: var(--primary-color);
}
.dept-3 {
  background-color: #f44336;
}
.dept-4 {
  background-color: #9c27b0;
}
.dept-5 {
  background-color: #ff9800;
}

/* Dragula 스타일 */
.gu-mirror {
  /* 드래그 중인 경기 강조 */
  background-color: #fff !important;
  border: 2px solid var(--primary-color) !important;
  box-shadow: var(--shadow) !important;
  opacity: 0.9 !important;
}

.gu-hide {
  display: none !important;
}

.gu-unselectable {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

.gu-transit {
  /* 원래 위치 표시 */
  opacity: 0.3 !important;
  background-color: var(--bg-lighter) !important;
  border: 1px dashed var(--border-color) !important;
}

/* 드래그 앤 드롭 상태 */
.gu-over {
  /* 드롭 가능한 영역 하이라이트 */
  background-color: #e3f2fd !important;
  border: 1px dashed var(--primary-color) !important;
  transition: all var(--transition-speed) ease !important;
}

.match-item.ex-moved {
  border: 2px solid var(--danger-color);
  background-color: #fff3f3;
  position: relative;
}

.match-item.ex-moved::after {
  content: "이동됨";
  position: absolute;
  top: 0;
  right: 0;
  background: var(--danger-color);
  color: white;
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 0 var(--border-radius) 0 var(--border-radius);
}

.court-matches.ex-over {
  background-color: #e3f2fd;
  border: 2px dashed var(--primary-color);
}

/* 새로고침 버튼 스타일 */
.refresh-btn {
  background: none;
  border: 1px solid var(--border-color);
  cursor: pointer;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text-muted);
  border-radius: var(--border-radius);
  transition: all var(--transition-speed) ease;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
}

.refresh-btn span {
  font-size: 14px;
}

.refresh-btn i {
  font-size: 14px;
}

.refresh-btn:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  background-color: var(--bg-light);
}

.refresh-btn.rotating i {
  transition: transform 0.8s ease-in-out;
  transform: rotate(360deg);
}

.refresh-btn.rotating {
  background-color: var(--bg-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
  pointer-events: none; /* 애니메이션 중 추가 클릭 방지 */
}

/* 저장 버튼 스타일 */
.save-btn {
  background: var(--primary-color);
  border: none;
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-speed) ease;
}

.save-btn:disabled {
  background: var(--border-color);
  cursor: not-allowed;
  opacity: 0.7;
}

.save-btn:not(:disabled):hover {
  background: #1976d2;
}

.save-btn.loading {
  position: relative;
  opacity: 0.8;
}

.save-btn.loading i {
  animation: spin 1s infinite linear;
}

/* 임시 이동 상태 스타일 */
.match-item.pending-move {
  opacity: 0.8;
  border: 4px dashed #1aeb5f;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 모달 스타일 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  padding: var(--spacing-lg);
  border-radius: var(--border-radius);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  margin: 0 0 var(--spacing-lg);
  color: var(--text-dark);
}

.changes-list {
  margin-bottom: var(--spacing-lg);
}

.change-item {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  background: #fff;
}

.change-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

.change-header .game-no {
  font-weight: bold;
  color: var(--primary-color);
}

.change-header .dept-name {
  font-size: 12px;
  padding: 2px 8px;
  background: var(--primary-color);
  color: white;
  border-radius: 3px;
}

.teams-info {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--spacing-md) 0;
  gap: var(--spacing-sm);
  background: var(--bg-light);
  padding: var(--spacing-sm);
  border-radius: var(--border-radius);
}

.team-name {
  flex: 1;
  text-align: center;
  font-weight: 500;
}

.vs {
  padding: 0 var(--spacing-sm);
  color: var(--text-muted);
  font-size: 12px;
}

.change-from,
.change-to {
  margin: 4px 0;
  font-size: 14px;
}

.change-to {
  color: var(--primary-color);
  font-weight: 500;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-lg);
}

.btn {
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--border-radius);
  cursor: pointer;
  border: none;
  font-size: 14px;
  transition: all var(--transition-speed) ease;
}

.confirm-btn {
  background: var(--primary-color);
  color: white;
}

.confirm-btn:hover {
  background: #1976d2;
}

.cancel-btn {
  background: var(--border-color);
  color: var(--text-muted);
}

.cancel-btn:hover {
  background: #ccc;
}

/* 모달 알림 스타일 */
.modal-notice {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md);
  background-color: #fff8e1;
  border-radius: var(--border-radius);
  border: 1px solid #ffe082;
}

.notice-text {
  color: #f57c00;
  font-weight: 500;
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.notice-text i {
  font-size: 18px;
}

.notice-list {
  margin: 0;
  padding-left: 24px;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}

.notice-list li {
  margin-bottom: 4px;
}

.notice-list li:last-child {
  margin-bottom: 0;
}

/* 드래그 불가능 상태의 경기 카드 스타일 */
.match-item.disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* 드래그 가능한 경기 카드 스타일 */
.match-item:not([data-status="경기종료"]):not([data-status="경기진행중"]) {
  cursor: grab;
}

/* 드래그 중인 경기 카드 스타일 */
.match-item:not([data-status="경기종료"]):not(
    [data-status="경기진행중"]
  ):active {
  cursor: grabbing;
}

/* 저장 대기 중인 경기 카드 스타일 */
.match-item.pending-save {
  border: 2px solid var(--primary-color);
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.3);
}

/* 매치 정보 스타일 */
.match-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* 라운드 타입 스타일 */
.round-type {
  font-size: 12px;
  color: #e21919;
  font-weight: bold;
}

/* 토너먼트 경기 스타일 */
.match-item[data-round-type]:not([data-round-type=""]) .match-content {
  border-left: 3px solid #ff9800;
}

/* 라운드별 색상 구분 */
.match-item[data-round-type="64"] .round-type {
  background-color: #e3f2fd;
  color: #1976d2;
}
.match-item[data-round-type="32"] .round-type {
  background-color: #e8f5e9;
  color: #388e3c;
}
.match-item[data-round-type="16"] .round-type {
  background-color: #fff3e0;
  color: #f57c00;
}
.match-item[data-round-type="8"] .round-type {
  background-color: #fce4ec;
  color: #c2185b;
}
.match-item[data-round-type="4"] .round-type {
  background-color: #f3e5f5;
  color: #7b1fa2;
}
.match-item[data-round-type="2"] .round-type {
  background-color: #ffebee;
  color: var(--danger-color);
  font-weight: bold;
}

/* 이동된 경기 스타일 - 더 부드러운 스타일로 변경 */
.match-item.moved-match {
  border-left: 2px solid var(--danger-color);
}

/* 이동됨 라벨 제거 */
.match-item.moved-match::after {
  display: none; /* 이동됨 라벨 숨김 */
}

/* 이동 이력이 있는 매치 스타일 */
.match-item.has-move-history {
  position: relative;
}

/* 이동 이력 아이콘 스타일 */
.match-item.has-move-history .move-history-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--danger-color);
  font-size: 12px;
  opacity: 0.7;
}

/* 이동된 매치의 내용 스타일 */
.match-item.moved-match .match-content {
  padding: var(--spacing-md);
  position: relative;
}

/* 매치 헤더 영역 여백 조정 */
.match-item.moved-match .match-header {
  padding-right: 30px; /* 여백 감소 */
}

/* 상태별 스타일과의 충돌 방지 */
.match-item[data-status="경기종료"].moved-match,
.match-item[data-status="경기진행중"].moved-match {
  opacity: 0.8 !important;
}

/* 경기 상태별 스타일 통합 */
.match-item[data-status="경기종료"] {
  background-color: #e9ecef !important;
  opacity: 0.7 !important;
  border: 1px solid #ced4da !important;
  pointer-events: auto !important;
  cursor: not-allowed !important;
  user-select: none !important;
}

.match-item[data-status="경기진행중"] {
  background-color: #fff3cd !important;
  border: 1px solid #ffeeba !important;
  pointer-events: auto !important;
  cursor: not-allowed !important;
  user-select: none !important;
}

/* 상태 표시 라벨 */
.match-item[data-status="경기종료"]::before,
.match-item[data-status="경기진행중"]::before {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
  z-index: 2;
}

.match-item[data-status="경기종료"]::before {
  content: "종료";
  background-color: #6c757d;
  color: white;
}

.match-item[data-status="경기진행중"]::before {
  content: "진행중";
  background-color: #ffc107;
  color: #000;
}

/* 호버 효과 제거하되 커서는 유지 */
.match-item[data-status="경기종료"]:hover,
.match-item[data-status="경기진행중"]:hover {
  transform: none !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
}

/* 드래그 방지를 위한 이벤트 처리 */
.match-item[data-status="경기종료"] *,
.match-item[data-status="경기진행중"] * {
  pointer-events: none !important;
}

/* 같은 팀 하이라이트 스타일 - 단순화 */
.match-item.same-team-highlight {
  border: 2px solid var(--danger-color);
  background-color: #fff0f0;
  position: relative;
  z-index: 2;
}

/* 같은 팀 알림 라벨 */
.match-item.same-team-highlight::before {
  content: "⚠️ 같은 팀";
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--danger-color);
  color: white;
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: bold;
  z-index: 3;
}

/* 팀 이름 강조 */
.match-item.same-team-highlight .team {
  color: var(--danger-color);
  font-weight: bold;
}

/* 로그 다운로드 버튼 */
.log-download-btn {
  padding: 5px 10px;
  margin-left: 10px;
  background-color: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  display: none;
}

.log-download-btn:hover {
  background-color: #5a6268;
}

.log-download-btn i {
  font-size: 14px;
}

/* 컨텍스트 메뉴 스타일 */
.context-menu {
  position: fixed;
  z-index: 1000;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  padding: 8px 0;
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.context-menu.show {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.context-menu-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dark);
  transition: all var(--transition-speed) ease;
  font-size: 14px;
}

.context-menu-item:hover {
  background-color: var(--bg-light);
  color: var(--primary-color);
}

.context-menu-item i {
  font-size: 14px;
  width: 16px;
  text-align: center;
}

/* 구분선 */
.context-menu-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

.announce-input-group {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}

.announce-input {
  min-width: 800px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 14px;
  height: 38px;
}

.announce-btn {
  padding: 8px 16px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.announce-btn:hover {
  background: #1976d2;
}
