/* ===================================================
   교실 자리 배치 — MUJI 스타일 디자인 시스템
   컬러: #F5F5F0 배경 / #4A4A4A 텍스트 / #8B7355 강조
   =================================================== */

/* ---------- 리셋 & 기본 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #F5F5F0;       /* 자연 베이지 */
  --bg-panel:     #EFEDE7;       /* 패널 배경 */
  --bg-panel-2:   #E8E5DC;       /* 보조 패널 */
  --bg-input:     #FAF9F5;       /* 입력창 배경 */
  --bg-seat:      #FAFAF6;       /* 빈 자리 */
  --bg-seat-fill: #EDE8DF;       /* 채워진 자리 */

  --accent:       #8B7355;       /* 웜 브라운 */
  --accent-light: #C4AB8A;       /* 연한 브라운 */
  --accent-dark:  #6B5740;       /* 진한 브라운 */

  --text-primary: #4A4A4A;       /* 메인 텍스트 */
  --text-second:  #8A8A8A;       /* 보조 텍스트 */
  --text-muted:   #B8B4AC;       /* 흐린 텍스트 */

  --border:       #D8D4C8;       /* 기본 테두리 */
  --border-strong:#C4BFB2;       /* 강한 테두리 */

  --blackboard-bg:#3A5A3A;       /* 칠판 녹색 */

  --radius-sm:    4px;
  --radius-md:    8px;
  --radius-lg:    12px;

  --trans:        0.18s ease;
  --font:         'Noto Sans KR', sans-serif;

  /* 크래프트 종이 노이즈 텍스처 (SVG 인라인) */
  --texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

html { font-family: var(--font); font-size: 15px; }
body {
  background-color: var(--bg-base);
  background-image: var(--texture);
  color: var(--text-primary);
  min-height: 100vh;
  letter-spacing: -0.2px;
}

/* ---------- 레이아웃 ---------- */
.app-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ---------- 헤더 ---------- */
.app-header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.header-icon {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 12px;
  opacity: 0.7;
}
.app-header h1 {
  font-size: 1.6rem;
  font-weight: 300;       /* MUJI 특유의 가는 제목 */
  color: var(--text-primary);
  letter-spacing: 8px;    /* 넓은 자간 */
  text-transform: none;
}
.header-sub {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 300;
  letter-spacing: 3px;
}

/* ---------- 2단 레이아웃 ---------- */
.main-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

/* ---------- 입력 패널 ---------- */
.input-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-second);
  letter-spacing: 2px;
}
.student-count {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 1px;
}

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

/* 이름 그리드 */
.name-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.name-grid::-webkit-scrollbar { width: 3px; }
.name-grid::-webkit-scrollbar-track { background: transparent; }
.name-grid::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.name-item {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  transition: border-color var(--trans);
}
.name-item:focus-within {
  border-color: var(--accent-light);
}
.name-num {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 400;
  min-width: 16px;
  text-align: right;
}
.name-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8rem;
  width: 100%;
}
.name-input::placeholder { color: var(--text-muted); }

/* 셔플 영역 */
.shuffle-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-weight: 400;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--trans);
  letter-spacing: 1px;
}
.btn-icon { font-size: 0.95em; }

/* 기본 버튼 — 브라운 */
.btn-primary {
  background: var(--accent);
  color: #FAF9F5;
  padding: 11px 18px;
  font-size: 0.82rem;
  border: 1px solid var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* 보조 버튼 — 라인 */
.btn-secondary {
  background: transparent;
  color: var(--text-second);
  padding: 9px 18px;
  font-size: 0.8rem;
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  border-color: var(--accent-light);
  color: var(--accent);
}

/* 고스트 버튼 */
.btn-ghost {
  background: var(--bg-input);
  color: var(--text-second);
  padding: 6px 10px;
  font-size: 0.74rem;
  border: 1px solid var(--border);
  flex: 1;
}
.btn-ghost:hover {
  border-color: var(--accent-light);
  color: var(--accent);
  background: var(--bg-panel);
}
.btn-sm { font-size: 0.72rem; }

.btn-outline {
  background: transparent;
  color: var(--text-second);
  padding: 9px 20px;
  font-size: 0.78rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 교실 패널 ---------- */
.classroom-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.classroom-container {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* 칠판 */
.blackboard {
  width: 100%;
  background: var(--blackboard-bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  color: rgba(255,255,255,0.65);
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 4px;
}

/* 자리 그리드 — 행별 flex 구조 */
.seat-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* 행 단위 컨테이너 */
.seat-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 행 내부 자리들 */
.seat-row-inner {
  display: flex;
  gap: 0;
  align-items: stretch;
}

/* 각 자리 */
.seat {
  background: var(--bg-seat);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 5px;
  text-align: center;
  flex: 1;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 0 3px;
  transition: all var(--trans);
}
.seat.filled {
  background: var(--bg-seat-fill);
  border-color: var(--accent-light);
}
.seat.filled:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(139,115,85,0.15);
  cursor: default;
}

/* 팝 인 애니메이션 */
@keyframes seatPop {
  0%   { transform: scale(0.85); opacity: 0; }
  65%  { transform: scale(1.03); }
  100% { transform: scale(1);    opacity: 1; }
}
.seat.pop {
  animation: seatPop 0.32s ease both;
}

.seat-num {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
}
.seat-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.25;
  word-break: keep-all;
}

/* 쌍 사이 통로 */
.aisle {
  width: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.aisle-dot {
  width: 2px;
  height: 2px;
  background: var(--border-strong);
  border-radius: 50%;
}

/* 행 레이블 */
.row-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-label-text {
  font-size: 0.64rem;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 2px;
  white-space: nowrap;
}
.row-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* 교실 하단 */
.classroom-footer {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}
.door-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  letter-spacing: 1px;
  font-weight: 300;
}

.classroom-actions {
  display: flex;
  justify-content: flex-end;
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--accent);
  color: #FAF9F5;
  padding: 10px 22px;
  border-radius: 2px;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 999;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 반응형 ---------- */
@media (max-width: 900px) {
  .main-layout { grid-template-columns: 1fr; }
  .name-grid   { max-height: 220px; }
  .seat        { min-height: 48px; padding: 7px 4px; }
  .seat-name   { font-size: 0.75rem; }
  .app-header h1 { letter-spacing: 4px; font-size: 1.3rem; }
}

/* ---------- 인쇄 ---------- */
@media print {
  body { background: #fff; }
  .input-panel,
  .classroom-actions,
  .toast { display: none !important; }
  .main-layout { grid-template-columns: 1fr; }
  .classroom-container {
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: none;
  }
  .seat.filled {
    background: #f0ede7;
    border-color: #8B7355;
  }
  .seat-name { color: #333; }
}
