/* ==========================================================================
   CON TII Liquor Finder — 사용자 검색 화면
   ========================================================================== */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 20px;
}

/* --------------------------------------------------------------------------
   헤더
   -------------------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--ink);
}

.brand-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--gold);
  white-space: nowrap;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.status-dot[data-state="ok"]::before {
  background: var(--down);
}

.status-dot[data-state="error"]::before {
  background: var(--up);
}

/* 헤더 오른쪽 묶음 — 상태 표시 + 관리자 링크 (IMPLEMENT-01A).
   헤더가 space-between 이라 묶지 않으면 상태 점이 가운데로 밀립니다. */
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: none;
}

/* 관리자 링크 — 보이되 손님용 버튼처럼 보이지 않게. navigation 이지
   인증이 아닙니다: href 는 admin.html 뿐이고 JS 가 붙지 않습니다. */
.header-admin-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: nowrap;
  line-height: 1.2;
}

.header-admin-link:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

/* --------------------------------------------------------------------------
   검색 영역
   -------------------------------------------------------------------------- */

.hero {
  padding: 44px 0 28px;
}

.hero-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}

.searchbar {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.searchbar-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.searchbar input[type="search"] {
  width: 100%;
  height: 52px;
  padding: 0 44px 0 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

.searchbar input[type="search"]::-webkit-search-cancel-button {
  appearance: none;
}

.searchbar input[type="search"]:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.searchbar input::placeholder {
  color: var(--muted);
}

.field-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
}

.field-clear:hover {
  background: var(--bg-sunken);
  color: var(--ink);
}

.searchbar-field[data-filled="true"] .field-clear {
  display: flex;
}

.btn-primary {
  flex: none;
  height: 52px;
  padding: 0 26px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.86;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: default;
}

/* --- 카테고리 칩 --- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
}

.chip {
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.13s ease;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.chip-count {
  font-size: 11px;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}

/* --- 옵션 --- */

.options {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
  cursor: pointer;
}

.options-hint {
  font-size: 12px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   결과 영역
   -------------------------------------------------------------------------- */

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 14px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 18px;
  flex-wrap: wrap;
}

.results-count {
  font-size: 13px;
  color: var(--ink-2);
}

.results-count strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.results-note {
  font-size: 12px;
  color: var(--muted);
}

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 40px;
}

/* --------------------------------------------------------------------------
   상품 카드
   -------------------------------------------------------------------------- */

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  padding: 18px 20px;
  align-items: start;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.card-volume {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  background: var(--gold-soft);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0;
}

.card-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

.card-meta {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 9px;
}

.card-alias {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.card-alias code {
  font-family: var(--font-num);
  background: var(--bg-sunken);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--ink-2);
}

/* --- 가격 블록 --- */

.card-price {
  text-align: right;
  min-width: 190px;
}

.price-market {
  font-size: 12px;
  color: var(--muted);
}

.price-market .num {
  color: var(--ink-2);
}

.price-main {
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 7px;
}

.price-main .num {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.price-main .won {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.price-none {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 0;
}

/* --------------------------------------------------------------------
   재고가 확인되지 않은 시장가 (STEP 24-O)

   확인된 값과 참고값을 같은 모양으로 찍으면, 손님은 지금 살 수 없는
   값을 보고 판단합니다. 숫자는 읽히되 확정값보다 약하게, 그리고
   '재고 미확인' 또는 '품절' 이라는 글자가 반드시 함께 보이도록
   합니다. 색만으로 구분하지 않습니다.
   -------------------------------------------------------------------- */
.price-market-soft .num {
  color: var(--muted);
}

.price-market .stock-note {
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.price-market-none {
  color: var(--muted);
}

/* 우리 판매가임을 말해 둡니다. 숫자만 크게 두면 시장가와 헷갈립니다. */
.price-label {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* --- 시장 판매처 표 --- */
.row-supplier .row-source {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.stock-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-sunken);
  color: var(--ink-2);
}

.stock-badge[data-stock="ok"] {
  background: var(--down-soft);
  color: var(--down);
}

.stock-badge[data-stock="out"] {
  background: var(--up-soft);
  color: var(--up);
}

.stock-badge[data-stock="unknown"] {
  background: var(--warn-soft);
  color: var(--warn);
}

/* 살 수 없는 줄은 눈에 덜 걸리게. 지우지는 않습니다 — 값을 걷어 온
   사실까지 숨길 이유는 없습니다. */
.ptable tr[data-stock="out_of_stock"] .num {
  color: var(--muted);
}

.price-supplier {
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
}

.supplier-badge {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.price-basis {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.price-basis .basis-note {
  font-size: 11px;
  opacity: 0.8;
}

.compare-note {
  margin-top: 12px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}

.compare-note b {
  color: var(--ink-2);
  font-weight: 600;
}

.price-diff {
  margin-top: 7px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

.price-diff[data-dir="down"] {
  color: var(--down);
  background: var(--down-soft);
}

.price-diff[data-dir="up"] {
  color: var(--up);
  background: var(--up-soft);
}

.price-diff[data-dir="flat"] {
  color: var(--muted);
  background: var(--bg-sunken);
}

/* --- 카드 하단 --- */

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  flex-wrap: wrap;
}

.card-foot-note {
  font-size: 12px;
  color: var(--muted);
}

.btn-compare {
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.13s ease;
}

.btn-compare:hover {
  border-color: var(--ink-2);
}

.btn-compare .caret {
  font-size: 10px;
  transition: transform 0.16s ease;
  color: var(--muted);
}

.btn-compare[aria-expanded="true"] .caret {
  transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   가격 비교 패널
   -------------------------------------------------------------------------- */

.compare {
  border-top: 1px solid var(--line);
  padding: 16px 20px 20px;
  background: var(--bg-soft);
}

.compare-loading,
.compare-error {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 0;
}

.compare-error {
  color: var(--up);
}

.compare-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 8px;
}

.compare-section + .compare-section {
  margin-top: 20px;
}

.ptable {
  font-size: 13px;
}

.ptable thead th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: right;
  padding: 0 10px 7px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.ptable thead th:first-child {
  text-align: left;
  padding-left: 0;
}

.ptable thead th:last-child {
  padding-right: 0;
}

.ptable tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

/*
 * 판매 채널 구분 머리글.
 *
 * 협의된 직접 거래처와 플랫폼 입점 판매처는 성격이 다릅니다.
 * 같은 표에 섞어 두면 둘 다 상시 거래처처럼 보입니다.
 * 마켓플레이스 판매처가 있을 때만 나타납니다.
 */
.ptable tbody tr.ptable-group td {
  padding: 12px 0 5px;
  border-bottom: none;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.ptable tbody tr.ptable-group:first-child td {
  padding-top: 4px;
}

.ptable tbody td:first-child {
  text-align: left;
  padding-left: 0;
  white-space: normal;
}

.ptable tbody td:last-child {
  padding-right: 0;
}

.ptable tbody tr:last-child td {
  border-bottom: none;
}

.ptable tbody tr[data-best="true"] {
  background: var(--down-soft);
}

.ptable tbody tr[data-purchasable="false"] {
  color: var(--muted);
}

.ptable tbody tr[data-purchasable="false"] .effective {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.row-supplier {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-supplier .name {
  font-weight: 600;
  color: inherit;
}

.row-region {
  font-size: 11.5px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tag-best {
  background: var(--down);
  color: #fff;
}

.tag-excluded {
  background: var(--bg-sunken);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.tag-vat {
  background: var(--warn-soft);
  color: var(--warn);
}

.effective {
  font-weight: 700;
}

.cell-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

/* --- 최근 변동 --- */

.change-row {
  margin-top: 16px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
}

.change-row .label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.change-arrow {
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   상태 화면 (안내 / 로딩 / 없음 / 오류)
   -------------------------------------------------------------------------- */

.state {
  text-align: center;
  padding: 56px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
}

.state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.state-body {
  font-size: 13px;
  line-height: 1.7;
}

.state-examples {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.example-chip {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
  transition: all 0.13s ease;
}

.example-chip:hover {
  border-color: var(--gold);
  color: var(--ink);
}

.state[data-kind="error"] {
  border-color: var(--up);
  border-style: solid;
  background: var(--up-soft);
  color: var(--up);
}

.state[data-kind="error"] .state-title {
  color: var(--up);
}

/* --- 스켈레톤 --- */

.skeleton {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 20px;
}

.sk-line {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--bg-sunken) 25%,
    var(--bg-soft) 50%,
    var(--bg-sunken) 75%
  );
  background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite;
}

.sk-line + .sk-line {
  margin-top: 9px;
}

@keyframes sk {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* --- 더 보기 --- */

.more-wrap {
  display: flex;
  justify-content: center;
  padding-bottom: 48px;
}

.btn-more {
  height: 42px;
  padding: 0 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.13s ease;
}

.btn-more:hover {
  border-color: var(--ink-2);
}

.btn-more:disabled {
  opacity: 0.5;
  cursor: default;
}

/* --------------------------------------------------------------------------
   푸터
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 40px;
}

.site-footer .page {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   반응형
   -------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .hero {
    padding: 30px 0 22px;
  }

  .hero-title {
    font-size: 22px;
  }

  .card-main {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .card-price {
    text-align: left;
    min-width: 0;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
  }

  .price-main {
    justify-content: flex-start;
  }

  .skeleton {
    grid-template-columns: 1fr;
  }

  /* 표가 넘칠 때 가로 스크롤 */
  .compare-scroll {
    overflow-x: auto;
    margin: 0 -20px;
    padding: 0 20px;
  }

  .ptable {
    min-width: 520px;
  }
}

@media (max-width: 480px) {
  .searchbar {
    flex-wrap: wrap;
  }

  .btn-primary {
    width: 100%;
  }

  /* 좁은 화면에서는 상태 **문구**를 접고 점만 남깁니다. 관리자 링크는
     숨기지 않습니다 - 모바일에서 들어갈 길이 없으면 링크의 목적이
     사라집니다. */
  .site-header .page {
    gap: 10px;
  }

  .status-dot {
    font-size: 0;
    gap: 0;
  }

  .header-admin-link {
    padding: 5px 8px;
  }
}
