/* CSS 변수를 이용한 글로벌 디자인 테마 정의 */
:root {
  --font-family: 'Gowun Dodum', 'Fredoka', 'Nanum Gothic', sans-serif;
  
  /* 부드럽고 따뜻한 파스텔 테마 색상 */
  --bg-gradient: linear-gradient(135deg, #eef2f7 0%, #e0f2f1 100%);
  --sidebar-bg: rgba(255, 255, 255, 0.85);
  --card-shadow: 0 8px 24px rgba(149, 157, 165, 0.15);
  
  --color-primary: #80deea; /* 파스텔 스카이블루 */
  --color-primary-hover: #4dd0e1;
  --color-primary-text: #006064;
  
  --color-secondary: #fff59d; /* 파스텔 옐로우 */
  --color-secondary-hover: #fff176;
  --color-secondary-text: #f57f17;

  --color-danger: #ffab91; /* 파스텔 피치/오렌지 */
  --color-danger-hover: #ff8a65;
  --color-danger-text: #d84315;

  --color-text-dark: #2c3e50;
  --color-text-muted: #7f8c8d;
  
  /* 카드 개별 테마 (학생 자리) */
  --desk-bg: #ffffff;
  --desk-border: #e0f2f1;
  --desk-empty-bg: #f5f5f5;
  --desk-empty-border: #e0e0e0;
  --desk-empty-text: #b0bec5;

  /* 칠판 컬러 */
  --blackboard-bg: #2d5a27;
  --blackboard-border: #8d6e63;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--color-text-dark);
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow-x: hidden;
}

/* 전체 앱 레이아웃 */
.app-container {
  display: flex;
  width: 100%;
  max-width: 1920px;
  min-height: 100vh;
}

/* 왼쪽 설정 사이드바 */
.sidebar {
  width: 380px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 2px solid rgba(255, 255, 255, 0.5);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.03);
  z-index: 10;
  flex-shrink: 0;
}

.sidebar-header {
  margin-bottom: 0.5rem;
}

.logo {
  font-size: 1.8rem;
  font-weight: 600;
  color: #00796b;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* 입력 그룹 스타일 */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #004d40;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.count {
  font-size: 0.8rem;
  background-color: #e0f2f1;
  color: #00796b;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
}

textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid #b2dfdb;
  border-radius: 16px;
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  background-color: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
  color: var(--color-text-dark);
}

textarea:focus {
  outline: none;
  border-color: #4db6ac;
  box-shadow: 0 0 0 4px rgba(77, 182, 172, 0.15);
}

/* 그리드 세로/가로줄 입력 배치 */
.grid-setup {
  display: flex;
  gap: 1rem;
}

.input-subgroup {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input[type="number"] {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid #b2dfdb;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1.1rem;
  text-align: center;
  background-color: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
  font-weight: 600;
}

input[type="number"]:focus {
  outline: none;
  border-color: #4db6ac;
  box-shadow: 0 0 0 4px rgba(77, 182, 172, 0.15);
}

/* 인포 박스 */
.info-box {
  background-color: #e8f5e9;
  border: 2px dashed #a5d6a7;
  border-radius: 14px;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.85rem;
  color: #2e7d32;
  line-height: 1.4;
  margin-top: auto;
}

.info-icon {
  font-size: 1.2rem;
}

/* 버튼 스타일링 */
.button-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.btn {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-primary-text);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
  box-shadow: 0 8px 16px rgba(0, 96, 100, 0.15);
}

.btn-secondary {
  background-color: var(--color-secondary);
  color: var(--color-secondary-text);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--color-secondary-hover);
  box-shadow: 0 8px 16px rgba(245, 127, 23, 0.15);
}

.btn-danger {
  background-color: var(--color-danger);
  color: var(--color-danger-text);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--color-danger-hover);
  box-shadow: 0 8px 16px rgba(216, 67, 21, 0.15);
}

/* 오른쪽 메인 콘텐츠 영역 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2.5rem;
  gap: 2rem;
  overflow-y: auto;
}

/* 칠판 영역 */
.classroom-front {
  display: flex;
  justify-content: center;
  width: 100%;
}

.blackboard {
  background-color: var(--blackboard-bg);
  border: 10px solid var(--blackboard-border);
  border-radius: 12px;
  width: 60%;
  min-width: 300px;
  max-width: 600px;
  padding: 1.2rem;
  text-align: center;
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: bold;
  box-shadow: 0 10px 20px rgba(0,0,0,0.15), inset 0 0 40px rgba(0,0,0,0.4);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  position: relative;
}

/* 칠판 아래 분필 받침대 느낌 */
.blackboard::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 10%;
  width: 80%;
  height: 5px;
  background-color: #d7ccc8;
  border-radius: 3px;
}

/* 자리 배치도 그리드 컨테이너 */
.seating-chart-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seating-chart {
  display: grid;
  gap: 1.2rem;
  width: 100%;
  max-width: 1200px;
  height: auto;
  margin: 0 auto;
  grid-template-columns: repeat(var(--cols, 6), 1fr);
  transition: all 0.3s ease;
}

/* 자리 카드 공통 스타일 */
.seat-card {
  aspect-ratio: 1.3 / 1; /* 카드 비율 고정 */
  background-color: var(--desk-bg);
  border: 3px solid var(--desk-border);
  border-radius: 20px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--card-shadow);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  cursor: default;
}

.seat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 28px rgba(149, 157, 165, 0.25);
  border-color: #80deea;
}

/* 자리 번호 (예: 1-1, 1-2 또는 단순 번호) */
.seat-number {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background-color: #f1f8e9;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  align-self: flex-start;
}

/* 학생 이름 */
.seat-name {
  font-size: 1.6rem; /* 대형 화면/전자칠판 가독성을 위해 큰 폰트 적용 */
  font-weight: 600;
  color: #004d40;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: auto;
  margin-bottom: auto;
}

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

.seat-card.empty .seat-name {
  color: var(--desk-empty-text);
  font-size: 1.3rem;
  font-weight: 400;
}

.seat-card.empty:hover {
  transform: none;
  border-color: var(--desk-empty-border);
}

/* 셔플 애니메이션 클래스 */
.seat-card.shuffling {
  animation: shuffleAnimation 0.5s ease-in-out infinite alternate;
}

@keyframes shuffleAnimation {
  0% {
    transform: rotate(-3deg) scale(0.97);
    filter: brightness(0.95);
  }
  100% {
    transform: rotate(3deg) scale(1.03);
    filter: brightness(1.05);
  }
}

/* 카드가 자리잡을 때 나타나는 애니메이션 */
.seat-card.reveal {
  animation: revealAnimation 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes revealAnimation {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* 토스트 알림창 스타일 */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #00796b;
  color: #ffffff;
  padding: 1rem 2rem;
  border-radius: 30px;
  font-size: 1.1rem;
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(0,0,0,0.15);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
  opacity: 0;
  z-index: 100;
}

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

/* 모바일/태블릿 반응형 레이아웃 */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    padding: 1.5rem;
  }
  .main-content {
    padding: 1.5rem;
  }
  .blackboard {
    width: 80%;
  }
  .seating-chart {
    gap: 0.8rem;
  }
  .seat-name {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .blackboard {
    width: 100%;
    font-size: 1.1rem;
    padding: 0.8rem;
  }
  .seat-name {
    font-size: 1.1rem;
  }
  .seat-card {
    padding: 0.5rem;
    border-radius: 12px;
  }
}
