/*
 * styles.css — 동백점 조리완료 보드
 * 직원 패드(입력)와 고객 패드(표시) 두 화면을 한 파일로 꾸민다.
 */

:root {
  --brand: #c8102e;        /* 파파존스 레드 */
  --brand-dark: #a50d25;
  --go: #2e7d32;           /* 픽업완료(초록) */
  --go-dark: #1b5e20;
  --ink: #1c1c1c;
  --muted: #6b6b6b;
  --line: #e4e2dd;
  --surface: #ffffff;
  --ground: #f4f2ee;
  --radius: 20px;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: var(--ink);
  background: var(--ground);
  -webkit-text-size-adjust: none;
  /* 패드는 손가락으로만 쓴다 — 밀 때 글자 선택·이미지 끌림을 막는다. (키오스크에서 배운 것) */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

img { -webkit-user-drag: none; }

#app { height: 100%; }

#app.booting {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 20px;
}

/* ── 공통 헤더 ─────────────────────────────── */
.hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 24px 18px;
  background: var(--brand);
  color: #fff;
}
.hdr-title { font-size: clamp(22px, 4vw, 34px); font-weight: 800; letter-spacing: -0.01em; }
.hdr-sub { font-size: 13px; font-weight: 600; opacity: 0.85; letter-spacing: 0.08em; text-transform: uppercase; }
.hdr-right { display: flex; align-items: center; gap: 14px; }
.hdr-count { font-size: 15px; font-weight: 700; opacity: 0.9; }

/* 설정(역할 전환) — 눈에 잘 안 띄게, 길게 눌러야 열린다 */
.gear {
  width: 40px; height: 40px; flex: none;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff; font-size: 18px; cursor: pointer;
}

/* ══════════════════ 고객 화면(표시) ══════════════════ */
.display { display: flex; flex-direction: column; height: 100%; }
.display .hdr-title { font-size: clamp(26px, 5vw, 44px); }

.board {
  flex: 1;
  /* 스크롤 없이 전부 한 화면에 — 칸 수·글자 크기는 app.js 가 개수에 맞춰 정한다. */
  overflow: hidden;
  padding: 18px calc(16px + env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 18px) calc(16px + env(safe-area-inset-left, 0px));
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  grid-auto-rows: 1fr;
  gap: 14px;
}

.num-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 0;
  min-width: 0;
  padding: 8px;
  background: var(--surface);
  border: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.num-big {
  font-size: var(--num-size, clamp(60px, 15vw, 140px));
  font-weight: 800;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1;
}
.num-elapsed {
  font-size: max(12px, calc(var(--num-size, 40px) * 0.22));
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
}

/* 새로 뜬 번호 — 잠깐 강조(깜빡) */
@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes flash {
  0%, 100% { background: var(--surface); color: var(--brand); }
  25%, 75% { background: var(--brand); color: #fff; }
}
.num-card.is-new { animation: pop 0.4s ease-out, flash 1.4s ease-in-out 0.4s 2; }

/* 아무것도 없을 때 */
.board-empty {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}
.board-empty-mark { font-size: clamp(60px, 12vw, 120px); font-weight: 800; color: var(--line); letter-spacing: 0.1em; }
.board-empty-text { font-size: clamp(18px, 3vw, 26px); font-weight: 600; }

/* 소리 켜기 안내(최초 1회 탭) — 브라우저는 탭 전엔 소리를 막는다 */
.tap-gate {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  background: var(--brand);
  color: #fff;
  z-index: 50;
  cursor: pointer;
  text-align: center;
  padding: 24px;
}
.tap-gate-big { font-size: clamp(28px, 6vw, 52px); font-weight: 800; }
.tap-gate-sub { font-size: clamp(16px, 3vw, 22px); font-weight: 600; opacity: 0.9; }
.tap-gate-icon { font-size: clamp(60px, 12vw, 110px); }

/* ══════════════════ 직원 화면(입력) ══════════════════ */
.staff { display: flex; flex-direction: column; height: 100%; }

.staff-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}

/* 입력 영역 */
.entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.entry-screen {
  height: 90px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--ground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
}
.entry-screen.is-empty { color: #bdbab4; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.key:active { background: var(--ground); }
.key-wide { grid-column: span 1; font-size: 20px; }

.btn-confirm {
  height: 76px;
  border: none;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  cursor: pointer;
}
.btn-confirm:disabled { background: #d9b5bb; cursor: default; }
.btn-confirm:active:not(:disabled) { background: var(--brand-dark); }

/* '번호 생성' 큰 버튼 — 평소 직원 화면 맨 위 */
.btn-create {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; height: 92px;
  border: none; border-radius: var(--radius);
  background: var(--brand); color: #fff;
  font-size: 28px; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow);
}
.btn-create:active { background: var(--brand-dark); }
.btn-create-plus { font-size: 36px; font-weight: 800; line-height: 1; }

/* 키패드 모달 */
.entry-sheet {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 20px;
}
.entry-sheet .entry { width: min(520px, 100%); max-height: 92vh; overflow-y: auto; }
.entry-head { text-align: center; }
.entry-title { font-size: 21px; font-weight: 800; color: var(--ink); }
.entry-actions { display: flex; gap: 10px; }
.entry-actions .btn-confirm { flex: 1; }
.btn-cancel {
  flex: none; width: 128px; height: 76px;
  border: none; border-radius: 16px;
  background: var(--ground); color: var(--ink);
  font-size: 20px; font-weight: 700; cursor: pointer;
}
.btn-cancel:active { background: #e6e3dd; }

/* 현재 조리완료 목록 — 세로화면에서 한눈에 많이 보이게 2열 그리드 */
.staff-list-title { font-size: 16px; font-weight: 700; color: var(--muted); padding: 4px 2px; }
.staff-list {
  display: grid;
  /* 세로화면 2열 — 번호와 픽업완료 버튼이 한 줄에 넉넉히 들어가게 */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 10px;
}

.staff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px 12px 20px;
}
.staff-row-main { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.staff-row-num {
  font-size: 40px;
  font-weight: 800;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  line-height: 1;
}
.staff-row-elapsed { font-size: 15px; font-weight: 600; color: var(--muted); }
.btn-done {
  flex: none;
  height: 56px;
  padding: 0 22px;
  border: none;
  border-radius: 14px;
  background: var(--go);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.btn-done:active { background: var(--go-dark); }

.staff-empty { grid-column: 1 / -1; color: var(--muted); font-size: 16px; text-align: center; padding: 24px; }

/* 토스트(짧은 안내) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateX(-50%);
  background: rgba(28, 28, 28, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* 연결 끊김 띠 */
.offline-bar {
  background: #8a6d00;
  color: #fff;
  text-align: center;
  padding: 8px;
  font-size: 14px;
  font-weight: 700;
}
.offline-bar[hidden] { display: none; }

/* 역할 선택(설정) 창 */
.role-sheet {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 70;
  padding: 24px;
}
.role-card {
  background: #fff; border-radius: 22px; padding: 24px;
  width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px;
}
.role-card h2 { margin: 0 0 4px; font-size: 22px; }
.role-btn {
  height: 72px; border: 2px solid var(--line); border-radius: 16px;
  background: #fff; font-size: 20px; font-weight: 700; cursor: pointer;
}
.role-btn.on { border-color: var(--brand); color: var(--brand); background: #fdf0f2; }
.role-close { height: 52px; border: none; border-radius: 14px; background: var(--ground); font-size: 16px; font-weight: 600; cursor: pointer; }
