/*
 * PEAR 체험용 쇼핑몰 화면. 외부 주소에서 글꼴·라이브러리를 받지 않는다.
 * - 색은 PEAR 관리 화면(admin-web/src/styles.css)과 같은 "배 그린"이다. 주 색 #3f7d20은 흰 글자와의 대비가 5:1이다.
 * - 글꼴은 이 폴더의 fonts/PretendardVariable.woff2(SIL OFL 1.1, fonts/LICENSE-Pretendard.txt)를 쓴다.
 */
@font-face {
  font-family: 'Pretendard Variable';
  font-style: normal;
  font-weight: 45 920;
  font-display: swap;
  src: url('fonts/PretendardVariable.woff2') format('woff2-variations');
}

:root {
  --bg: #f6f8f3;
  --panel: #ffffff;
  --panel-muted: #f8faf6;
  --text: #1f2723;
  --text-soft: #47524a;
  --muted: #6a746d;
  --line: #e2e7de;
  --line-soft: #edf1ea;
  --brand: #3f7d20;
  --brand-hover: #39711d;
  --brand-dark: #32641a;
  --brand-weak: #ecf2e9;
  --accent: #8cc152;
  --ok: #2b7a2f;
  --ok-weak: #e7f3e5;
  --warn: #8a5a00;
  --warn-weak: #fcf1dc;
  --bad: #b3261e;
  --bad-weak: #fbe9e7;
  --info: #2a5db0;
  --info-weak: #e8effb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(31 39 35 / 4%), 0 1px 3px rgb(31 39 35 / 4%);
  --shadow-raised: 0 12px 32px rgb(31 39 35 / 12%), 0 2px 6px rgb(31 39 35 / 6%);
  --focus: 0 0 0 3px rgb(63 125 32 / 18%);
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI',
    'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: #d9e5d2; }

h2 { margin: 0 0 6px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
h2 small, h3 small { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; letter-spacing: 0; }
h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 700; }
h4 { margin: 8px 0 4px; font-size: 12px; color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: 12px; }
.space { margin-top: 18px; }

/* ── 입력 ─────────────────────────────── */

button, select, input {
  font: inherit;
  color: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
button:hover { border-color: #c9d1c5; background: var(--panel-muted); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--panel-muted); }
button.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand-dark);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

input, select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: var(--panel);
}
input[type="number"] { width: 110px; }

/* ── 위쪽 ─────────────────────────────── */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.logo { display: block; flex: none; }

/* 회원·등급·채널: 체험용으로 화면에서 고르는 값을 한 덩어리로 묶는다 */
.member {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 6px 12px;
  background: var(--panel-muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
}
.member label { display: flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 13px; font-weight: 600; }
.member input { width: 96px; padding: 4px 10px; border-radius: 999px; }
.member select { padding: 4px 8px; border-radius: 999px; }
.quick { display: inline-flex; gap: 4px; }
.quick button { padding: 3px 10px; font-size: 12px; border-radius: 999px; }
.quick button.active { background: var(--brand-weak); border-color: var(--brand); color: var(--brand-dark); }

.admin-link {
  margin-left: auto;
  padding: 7px 14px;
  color: var(--brand-dark);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.admin-link:hover { background: var(--brand-weak); border-color: var(--brand-weak); }

/* 화면이 좁으면 로고 밑 설명을 숨겨 위쪽 막대가 한 줄에 들어가게 한다 */
@media (max-width: 1200px) {
  .brand small { display: none; }
}

/* 체험 순서: 번호가 붙은 알약 */
.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 7px 16px 7px 8px;
  background: none;
  color: var(--text-soft);
  white-space: nowrap;
}
.tabs button:hover { background: var(--panel-muted); }
.tabs .step {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--line-soft);
  border-radius: 50%;
}
.tabs button[aria-selected="true"] { background: var(--brand-weak); color: var(--brand-dark); }
.tabs button[aria-selected="true"] .step { background: var(--brand); color: #fff; }

/* ── 배치 ─────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  align-items: start;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 40px; }
  .topbar, .tabs { padding-left: 16px; padding-right: 16px; }
  .admin-link { margin-left: 0; }
}
main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.tab-panel { display: flex; flex-direction: column; gap: 18px; }
.tab-panel[hidden] { display: none; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-head h2 { margin: 0; }
.row { display: inline-flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.sub { color: var(--muted); font-size: 12px; }
.empty {
  margin: 8px 0;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: var(--panel-muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.ok { color: var(--ok); }
.error {
  background: var(--bad-weak);
  color: var(--bad);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions.sticky {
  position: sticky;
  bottom: 0;
  margin: 0;
  padding: 12px 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  z-index: 2;
}
.actions.sticky button { padding: 10px 18px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.stack label { display: flex; align-items: center; gap: 8px; color: var(--text-soft); font-weight: 600; font-size: 13px; }
.stack label input:not([type="number"]) { width: 220px; }
ul.plain { margin: 4px 0; padding-left: 18px; }
ul.plain li { margin: 2px 0; }

/* ── 쿠폰(표 모양 카드) ───────────────── */

.coupon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.coupon {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  padding: 16px 16px 14px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
/* 왼쪽 띠: 쿠폰 표의 잘리는 쪽 */
.coupon::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--accent);
}
.coupon.disabled { background: var(--panel-muted); color: var(--muted); }
.coupon.disabled::before { background: #c9d1c5; }
.coupon-benefit { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; color: var(--brand-dark); }
.coupon.disabled .coupon-benefit { color: var(--muted); }
.coupon-name { font-weight: 600; }
.coupon-meta { color: var(--muted); font-size: 12px; }
.coupon-foot {
  align-self: stretch;
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.chip { margin: 0 6px 6px 0; padding: 4px 12px; border-radius: 999px; font-size: 12px; }

.pick {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 8px;
  cursor: pointer;
}
.pick:hover { background: var(--panel-muted); }
.pick:last-child { border-bottom: 0; }
.pick input { margin-top: 4px; accent-color: var(--brand); }
.pick.unavailable strong { color: var(--muted); }
.reason { color: var(--warn); font-size: 12px; margin-left: 4px; }
.point-input { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--text-soft); font-weight: 600; font-size: 13px; }

.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 30px; height: 30px; padding: 0; border-radius: 50%; font-size: 16px; line-height: 1; }
.stepper span { min-width: 20px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── 상품 ─────────────────────────────── */

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.product {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.product.in-cart { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.product-top { display: flex; align-items: center; gap: 12px; }
.product-thumb {
  display: grid;
  flex: none;
  place-items: center;
  width: 46px;
  height: 46px;
  font-size: 18px;
  font-weight: 800;
  border-radius: 12px;
  color: var(--brand-dark);
  background: var(--brand-weak);
}
.product-thumb.tone-shoes { color: #1d4f91; background: #e7effa; }
.product-thumb.tone-goods { color: #7a4b00; background: #fcf1dc; }
.product-name { font-weight: 700; }
.product-key { display: block; color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.product-price { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cat {
  align-self: flex-start;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--panel-muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
}

/* ── 표 ─────────────────────────────── */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--line-soft); padding: 9px 10px; text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; background: var(--panel-muted); }
.table th:first-child { border-top-left-radius: 8px; }
.table th:last-child { border-top-right-radius: 8px; }
.table tbody tr:hover td { background: #fbfcfa; }
/* 숫자 열은 머리글도 값과 같은 오른쪽에 맞춘다 */
.table.numbers th:nth-child(n + 3),
.table.numbers td:nth-child(n + 3) { text-align: right; font-variant-numeric: tabular-nums; }
.table .qty { width: 70px; }
/* 식별자·금액·시각은 줄을 바꾸지 않는다. 표가 넓으면 옆으로 민다 */
.table td { word-break: keep-all; }
.table .mono, .table strong { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #eef1eb;
  color: var(--muted);
  white-space: nowrap;
}
.badge.ISSUED, .badge.CONFIRMED { background: var(--ok-weak); color: var(--ok); }
.badge.RESERVED, .badge.HELD { background: var(--info-weak); color: var(--info); }
.badge.USED, .badge.PARTIALLY_CANCELED { background: var(--warn-weak); color: var(--warn); }
.badge.EXPIRED, .badge.REVOKED, .badge.RELEASED, .badge.CANCELED { background: #eef1eb; color: var(--muted); }
.badge.info { background: var(--info-weak); color: var(--info); }

/* ── 금액 ─────────────────────────────── */

.amounts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.amounts div { background: var(--panel-muted); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.amounts dt { color: var(--muted); font-size: 12px; }
.amounts dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.amounts dd.minus { color: var(--bad); }
.amounts .total { background: var(--brand-weak); border-color: #d9e5d2; }
.amounts .total dd { color: var(--brand-dark); font-size: 20px; font-weight: 800; }
.amounts.small .total dd { font-size: 16px; }
.countdown { margin-left: 8px; color: var(--info); font-size: 13px; font-weight: 600; }
.claim { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0; }
.claim-head { display: flex; align-items: center; gap: 8px; }

/* ── 잔액 ─────────────────────────────── */

.balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.balance { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.balance-amount { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.plus { color: var(--ok); }
.minus { color: var(--bad); }
.zero { color: var(--muted); }

/* ── PEAR 호출 기록 ─────────────────── */

.calls {
  position: sticky;
  top: 16px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.call-list { list-style: none; margin: 0; padding: 0; }
.call { border-left: 3px solid var(--line); margin: 8px 0; padding: 2px 0 2px 10px; }
.call.ok { border-left-color: var(--ok); }
.call.warn { border-left-color: #d29a1a; }
.call.bad { border-left-color: var(--bad); }
.call summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline; }
.call .method { font-family: var(--mono); font-size: 11px; font-weight: 700; }
.call .path { font-family: var(--mono); font-size: 12px; word-break: break-all; flex: 1 1 180px; }
.call .status { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.call.ok .status { color: var(--ok); }
.call.warn .status { color: var(--warn); }
.call.bad .status { color: var(--bad); }
.call .meta { color: var(--muted); font-size: 11px; width: 100%; }
.call pre {
  background: #17201b;
  color: #e4ebe2;
  border-radius: 10px;
  padding: 10px;
  font-size: 11px;
  overflow-x: auto;
  max-height: 320px;
  margin: 0 0 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(640px, calc(100vw - 32px));
  padding: 11px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow-raised);
  background: var(--text);
  color: #fff;
  font-weight: 600;
  z-index: 10;
}
.toast.bad { background: var(--bad); }
.toast.warn { background: var(--warn); }
.toast.ok { background: var(--brand-dark); }
