/* ============================================================
   집계표 앱 전용 컴포넌트

   ⚠️ 데모킷(COMPONENTS.md)에 없는 것만 여기에 둔다.
   토큰만 사용 — hex/임의 radius/임의 간격 금지.
   자주 쓰이게 되면 solve-us demo-kit.css 로 승격 후 여기서 제거할 것.
   ============================================================ */

/* ── 셸 보강 ───────────────────────────────────────────
   킷의 .demo-shell 은 단순 블록이라, 내용이 짧으면 하단 액션바가
   화면 바닥이 아니라 콘텐츠 바로 밑에 떠 버린다. 세로 플렉스로 바꿔
   main 이 남는 높이를 먹게 한다. (킷 파일은 건드리지 않는다) */
.demo-shell {
  display: flex;
  flex-direction: column;
}
.demo-shell > main {
  flex: 1 0 auto;
}
/* 하단 탭바 대신 t-bottombar 를 쓰므로 킷의 탭바 여백은 불필요 */
.demo-shell > main.su-content {
  padding-bottom: var(--space-6);
}

/* ── 폼 ───────────────────────────────────────────────── */
.t-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.t-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
}
.t-input,
.t-select {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  color: var(--color-text-primary);
}
.t-input:focus,
.t-select:focus {
  outline: none;
  border-color: var(--color-ash-rose);
  box-shadow: 0 0 0 3px var(--color-ring-primary);
}
.t-input::placeholder {
  color: var(--color-mid-grey);
}
.t-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #8a7f76 50%),
    linear-gradient(135deg, #8a7f76 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.t-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ── 세그먼트 (실측 / 전달받음) ────────────────────────── */
.t-seg {
  display: flex;
  background: var(--color-tint-greige);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  gap: var(--space-1);
}
.t-seg button {
  flex: 1;
  height: 38px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  font-family: var(--font-family);
  color: var(--color-mid-grey);
  cursor: pointer;
}
.t-seg button[aria-pressed='true'] {
  background: var(--color-white);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-subtle);
}

/* ── 접이식 기구 그룹 ──────────────────────────────────── */
.t-group {
  background: var(--color-white);
  border: 1px solid var(--color-light-grey);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  overflow: hidden;
}
.t-group + .t-group {
  margin-top: var(--space-3);
}
.t-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-family);
  text-align: left;
}
.t-group-name {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}
.t-group-sum {
  margin-left: auto;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-ash-rose);
}
.t-group-sum--zero {
  color: var(--color-light-grey);
  font-weight: 500;
}
.t-caret {
  color: var(--color-mid-grey);
  display: flex;
  transition: transform var(--transition-fast);
}
.t-group[data-open='true'] .t-caret {
  transform: rotate(90deg);
}
.t-group-body {
  padding: 0 var(--space-4) var(--space-4);
}
.t-group[data-open='false'] .t-group-body {
  display: none;
}

/* ── 카운터 그리드 ─────────────────────────────────────── */
.t-grid {
  display: grid;
  gap: var(--space-2);
  align-items: center;
}
.t-grid--1 {
  grid-template-columns: 1fr 148px;
}
.t-grid--2 {
  grid-template-columns: 62px 1fr 1fr;
}
.t-colhead {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-mid-grey);
  text-align: center;
  letter-spacing: 0.02em;
}
.t-rowlabel {
  font-size: var(--font-size-xs);
  color: var(--color-mid-grey);
  line-height: 1.3;
}
.t-rowlabel--on {
  color: var(--color-text-primary);
  font-weight: 600;
}

.t-counter {
  display: flex;
  align-items: center;
  background: var(--color-off-white);
  border: 1px solid var(--color-light-grey);
  border-radius: var(--radius-md);
  height: 44px;
  overflow: hidden;
}
.t-counter--on {
  background: var(--color-white);
  border-color: var(--color-ash-rose);
}
.t-counter button {
  width: 40px;
  height: 100%;
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  font-family: var(--font-family);
  color: var(--color-charcoal);
  display: flex;
  align-items: center;
  justify-content: center;
}
.t-counter button:disabled {
  color: var(--color-light-grey);
  cursor: default;
}
.t-counter input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  background: none;
  text-align: center;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-mid-grey);
  appearance: textfield;
  -moz-appearance: textfield;
}
.t-counter--on input {
  color: var(--color-text-primary);
}
.t-counter input:focus {
  outline: none;
}
.t-counter input::-webkit-outer-spin-button,
.t-counter input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 세면기 규격 펼치기 */
.t-advtoggle {
  margin-top: var(--space-3);
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-family);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-mid-grey);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.t-advnote {
  margin-top: var(--space-2);
  font-size: 11.5px;
  color: var(--color-mid-grey);
  line-height: 1.45;
}

/* ── 총계 바 (sticky) ──────────────────────────────────── */
.t-totalsbar {
  position: sticky;
  top: 56px;
  z-index: var(--z-header);
  background: var(--color-background);
  padding: 0 18px var(--space-3);
  border-bottom: 1px solid var(--color-light-grey);
}
.t-totals {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.t-totals::-webkit-scrollbar {
  display: none;
}
.t-total {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
  background: var(--color-white);
  border: 1px solid var(--color-light-grey);
  border-radius: 999px;
  padding: 5px var(--space-3);
}
.t-total-k {
  font-size: 11.5px;
  color: var(--color-mid-grey);
}
.t-total-v {
  font-size: 14px;
  font-weight: 800;
  color: var(--color-ash-rose);
  letter-spacing: -0.02em;
}
.t-totals-empty {
  font-size: 12.5px;
  color: var(--color-mid-grey);
}

/* ── 장소 리스트 ───────────────────────────────────────── */
.t-floor {
  margin-top: var(--space-5);
}
.t-floor:first-child {
  margin-top: 0;
}
.t-floorhead {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.t-floorname {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}
.t-floorcount {
  font-size: 11.5px;
  color: var(--color-mid-grey);
}
.t-floorcopy {
  margin-left: auto;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 3px var(--space-2);
  font-family: var(--font-family);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-charcoal);
  cursor: pointer;
}

.t-place {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-white);
  border: 1px solid var(--color-light-grey);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-family);
}
.t-place + .t-place {
  margin-top: var(--space-2);
}
.t-place-main {
  flex: 1;
  min-width: 0;
}
.t-place-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.t-place-sum {
  font-size: 11.5px;
  color: var(--color-mid-grey);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t-place-chev {
  color: var(--color-light-grey);
  flex-shrink: 0;
  display: flex;
}

/* 누락 힌트 */
.t-hint {
  margin-top: var(--space-2);
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--color-warning);
}

/* 이름 추천 칩 */
.t-chiprow {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.t-namechip {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 5px var(--space-3);
  font-family: var(--font-family);
  font-size: 12.5px;
  color: var(--color-charcoal);
  cursor: pointer;
}

/* ── 하단 액션 바 ─────────────────────────────────────── */
.t-bottombar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-tab-bar);
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) 18px;
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  background: var(--color-white);
  border-top: 1px solid var(--color-light-grey);
}
.t-bottombar .su-cta,
.t-bottombar .su-btn-secondary {
  height: 48px;
  box-shadow: none;
}

/* ── JSON 내보내기 ─────────────────────────────────────── */
.t-json {
  width: 100%;
  min-height: 260px;
  padding: var(--space-3);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-charcoal);
  resize: vertical;
}

/* ── 모달 (층 복제) ────────────────────────────────────── */
.t-modal-bg {
  position: fixed;
  inset: 0;
  background: var(--color-overlay-strong);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.t-modal {
  width: 100%;
  max-width: var(--mobile-max-width);
  background: var(--color-white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-6) var(--space-5);
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.t-floorpick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.t-floorpick button {
  min-width: 52px;
  height: 42px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-charcoal);
  cursor: pointer;
}
.t-floorpick button[aria-pressed='true'] {
  background: var(--color-ash-rose);
  border-color: var(--color-ash-rose);
  color: var(--color-white);
}

/* ── 기타 ─────────────────────────────────────────────── */
.t-empty {
  text-align: center;
  padding: var(--space-10) var(--space-5);
  color: var(--color-mid-grey);
  font-size: var(--font-size-xs);
  line-height: 1.6;
}
.t-danger {
  background: none;
  border: none;
  font-family: var(--font-family);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-error);
  cursor: pointer;
  padding: var(--space-2);
}
.t-meta {
  font-size: 11.5px;
  color: var(--color-mid-grey);
  line-height: 1.5;
}
