/* ============================================================
   SeatChange — 페이지 전용 스타일
   theme.css의 토큰만 쓰고 새 색을 만들지 않는다.
   inset-group / icon-action / sw는 design-reference의 공용 패턴을
   그대로 가져온 것 — 규격이 바뀌면 그쪽을 기준으로 맞춘다.
   ============================================================ */

.wrap { max-width: 780px; margin: 0 auto; padding: 16px 16px 120px; }
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}

/* ---- 공용 패턴 (design-reference/reference.html 발췌) ---- */
.icon-action {
  width: 34px; height: 34px; border-radius: 50%; border: none; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--sub); flex-shrink: 0;
  font-size: 1.15rem; line-height: 1; transition: background 0.15s, color 0.15s;
}
.icon-action:hover { background: var(--glass); color: var(--text); }
.icon-action.danger { color: var(--danger); }
.icon-action.danger:hover { background: var(--danger-light); }

.inset-group { background: var(--glass-strong); border-radius: var(--radius); overflow: hidden; }
.inset-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 48px; position: relative; }
.inset-row + .inset-row::before {
  content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--hairline);
}
.inset-row .row-label { font-size: 0.92rem; color: var(--text); flex-shrink: 0; min-width: 88px; }
.inset-row select { flex: 1; border: none; background: none; font-family: inherit; font-size: 0.92rem;
  color: var(--text); text-align: right; outline: none; min-width: 0; }
.inset-row .row-sub { font-size: 0.78rem; color: var(--text-3); margin-top: 2px; }
.row-sub { font-size: 0.78rem; color: var(--text-3); line-height: 1.5; }

/* ---- iOS 스타일 스위치 ---- */
.sw { width: 44px; height: 26px; border-radius: var(--radius-pill); background: var(--glass); border: 1px solid var(--border-card);
      cursor: pointer; position: relative; flex-shrink: 0; margin-left: auto; transition: background var(--dur) var(--ease); }
.sw.on { background: var(--accent); border-color: transparent; }   /* 색 = 상태 */
.sw::after { content:''; position:absolute; top:2px; left:2px; width:20px; height:20px; border-radius:50%;
             background:#fff; box-shadow:0 1px 3px rgba(0,0,0,0.3); transition: transform var(--dur) var(--ease); }
.sw.on::after { transform: translateX(18px); }

/* ---- 명단 칩 (짝 금지 목록 등에서 재사용) ---- */
.roster { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 6px 5px 12px;
  background: var(--glass); border: 1px solid var(--border-card); border-radius: var(--radius-pill);
  font-size: 0.86rem; font-weight: 600;
}
.chip .x { width: 20px; height: 20px; border: none; background: none; cursor: pointer; color: var(--text-3);
           display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; padding: 0; }
.chip .x:hover { background: var(--danger-light); color: var(--danger); }
.empty { font-size: 0.86rem; color: var(--text-3); padding: 6px 0; }

/* ---- 방 제목 바 ---- */
.roombar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.roombar .inp { flex: 1; font-weight: 700; }
.view-title { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }

/* ---- 교실 보드: 이게 메인 화면이다 ---- */
.boardcard { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.blackboard {
  text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--text-3);
  letter-spacing: 0.1em; padding: 9px; margin-bottom: 16px;
  border: 1px dashed var(--hairline); border-radius: var(--radius-sm);
}
.board { overflow-x: auto; padding: 4px; }
.grid { display: grid; gap: 8px; justify-content: center; min-width: max-content; margin: 0 auto; touch-action: none; }

.seat {
  width: 76px; height: 58px; border-radius: var(--radius-sm);
  background: var(--glass-strong); border: 1px solid var(--border-card);
  box-shadow: var(--highlight), var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 4px; text-align: center; cursor: pointer; position: relative;
  transition: transform 0.12s var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.seat:hover { transform: translateY(-1px); box-shadow: var(--highlight), var(--shadow); }
.seat .nm { font-size: 0.88rem; font-weight: 700; letter-spacing: -0.01em; word-break: keep-all; line-height: 1.25; }
.seat .no { font-size: 0.62rem; color: var(--text-3); font-variant-numeric: tabular-nums; margin-top: 2px; }
.seat.landing { animation: land 0.42s var(--ease); }
@keyframes land { 0% { transform: scale(0.7); opacity: 0; } 60% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }

/* 빈 칸 — 편집 모드에서만 보이는 "+ 추가" 자리 */
.seat.empty-slot {
  background: transparent; border: 1.5px dashed var(--hairline); box-shadow: none;
  color: var(--text-3); font-size: 1.3rem; font-weight: 300;
}
.seat.empty-slot:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* 편집 모드가 아닐 때의 빈 칸(통로) — 자리만 차지하고 안 보인다 */
.seat.gap { visibility: hidden; pointer-events: none; box-shadow: none; }

/* 배치는 됐지만 이 책상엔 아무도 안 앉은 경우 (학생보다 책상이 많을 때) */
.seat.spare { opacity: 0.4; cursor: default; box-shadow: none; }
.seat.spare:hover { transform: none; }

/* 뷰어가 배치 전 상태를 볼 때 — 눌러도 아무 일도 안 일어난다 */
.seat.preview { background: var(--glass); box-shadow: none; cursor: default; }
.seat.preview:hover { transform: none; box-shadow: none; }

/* 드래그로 옮기는 중 */
.seat.dragging { opacity: 0.35; }
.seat.drop-target { outline: 2px solid var(--accent); outline-offset: -1px; }

/* 삭제 버튼 — 책상 우상단, 편집 모드에서만 */
.seat .seat-del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--border-card); background: var(--bg-elevated); color: var(--text-3);
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  box-shadow: var(--shadow-sm); opacity: 0; transition: opacity 0.15s;
}
.seat:hover .seat-del, .seat:focus-within .seat-del { opacity: 1; }
.seat .seat-del:hover { background: var(--danger-light); color: var(--danger); border-color: transparent; }

/* 배치 완료 후 — 아직 안 누른 책상은 비워둔다 (몰래 배정의 핵심) */
.seat.blank { cursor: pointer; }
.seat.blank::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); opacity: 0.5;
}

/* ---- 보드 하단 편집 툴바 ---- */
.boardtools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px;
              padding-top: 14px; border-top: 1px solid var(--hairline); }
.boardtools .bt-label { font-size: 0.78rem; font-weight: 700; color: var(--sub); }
.boardtools .icon-action { width: 28px; height: 28px; background: var(--glass); border: 1px solid var(--border-card); }
.boardtools .bt-hint { font-size: 0.76rem; color: var(--text-3); margin-left: auto; }

/* ---- 하단 고정 액션 바 ---- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
  display: flex; gap: 10px; justify-content: center; align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--glass-nav); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--hairline);
}

/* ---- 전체화면(프로젝터) 모드 — 같은 보드를 확대해서 보여줄 뿐, 별도 화면이 아니다 ----
   actionbar는 절대 숨기지 않는다 — 네이티브 Fullscreen API가 막힌 환경(관리형
   브라우저, iframe 등)에서는 이 버튼이 유일한 탈출구라, 숨기면 새로고침 말고는
   빠져나올 방법이 없는 함정이 된다. */
body.projector .wrap > *:not(.boardcard) { display: none; }
body.projector .boardcard { position: fixed; inset: 0; z-index: 400; margin: 0; border-radius: 0;
  display: flex; flex-direction: column; justify-content: center; background: var(--bg); background-attachment: fixed; }
body.projector .boardtools { display: none; }
body.projector .actionbar { z-index: 401; background: var(--glass-nav); }
body.projector .seat { width: 108px; height: 80px; }
body.projector .seat .nm { font-size: 1.15rem; }
body.projector .blackboard { font-size: 0.9rem; padding: 14px; }

.banner { font-size: 0.84rem; padding: 10px 14px; border-radius: var(--radius-sm);
          background: var(--danger-light); color: var(--danger); font-weight: 600; margin-bottom: 12px; }
.banner.warn { background: var(--accent-light); color: var(--accent); }

/* ---- 이름 공개 오버레이 ---- */
.reveal {
  position: fixed; inset: 0; z-index: 600; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; cursor: pointer;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: saturate(180%) blur(28px); -webkit-backdrop-filter: saturate(180%) blur(28px);
  opacity: 0; transition: opacity 0.22s var(--ease);
}
.reveal.show { opacity: 1; }
.reveal-name { font-size: clamp(2.4rem, 10vw, 5.5rem); font-weight: 900; letter-spacing: -0.04em; text-align: center; }
.reveal-hint { font-size: 0.82rem; color: var(--sub); font-weight: 600; }

/* ---- 설정 패널 (슬라이드 오버) ---- */
.scrim { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.28);
         opacity: 0; transition: opacity var(--dur) var(--ease); }
.scrim.show { opacity: 1; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 310; width: min(400px, 100vw);
  background: var(--surface); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-lg); border-left: 1px solid var(--border-card);
  transform: translateX(100%); transition: transform var(--dur) var(--ease);
  display: flex; flex-direction: column;
}
.panel.show { transform: translateX(0); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px;
              border-bottom: 1px solid var(--hairline); font-weight: 800; font-size: 1rem; flex-shrink: 0; }
.panel-body { overflow-y: auto; padding: 16px 18px calc(100px + env(safe-area-inset-bottom)); flex: 1; }
.panel-section { margin-bottom: 22px; }
.panel-h { font-size: 0.82rem; font-weight: 700; color: var(--sub); margin-bottom: 10px; }
.panel-h .hint { font-weight: 400; color: var(--text-3); margin-left: 6px; }

.roster-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.roster-row + .roster-row { border-top: 1px solid var(--hairline); }
.roster-row .rr-name { flex: 1; font-size: 0.9rem; font-weight: 600; }
.roster-row select { font-family: inherit; font-size: 0.82rem; color: var(--text-2); background: var(--glass);
  border: 1px solid var(--border-card); border-radius: var(--radius-pill); padding: 4px 10px; outline: none; }

/* 두 hidden 클래스 다 쓰인다: [hidden]은 항상 안 보이고, .hidden은 트랜지션 대상에 쓴다. */
[hidden] { display: none !important; }
.hidden { display: none !important; }

@media print {
  .nav, .actionbar, .noprint, .boardtools, .banner { display: none !important; }
  body { background: #fff !important; }
  .wrap { padding: 0; max-width: none; }
  .boardcard, .card { background: none; box-shadow: none; border: none; padding: 0; }
  .seat { box-shadow: none; background: none; border: 1px solid #bbb; break-inside: avoid; }
  .seat .seat-del, .seat.empty-slot { display: none; }
}

/* 하단 액션바가 있는 화면이라 토스트를 그 위로 올린다 — 겹치면 버튼이 가려진다. */
.toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---- 읽기 전용 뷰(공유받은 좌석표) ---- */
body.readonly .edit-only { display: none !important; }
body.readonly .view-title { display: block !important; }

/* ---- 설계 중 vs 배치 완료 (소유자에게만 의미 있음, edit-only의 하위 상태) ---- */
body.arranged .pre-arrange { display: none !important; }
body:not(.arranged) .post-arrange { display: none !important; }

/* 첫 로딩 동안 조작을 막는다 — Firestore 응답 전에 누른 액션이 유실되는 것을 방지. */
body.loading .actionbar button { pointer-events: none; opacity: 0.5; }
