/* 글로벌 스타일 초기화 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Gowun Dodum', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root {
  --bg-app: linear-gradient(135deg, #f0f4f9 0%, #e2ebf5 100%);
  --bg-sidebar: rgba(255, 255, 255, 0.95);
  --color-primary: #85d2a4; /* 파스텔 민트 */
  --color-primary-hover: #72c192;
  --color-secondary: #a8c1ec; /* 파스텔 블루 */
  --color-secondary-hover: #93afd8;
  --color-danger: #ffb3b3;
  --color-text-main: #2c3e50;
  --color-text-muted: #7f8c8d;
  --color-card-bg: #ffffff;
  --color-student-bg: #fffdeb; /* 파스텔 크림 옐로우 */
  --color-student-border: #f7e1a0;
  --color-empty-bg: rgba(248, 249, 250, 0.5);
  --color-empty-border: #d1d5db;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.07), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
}

body {
  background: var(--bg-app);
  color: var(--color-text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* 앱 컨테이너 */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
}

/* 사이드바 */
.sidebar {
  width: 380px;
  background: var(--bg-sidebar);
  border-right: 2px solid #e2ebf5;
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.02);
  z-index: 10;
  overflow-y: auto;
}

/* 로고 영역 */
.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.logo-emoji {
  font-size: 2rem;
}

.logo-area h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #3b628a;
  letter-spacing: -0.5px;
}

/* 컨트롤 패널 */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-grow: 1;
}

/* 입력 그룹 */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label, .grid-settings label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #4a5568;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.sub-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: normal;
}

textarea {
  width: 100%;
  height: 160px;
  padding: 12px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  resize: none;
  font-size: 0.95rem;
  line-height: 1.5;
  transition: all 0.2s ease;
  outline: none;
  background: #f8fafc;
}

textarea:focus {
  border-color: var(--color-secondary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(168, 193, 236, 0.3);
}

.count-badge {
  font-size: 0.8rem;
  color: #64748b;
  text-align: right;
  margin-top: 4px;
  font-weight: 600;
}

/* 행/열 그리드 설정 */
.grid-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed #cbd5e1;
}

.settings-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field label {
  font-size: 0.8rem;
  color: #64748b;
}

input[type="number"] {
  width: 100%;
  padding: 10px;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  font-size: 1rem;
  text-align: center;
  font-weight: bold;
  outline: none;
  transition: all 0.2s;
}

input[type="number"]:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(168, 193, 236, 0.3);
}

.multiplier {
  font-size: 1.2rem;
  font-weight: bold;
  color: #94a3b8;
  margin-top: 20px;
}

/* 버튼 스타일 */
.button-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: bold;
  border: none;
  border-radius: 50px; /* 둥근 버튼 */
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  font-size: 1.1rem;
}

.btn-primary {
  background: var(--color-primary);
  color: #1a3a2a;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--color-secondary);
  color: #1e2d4a;
}

.btn-secondary:hover {
  background: var(--color-secondary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* 푸터 */
.sidebar-footer {
  margin-top: 24px;
  border-top: 1px solid #e2ebf5;
  padding-top: 16px;
}

.sidebar-footer p {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* 우측 메인 영역 */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding: 40px;
  gap: 30px;
  overflow: hidden;
  height: 100%;
}

/* 칠판 */
.blackboard {
  background: #1e3f20; /* 칠판 색상 */
  border: 12px solid #8B5A2B; /* 나무 테두리 */
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  position: relative;
}

.blackboard-title {
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: bold;
  letter-spacing: 2px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* 자리 그리드 래퍼 */
.grid-wrapper {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 10px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 24px;
  border: 2px dashed rgba(255, 255, 255, 0.5);
}

/* 자리 그리드 */
.seat-grid {
  display: grid;
  gap: 16px;
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 700px;
  grid-template-columns: repeat(var(--grid-cols, 5), 1fr);
  grid-template-rows: repeat(var(--grid-rows, 5), 1fr);
}

/* 카드 기본 스타일 */
.seat-card {
  background: var(--color-card-bg);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  padding: 12px;
}

/* 학생 카드 */
.seat-card.student {
  background: var(--color-student-bg);
  border: 3px solid var(--color-student-border);
  cursor: default;
}

.seat-card.student:hover {
  transform: scale(1.05) translateY(-4px);
  box-shadow: var(--shadow-md);
  z-index: 2;
}

/* 셔플 애니메이션 */
@keyframes popIn {
  0% {
    transform: scale(0.7) rotate(-3deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.1) rotate(2deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.seat-card.shuffle-anim {
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.seat-number {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: bold;
}

.student-name {
  font-size: 1.4rem;
  font-weight: bold;
  color: #2c3e50;
  word-break: break-all;
  text-align: center;
}

/* 빈자리 카드 */
.seat-card.empty {
  background: var(--color-empty-bg);
  border: 3px dashed var(--color-empty-border);
  box-shadow: none;
}

.seat-card.empty .student-name {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  font-weight: 500;
}

/* 모달 레이아웃 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.2s ease;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 24px;
  width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  border: 4px solid var(--color-secondary);
}

.modal-icon {
  font-size: 3rem;
  line-height: 1;
}

.modal-content h3 {
  font-size: 1.3rem;
  color: #2c3e50;
}

.modal-content p {
  font-size: 0.95rem;
  color: #64748b;
  line-height: 1.5;
}

.modal-content button {
  width: 100%;
}

.hidden {
  display: none !important;
  opacity: 0;
}

/* 토스트 메시지 */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(44, 62, 80, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: bold;
  font-size: 0.95rem;
  box-shadow: var(--shadow-md);
  z-index: 200;
  transition: all 0.3s ease;
}

/* 전자칠판 또는 대형 모니터 가독성을 위한 미디어 쿼리 */
@media (min-width: 1600px) {
  .student-name {
    font-size: 1.8rem;
  }
  .blackboard-title {
    font-size: 1.4rem;
  }
}
