/* ================================================================
   상품 목록 페이지
   그리드 뷰 (카드형) + 리스트 뷰 (테이블 + 장바구니 사이드바)
   ================================================================ */

/* ── 통합 네비 바 ── */
.list-bar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 68px;
  z-index: 40;
}
.list-bar__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 50px;
}
.list-bar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.breadcrumb { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--navy-30); }
.breadcrumb a { color: var(--navy-30); transition: color .2s; }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb__sep { color: var(--navy-15); font-size: 9px; }
.list-bar__title { font-size: 16px; font-weight: 800; color: var(--navy); white-space: nowrap; }
.list-bar__count { font-size: 13px; color: var(--navy-30); white-space: nowrap; }
.list-bar__count strong { color: var(--gold); font-weight: 700; }

/* 필터 칩 */
.list-bar__filters {
  display: flex; align-items: center; gap: 5px; flex: 1;
  overflow-x: auto; padding: 0 4px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.list-bar__filters::-webkit-scrollbar { display: none; }
.filter-chip {
  display: inline-flex; align-items: center; padding: 5px 14px;
  border-radius: 100px; font-size: 12px; font-weight: 600;
  color: var(--navy-50); background: transparent; border: 1px solid var(--line);
  white-space: nowrap; transition: all .2s;
}
.filter-chip:hover { border-color: var(--gold); color: var(--navy); background: var(--gold-bg); }
.filter-chip.is-active { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* 뷰 모드 */
.list-bar__view {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
  border-left: 1px solid var(--line); padding-left: 12px; margin-left: auto;
}
.view-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--navy-30); transition: all .2s;
}
.view-btn:hover { color: var(--navy-50); background: var(--cream); }
.view-btn.is-active { color: var(--navy); background: var(--cream); }

/* ── 메인 영역 ── */
.list-main { padding: 24px 0 60px; background: var(--bg-page); min-height: 60vh; }

/* ── 레이아웃 컨테이너 ── */
.list-layout { display: flex; gap: 20px; align-items: flex-start; }
.list-layout__products { flex: 1; min-width: 0; }

/* ── 리스트 뷰: 제품 넓게 + 장바구니 사이드바 ── */
.list-layout.is-list { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }

/* ── 장바구니 사이드바 (리스트 뷰에서만 표시) ── */
.cart-sidebar { display: none; }
.list-layout.is-list .cart-sidebar { display: block; }

/* ── 제품 영역 내 검색 ── */
.list-search {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding: 8px 12px;
  background: var(--white); border: 1px solid var(--line); border-radius: 8px;
}
.list-search__icon { flex-shrink: 0; color: var(--navy-30); }
.list-search__input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13px; color: var(--navy); height: 32px;
}
.list-search__input::placeholder { color: var(--navy-15); }
.list-search__clear {
  display: none; width: 24px; height: 24px;
  align-items: center; justify-content: center;
  border-radius: 50%; color: var(--navy-30); flex-shrink: 0; transition: all .15s;
}
.list-search__clear.is-visible { display: flex; }
.list-search__clear:hover { background: var(--cream); color: var(--accent-red); }

.cart-sidebar__inner {
  position: sticky; top: 130px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.cart-sidebar__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--navy); color: var(--white);
}
.cart-sidebar__title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--white);
}
.cart-sidebar__badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 100px; font-size: 11px; font-weight: 700;
  background: var(--gold); color: var(--white);
}
.cart-sidebar__items {
  max-height: 340px; overflow-y: auto; border-bottom: 1px solid var(--line);
}
.cart-sidebar__empty {
  padding: 40px 18px; text-align: center;
  font-size: 13px; color: var(--navy-30);
}

/* 장바구니 아이템 */
.cart-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  min-height: 72px;
}
.cart-item:last-child { border-bottom: none; }
.cart-item__img {
  width: 52px; height: 52px; border-radius: 6px; object-fit: contain;
  background: var(--cream-light); flex-shrink: 0; padding: 4px;
}
.cart-item__info { flex: 1; min-width: 0; }
.cart-item__name { font-size: 12px; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item__option { font-size: 11px; color: var(--navy-30); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item__meta { font-size: 12px; color: var(--accent-red); font-weight: 700; margin-top: 3px; }
.cart-item__remove {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--navy-30); flex-shrink: 0; transition: all .15s;
}
.cart-item__remove:hover { background: var(--cream); color: var(--accent-red); }
/* 장바구니 추가 애니메이션 */
.cart-item.is-new { animation: cartSlideIn .3s ease; }
@keyframes cartSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* 합계 */
.cart-sidebar__summary { padding: 14px 18px; background: var(--cream-light); }
.cart-sidebar__row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--navy-50); padding: 3px 0;
}
.cart-sidebar__row strong { color: var(--navy); }
.cart-sidebar__total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0 0; margin-top: 8px; border-top: 1px solid var(--line);
  font-size: 14px; font-weight: 700; color: var(--navy);
}
.cart-sidebar__total strong { font-size: 18px; color: var(--accent-red); }

/* 주문 버튼 */
.cart-sidebar__actions { display: flex; gap: 8px; padding: 14px 18px; }
.cart-sidebar__btn {
  flex: 1; text-align: center; padding: 10px; border-radius: 8px;
  font-size: 13px; font-weight: 700; transition: all .2s;
}
.cart-sidebar__btn--outline { border: 1px solid var(--line); color: var(--navy-50); background: var(--white); }
.cart-sidebar__btn--outline:hover { border-color: var(--navy); color: var(--navy); }
.cart-sidebar__btn--primary { background: var(--navy); color: var(--white); }
.cart-sidebar__btn--primary:hover { background: var(--navy-90); }

/* ━━━ 그리드 뷰 (기본) ━━━ */
.list-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
}
.list-grid .product-card { position: relative; border: 1px solid var(--line); }
.list-grid .product-card:hover { border-color: var(--gold); }
.list-grid .product-card__name { font-size: 14px; font-weight: 700; color: var(--navy); line-height: 1.5; }
.list-grid .product-card__cat { font-size: 11px; color: var(--gold); }
.list-grid .product-card__price { font-size: 18px; }

/* ━━━ 리스트 뷰 ━━━ */
.list-layout.is-list .list-grid {
  grid-template-columns: 1fr; gap: 0;
}
/* 리스트 뷰 카드 → 행 */
.list-layout.is-list .product-card {
  flex-direction: row; border-radius: 0;
  border: none; border-bottom: 1px solid var(--line);
  box-shadow: none; background: var(--white);
  min-height: 84px; height: auto; padding: 12px 0;
}
.list-layout.is-list .product-card:first-child { border-top: 1px solid var(--line); }
.list-layout.is-list .product-card:hover { background: var(--cream-light); box-shadow: none; transform: none; border-color: var(--line); }
.list-layout.is-list .product-card__thumb {
  width: 76px; min-width: 76px; height: 76px;
  border-radius: 6px; margin: 0 0 0 12px; overflow: hidden; flex-shrink: 0;
  background: var(--cream-light);
}
.list-layout.is-list .product-card__img { padding: 4px; }
.list-layout.is-list .product-card:hover .product-card__img { transform: none; }
.list-layout.is-list .product-card__body {
  padding: 0 16px; justify-content: center; gap: 4px; flex: 1; min-width: 0;
}
.list-layout.is-list .product-card__cat { font-size: 11px; margin-bottom: 0; color: var(--gold); }
.list-layout.is-list .product-card__name {
  font-size: 14px; font-weight: 700; color: var(--navy);
  margin-bottom: 3px; -webkit-line-clamp: 2;
  line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical;
}
.list-layout.is-list .product-card__price { font-size: 15px; font-weight: 800; color: var(--accent-red); }

/* ── 카드 액션 버튼 ── */
.product-card__actions {
  display: flex; flex-direction: column; gap: 5px;
  padding: 0 12px 12px;
}
.product-card__option-btn,
.product-card__detail-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 700; text-align: center;
  cursor: pointer; transition: all .2s; border: none;
  text-decoration: none; line-height: 1.4;
}
.product-card__option-btn {
  background: #e8f0fe; color: #3b6fc0;
  border: 1px solid #c8daef;
}
.product-card__option-btn:hover { background: #d4e4fc; border-color: #9bbce6; }
.product-card__detail-btn {
  background: #f3f0eb; color: #8a7a5e;
  border: 1px solid #e0d8ca;
}
.product-card__detail-btn:hover { background: #ebe5da; border-color: #c9bda6; color: #6b5d43; }

/* 리스트 뷰 액션 버튼 (카드 우측, 세로 배치) */
.list-layout.is-list .product-card__actions {
  flex-direction: column; gap: 5px;
  padding: 0; margin-right: 12px;
  align-items: stretch; flex-shrink: 0;
  min-width: 90px;
}
.list-layout.is-list .product-card__option-btn,
.list-layout.is-list .product-card__detail-btn {
  padding: 7px 14px; font-size: 11px; white-space: nowrap;
}

/* ── 결과 없음 ── */
.list-empty {
  grid-column: 1 / -1; text-align: center; padding: 80px 20px;
}
.list-empty__icon { width: 56px; height: 56px; margin: 0 auto 16px; color: var(--navy-15); opacity: .5; }
.list-empty__title { font-size: 16px; font-weight: 700; color: var(--navy-50); margin-bottom: 6px; }
.list-empty__desc { font-size: 13px; color: var(--text-muted); }
.list-empty__link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 16px; padding: 9px 22px; border-radius: 100px;
  font-size: 13px; font-weight: 700; color: var(--white); background: var(--navy); transition: all .2s;
}
.list-empty__link:hover { background: var(--navy-90); }

/* ── 페이지네이션 ── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line);
}
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 6px; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--navy-50);
  background: var(--white); border: 1px solid var(--line); cursor: pointer; transition: all .2s;
}
.page-btn:hover { border-color: var(--gold); color: var(--gold); }
.page-btn.is-active { background: var(--navy); color: var(--white); border-color: var(--navy); }
.page-btn.is-disabled { opacity: .3; pointer-events: none; }
.page-btn--arrow { background: var(--cream-light); }
.page-ellipsis {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 36px; font-size: 13px; color: var(--navy-15);
}

/* ── 스켈레톤 ── */
.item-skeleton { aspect-ratio: 3/4; border-radius: var(--radius-lg); }
.list-skeleton { height: 80px; border-radius: 0; }

/* ━━━ 반응형 ━━━ */
@media (max-width: 1100px) {
  .list-grid { grid-template-columns: repeat(3, 1fr); }
  .cart-sidebar { width: 280px; }
}
@media (max-width: 768px) {
  .list-bar { top: 56px; }
  .list-bar__inner { height: auto; flex-wrap: wrap; padding: 10px 0; gap: 8px; }
  .list-bar__left { width: 100%; }
  .list-bar__filters { width: 100%; order: 3; }
  .list-bar__view { order: 2; margin-left: auto; border-left: none; padding-left: 0; }
  .list-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .list-grid .product-card__name { font-size: 13px; }
  .list-main { padding: 16px 0 40px; }
  /* 모바일: 장바구니 사이드바 숨김, 1열 복귀 */
  .list-layout.is-list { grid-template-columns: 1fr; }
  .cart-sidebar { display: none !important; }
  .list-layout.is-list .product-card__thumb { width: 56px; min-width: 56px; height: 56px; }
}
@media (max-width: 480px) {
  .list-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .list-grid .product-card__name { font-size: 12px; }
  .list-grid .product-card__price { font-size: 15px; }
  .product-card__actions { gap: 4px; padding: 0 8px 8px; }
  .product-card__option-btn,
  .product-card__detail-btn { padding: 6px 8px; font-size: 11px; }
}

/* ━━━ 옵션 모달 ━━━ */
/* ━━━ 옵션 모달 (기존 사이트 item_option.php 방식: 대형 팝업 + 옵션 이미지 그리드) ━━━ */
.option-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
  padding-top: 30px;
}
.option-modal.is-open { opacity: 1; visibility: visible; }
.option-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .45);
}
.option-modal__box {
  position: relative; z-index: 1;
  width: 96%; max-width: 1100px;
  background: #fff; border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  transform: translateY(20px); transition: transform .3s ease;
  max-height: 90vh; overflow-y: auto;
}
.option-modal.is-open .option-modal__box { transform: translateY(0); }

/* 닫기 버튼 */
.option-modal__close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: #f5f5f5; color: #666;
  border: none; cursor: pointer; transition: all .2s;
}
.option-modal__close:hover { background: #eee; color: #c00; }

/* 로딩 */
.option-modal__loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; gap: 12px; font-size: 14px; color: #999;
}
.option-modal__spinner {
  width: 32px; height: 32px; border: 3px solid #e5e7eb;
  border-top-color: var(--navy); border-radius: 50%;
  animation: modalSpin .7s linear infinite;
}
@keyframes modalSpin { to { transform: rotate(360deg); } }

/* 모달 콘텐츠 */
.option-modal__content { padding: 28px 32px; }
.option-modal__header {
  border-bottom: 1px solid #ccc; padding-bottom: 12px; margin-bottom: 16px;
}
.option-modal__category { font-size: 12px; color: #999; padding-bottom: 4px; }
.option-modal__name { font-size: 20px; font-weight: 800; color: #222; margin: 6px 0; }
.option-modal__company { font-size: 13px; color: #666; border-bottom: 1px solid #ccc; padding-bottom: 10px; }
.option-modal__descript { color: #c00; font-weight: 700; margin-top: 12px; font-size: 14px; }

/* 옵션 이미지 그리드 (기존 사이트 방식) */
.option-modal__opt-label { font-weight: 700; padding: 10px 0 8px; clear: both; font-size: 13px; color: #333; }
.option-modal__opt-grid {
  display: flex; flex-wrap: wrap; gap: 10px; clear: both; margin-bottom: 16px;
}
.option-modal__opt-card {
  position: relative; width: 170px; border: 2px solid #ddd; border-radius: 6px;
  padding: 10px; cursor: pointer; transition: border-color .15s; text-align: center;
  background: #fff;
}
.option-modal__opt-card:hover { border-color: #999; }
.option-modal__opt-card.is-selected { border-color: #ff9d00; }
.option-modal__opt-card.is-soldout { opacity: .5; cursor: not-allowed; }
.option-modal__opt-card img {
  width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 4px; margin-bottom: 6px;
}
.option-modal__opt-price { font-size: 15px; font-weight: 700; text-align: center; margin-top: 6px; }
.option-modal__opt-name {
  padding: 6px 2px 2px; color: #333;
  font-size: 12px; line-height: 1.4; word-break: keep-all;
}
.option-modal__opt-soldout { color: red; font-weight: 700; }
.option-modal__opt-stock { color: #1d4ed8; font-size: 12px; }

/* 하단 영역: 요청사항 + 합계 + 수량 + 장바구니 */
.option-modal__bottom {
  display: flex; gap: 16px; align-items: flex-start;
  border-top: 1px solid #ddd; padding-top: 16px; margin-top: 16px;
  flex-wrap: wrap;
}
.option-modal__memo-area { flex: 1; min-width: 200px; }
.option-modal__memo-area p { color: red; font-size: 13px; margin-bottom: 6px; }
.option-modal__memo-area textarea {
  width: 100%; height: 60px; padding: 8px; border: 1px solid #ddd;
  border-radius: 4px; font: inherit; font-size: 13px; resize: vertical;
}
.option-modal__summary {
  width: 240px; font-size: 18px; font-weight: 700; line-height: 34px;
}
.option-modal__summary .price-val { color: #c00; font-size: 22px; font-weight: 800; }
.option-modal__summary .save-val { color: #7c3aed; }
.option-modal__actions { width: 180px; display: flex; flex-direction: column; gap: 8px; }
.option-modal__qty-row {
  display: flex; align-items: center; gap: 4px; font-size: 14px; margin-bottom: 4px;
}
.option-modal__qty-row .ctrl {
  width: 30px; height: 30px; border: 1px solid #ccc; border-radius: 4px;
  background: #f5f5f5; font-size: 16px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.option-modal__qty-row .ctrl:hover { background: #e5e5e5; }
.option-modal__qty-row input[type="text"] {
  width: 40px; text-align: center; border: 1px solid #ccc; border-radius: 4px;
  height: 30px; font-size: 14px; font-weight: 700;
}
.option-modal__cart-btn {
  display: block; width: 100%; padding: 10px; border: none; border-radius: 6px;
  background: var(--navy); color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer; text-align: center; transition: background .15s;
}
.option-modal__cart-btn:hover { background: #1e3050; }
.option-modal__cart-btn:disabled { opacity: .5; cursor: not-allowed; }
.option-modal__view-btn {
  display: block; width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px;
  background: #fff; color: #333; font-size: 14px; font-weight: 700;
  text-align: center; text-decoration: none; transition: all .15s;
}
.option-modal__view-btn:hover { border-color: var(--gold); color: var(--gold); }

/* 배송안내 */
.option-modal__delivery {
  margin-top: 16px; padding: 12px 14px; background: #f9fafb; border-radius: 6px;
  font-size: 13px; line-height: 1.6; color: #555;
}
.option-modal__delivery p { font-weight: 700; margin-bottom: 4px; }
.option-modal__delivery .warn {
  background: #dc2626; padding: 6px 10px; color: #fff; font-size: 12px;
  margin-top: 8px; border-radius: 4px;
}

/* 모달 반응형 */
@media (max-width: 768px) {
  .option-modal__opt-card { width: 120px; }
  .option-modal__bottom { flex-direction: column; }
  .option-modal__summary, .option-modal__actions { width: 100%; }
}
