/* 전역 변수 및 기본 스타일 */
:root {
  --bg-color: #fffdf0; /* 부드러운 파스텔 노랑 */
  --card-bg: #ffffff;
  --text-main: #2d3748;
  --text-muted: #718096;
  --primary-color: #ff8a8a; /* 귀여운 코랄 피치 */
  --primary-hover: #ff7171;
  --secondary-color: #ffd3b6; /* 은은한 살구 오렌지 */
  --secondary-hover: #ffbe94;
  --mint-color: #8becb2;
  --mint-dark: #62d08d;
  --border-color: #f1ebd9;
  --danger-color: #ff6b6b;
  --danger-hover: #fa5252;
  
  --font-cute: 'Gamja Flower', cursive;
  --font-sans: 'Noto Sans KR', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  font-family: var(--font-sans);
  color: var(--text-main);
  line-height: 1.6;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 헤더 스타일 */
.app-header {
  text-align: center;
  margin-bottom: 10px;
}

.app-title {
  font-family: var(--font-cute);
  font-size: 3rem;
  color: #3b3a30;
  text-shadow: 2px 2px 0px #ffeaa7;
  margin-bottom: 5px;
}

.app-subtitle {
  font-family: var(--font-cute);
  font-size: 1.4rem;
  color: var(--text-muted);
}

/* 메인 레이아웃 */
.app-container {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* 공통 카드 스타일 */
.card {
  background-color: var(--card-bg);
  border: 4px solid var(--border-color);
  border-radius: 24px;
  box-shadow: 0 8px 0px var(--border-color);
  padding: 24px;
  transition: all 0.2s ease;
}

/* 설정 패널 */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-label {
  font-family: var(--font-cute);
  font-size: 1.5rem;
  font-weight: bold;
  color: #4a5568;
}

.info-bubble {
  font-size: 0.85rem;
  color: var(--text-muted);
  background-color: #f7fafc;
  padding: 6px 12px;
  border-radius: 12px;
  border-left: 3px solid var(--primary-color);
}

textarea {
  width: 100%;
  border: 3px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px;
  font-size: 1rem;
  font-family: var(--font-sans);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

textarea:focus {
  border-color: var(--primary-color);
}

.counter-text {
  font-family: var(--font-cute);
  font-size: 1.25rem;
  text-align: right;
  color: var(--text-muted);
}

.badge {
  background-color: var(--primary-color);
  color: white;
  padding: 2px 10px;
  border-radius: 10px;
  font-weight: bold;
}

.badge.bg-mint {
  background-color: var(--mint-dark);
}

/* 줄/칸 설정 */
.row-col-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input[type="number"] {
  width: 100%;
  border: 3px solid #e2e8f0;
  border-radius: 16px;
  padding: 10px;
  font-size: 1.1rem;
  font-weight: bold;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

input[type="number"]:focus {
  border-color: var(--primary-color);
}

.status-section {
  border-top: 2px dashed #edf2f7;
  padding-top: 15px;
}

.seat-info {
  font-family: var(--font-cute);
  font-size: 1.3rem;
  margin-bottom: 5px;
}

.warning-text {
  font-size: 0.85rem;
  color: var(--danger-color);
  font-weight: bold;
  min-height: 20px;
}

/* 버튼 스타일 */
.panel-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  font-family: var(--font-cute);
  font-size: 1.5rem;
  padding: 12px 20px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border-bottom: 4px solid var(--primary-hover);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.btn-primary:active:not(:disabled) {
  transform: translateY(4px);
  border-bottom-width: 0px;
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: #5d4037;
  border-bottom: 4px solid var(--secondary-hover);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--secondary-hover);
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(4px);
  border-bottom-width: 0px;
}

.btn:disabled {
  background-color: #cbd5e0;
  border-bottom-color: #a0aec0;
  color: #718096;
  cursor: not-allowed;
  transform: none !important;
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
  border-bottom: 4px solid var(--danger-hover);
}

.btn-danger:hover {
  background-color: var(--danger-hover);
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.btn-danger:active {
  transform: translateY(4px);
  border-bottom-width: 0px;
}

/* 교실/자리 배치 영역 */
.classroom-area {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 500px;
  background-color: #f7fafc;
}

/* 칠판/교탁 스타일 */
.teacher-desk {
  background-color: #2d5a27; /* 다크 그린 칠판 */
  color: #ffffff;
  border: 8px solid #8e6239; /* 나무 테두리 */
  border-radius: 12px;
  padding: 15px;
  text-align: center;
  font-family: var(--font-cute);
  font-size: 1.6rem;
  font-weight: bold;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 4px 6px rgba(0,0,0,0.1);
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: transform 0.1s;
}

.teacher-desk:active {
  transform: scale(0.98);
}

.teacher-desk::after {
  content: "✏️ 더블클릭하면 비밀 자리 설정";
  position: absolute;
  bottom: 2px;
  right: 10px;
  font-size: 0.8rem;
  color: #a3e635;
  font-family: var(--font-sans);
  font-weight: normal;
  opacity: 0.6;
}

/* 자리 그리드 */
.seat-grid {
  flex-grow: 1;
  display: grid;
  gap: 15px;
  justify-content: center;
  align-content: start;
  width: 100%;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 300px;
  font-family: var(--font-cute);
  font-size: 1.6rem;
  color: var(--text-muted);
}

/* 개별 좌석 카드 */
.seat-card {
  background-color: white;
  border: 3px solid #edf2f7;
  border-radius: 20px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  aspect-ratio: 4 / 3;
  box-shadow: 0 4px 6px rgba(0,0,0,0.03);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: default;
}

.seat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px rgba(0,0,0,0.05);
  border-color: var(--secondary-color);
}

.seat-card.secret-assigned {
  border-color: #cbd5e0; /* 겉보기에는 일반 자리와 동일하게 만듦 (학생 의심 회피용) */
}

/* 위장 셔플 중 카드 쉐이크 애니메이션 */
.seat-card.shuffling {
  animation: shuffleShake 0.1s infinite alternate;
}

/* 자리 배치 완료 시 바운스 애니메이션 */
.seat-card.pop-in {
  animation: bouncePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.seat-num {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: bold;
}

.student-name {
  font-family: var(--font-cute);
  font-size: 1.65rem;
  font-weight: bold;
  color: #2d3748;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* 빈자리 카드 */
.seat-card.empty-seat {
  background-color: #f7fafc;
  border: 3px dashed #cbd5e0;
  box-shadow: none;
}

.seat-card.empty-seat .student-name {
  color: #a0aec0;
  font-size: 1.4rem;
}

/* 모달 레이아웃 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
  display: none; /* 기본 숨김 */
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-color: #cbd5e0;
  box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px dashed #edf2f7;
  padding-bottom: 12px;
  margin-bottom: 15px;
}

.modal-title {
  font-family: var(--font-cute);
  font-size: 1.8rem;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  overflow-y: auto;
  flex-grow: 1;
  padding-right: 5px;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 15px;
  line-height: 1.5;
}

/* 비밀 배치 설정 그리드 */
.secret-grid {
  display: grid;
  gap: 10px;
  margin-top: 15px;
  background-color: #f7fafc;
  padding: 15px;
  border-radius: 16px;
  border: 2px solid #edf2f7;
}

.secret-cell {
  background-color: white;
  border: 2px solid #edf2f7;
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.secret-cell-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: bold;
}

.secret-select {
  width: 100%;
  border: 2px solid #cbd5e0;
  border-radius: 8px;
  padding: 4px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.secret-select:focus {
  border-color: var(--primary-color);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 2px dashed #edf2f7;
  padding-top: 15px;
  margin-top: 15px;
}

/* 토스트 스타일 */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: rgba(45, 55, 72, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-family: var(--font-cute);
  font-size: 1.4rem;
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* 애니메이션 효과 정의 */

/* 1. 카드가 뿅 튀어나오는 애니메이션 */
@keyframes bouncePop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 2. 위장 셔플 중 카드 흔들림 효과 */
@keyframes shuffleShake {
  0% {
    transform: translate(1px, 1px) rotate(0deg);
  }
  10% {
    transform: translate(-1px, -1px) rotate(-1deg);
  }
  20% {
    transform: translate(-1px, 0px) rotate(1deg);
  }
  30% {
    transform: translate(0px, 1px) rotate(0deg);
  }
  40% {
    transform: translate(1px, -1px) rotate(1deg);
  }
  50% {
    transform: translate(-1px, 1px) rotate(-1deg);
  }
  60% {
    transform: translate(-1px, -1px) rotate(0deg);
  }
  70% {
    transform: translate(1px, 1px) rotate(-1deg);
  }
  80% {
    transform: translate(-1px, 1px) rotate(1deg);
  }
  90% {
    transform: translate(1px, -1px) rotate(0deg);
  }
  100% {
    transform: translate(1px, 1px) rotate(1deg);
  }
}
