/* =========================================================
 * 파일명: sports-day/css/admin.css
 * 설명: 교구명과 색상 중심의 기록원 UI + 총괄 관리자(Master Admin) UI 스타일
 * ========================================================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
}

body {
  background-color: #f1f5f9;
  color: #1e293b;
  padding-bottom: 60px;
}

/* 상단 헤더 */
.admin-header {
  background-color: #1e293b;
  color: #ffffff;
  padding: 20px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.badge-tag {
  background-color: #3b82f6;
  color: white;
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 4px;
  font-weight: 600;
}

.admin-header h1 {
  font-size: 20px;
  margin-top: 5px;
}

.subtitle {
  font-size: 13px;
  color: #94a3b8;
}

.lock-status {
  font-size: 13px;
  background-color: #334155;
  padding: 6px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #ef4444; /* 잠금 시 빨강, 해제 시 녹색 */
}

/* ==============================================
   모드 전환 탭 (기록원 탭 vs 총괄 관리자 탭)
   ============================================== */
.mode-tabs-container {
  max-width: 760px;
  margin: 16px auto 0;
  padding: 0 12px;
}

.mode-tabs {
  display: flex;
  background-color: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
  gap: 6px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn:hover {
  color: #1e293b;
}

.tab-btn.active {
  background-color: #ffffff;
  color: #2563eb;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* 메인 컨테이너 */
.container {
  max-width: 760px;
  margin: 16px auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 카드 공통 스타일 */
.card {
  background-color: #ffffff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #0f172a;
}

/* 1. 종목 선택 그리드 */
.event-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.btn-event {
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 12px 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.btn-event.active {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

/* 2. 교구 선택 그리드 (단장/팀장 이름 없이 교구명과 색상만 크게 표시) */
.team-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.team-card-btn {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 16px 8px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.team-card-btn:active {
  transform: scale(0.96);
}

.team-name-text {
  font-size: 16px;
  font-weight: 800;
}

.team-color-label {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* 1교구 (흰색) */
.team-white {
  background-color: #ffffff;
  color: #0f172a;
  border: 2px solid #cbd5e1;
}
.team-white .team-color-label {
  background-color: #e2e8f0;
  color: #334155;
}
.team-white.active {
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.2);
}

/* 2교구 (검은색) */
.team-black {
  background-color: #1f2937;
  color: #ffffff;
}
.team-black .team-color-label {
  background-color: #374151;
  color: #f3f4f6;
}
.team-black.active {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.3);
}

/* 3교구 (빨간색) */
.team-red {
  background-color: #ef4444;
  color: #ffffff;
}
.team-red .team-color-label {
  background-color: #b91c1c;
  color: #ffffff;
}
.team-red.active {
  border-color: #991b1b;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

/* 4교구 (파란색) */
.team-blue {
  background-color: #3b82f6;
  color: #ffffff;
}
.team-blue .team-color-label {
  background-color: #1d4ed8;
  color: #ffffff;
}
.team-blue.active {
  border-color: #1e40af;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* 순위 배점 영역 */
.score-action-box {
  background-color: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 16px;
}

.action-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.guide-desc {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 14px;
}

.rank-btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.btn-rank {
  border: none;
  border-radius: 8px;
  padding: 14px 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-rank:hover {
  opacity: 0.9;
}

.rank-1 { background-color: #fef08a; color: #854d0e; }
.rank-2 { background-color: #e2e8f0; color: #334155; }
.rank-3 { background-color: #ffedd5; color: #9a3412; }
.rank-4 { background-color: #f1f5f9; color: #64748b; }

/* 보너스 점수 영역 */
.bonus-section {
  margin-top: 18px;
  border-top: 1px solid #e2e8f0;
  padding-top: 14px;
}

.bonus-section h4 {
  font-size: 13px;
  color: #475569;
  margin-bottom: 10px;
}

.bonus-btn-group {
  display: flex;
  gap: 8px;
}

.btn-bonus {
  flex: 1;
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 10px 6px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-bonus.minus {
  background-color: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* 점수 로그 히스토리 */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-refresh {
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-refresh:hover {
  background-color: #e2e8f0;
}

.history-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
}

.history-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-pill {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.history-score {
  font-weight: 800;
  color: #2563eb;
}

.history-btn-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-edit-score {
  background-color: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-edit-score:hover {
  background-color: #dbeafe;
}

.btn-cancel-score {
  background-color: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-cancel-score:hover {
  background-color: #fecaca;
}

/* ==============================================
   [총괄 관리자 패널 전용 스타일]
   ============================================== */
.admin-management-card {
  border-top: 4px solid #2563eb;
}

.section-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-subtitle {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
}

.btn-primary-action {
  background-color: #2563eb;
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary-action:hover {
  background-color: #1d4ed8;
}

/* 종목 추가/수정 폼 */
.event-form-box {
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.form-box-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
  color: #1e293b;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.required {
  color: #ef4444;
}

.form-group input, .form-input, .form-select {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  background-color: #ffffff;
}

.form-group input:focus, .form-input:focus, .form-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.form-button-group {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-cancel {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-cancel:hover {
  background-color: #e2e8f0;
}

.btn-save-event {
  background-color: #16a34a;
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-save-event:hover {
  background-color: #15803d;
}

/* 관리자 데이터 테이블 공통 */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.admin-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.admin-data-table th {
  background-color: #f1f5f9;
  color: #475569;
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 2px solid #cbd5e1;
}

.admin-data-table td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.admin-data-table tbody tr:hover {
  background-color: #f8fafc;
}

.td-center {
  text-align: center;
  color: #94a3b8;
  padding: 24px !important;
}

.action-buttons {
  display: flex;
  gap: 6px;
}

.btn-edit-sm {
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-edit-sm:hover {
  background-color: #dbeafe;
}

.btn-delete-sm {
  background-color: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-delete-sm:hover {
  background-color: #fee2e2;
}

/* 필터 컨트롤 */
.filter-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-controls select {
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  background-color: #ffffff;
  outline: none;
}

/* 3. 위험 구역 (비상 리셋 카드) */
.danger-card {
  border-left: 5px solid #dc2626;
  background-color: #fff1f2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.danger-header {
  flex: 1;
  min-width: 260px;
}

.danger-title {
  font-size: 15px;
  font-weight: 800;
  color: #991b1b;
  margin-bottom: 4px;
}

.danger-desc {
  font-size: 12px;
  color: #7f1d1d;
  line-height: 1.4;
}

.btn-reset-all {
  background-color: #dc2626;
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-reset-all:hover {
  background-color: #b91c1c;
}

/* ==============================================
   모달 팝업 스타일
   ============================================== */
.pin-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.pin-modal {
  background-color: #ffffff;
  padding: 26px;
  border-radius: 16px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.pin-modal h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #0f172a;
}

.pin-modal p {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 16px;
}

.pin-modal input[type="password"] {
  width: 100%;
  padding: 12px;
  font-size: 20px;
  text-align: center;
  letter-spacing: 6px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  margin-bottom: 14px;
}

.btn-submit-pin {
  width: 100%;
  background-color: #2563eb;
  color: #ffffff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn-submit-pin:hover {
  background-color: #1d4ed8;
}

.pin-btn-group {
  display: flex;
  gap: 8px;
}

.pin-btn-group button {
  flex: 1;
}

.master-pin-modal {
  border-top: 5px solid #7c3aed;
}

.master-badge {
  display: inline-block;
  background-color: #7c3aed;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 9999px;
  margin-bottom: 8px;
}

.edit-score-modal {
  max-width: 440px;
  text-align: left;
}

.edit-score-modal h3 {
  text-align: left;
}

.edit-score-modal .modal-desc {
  text-align: left;
  margin-bottom: 14px;
}