/* 피부과 장바구니 — 메인·후기가 같이 쓴다. 마크업은 fragments/derma-cart.html, 동작은 js/dermatology/cart.js */

/* 본문과 갈리도록 1px 테두리를 두른다 */
.treatment-cart-wrap {
  position: fixed;
  right: 10px;
  top: 0;
  width: 370px;
  height: 100vh;
  background: #fff;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  z-index: 100;
}

/* 아래로 쓸어 닫을 수 있다는 표시. 서랍으로 뜨는 모바일에서만 보인다 */
.derma-cart-grab {
  display: none;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #d4d4d8;
  margin: 8px auto 0;
  flex: 0 0 auto;
}

.treatment-cart-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 12px 16px;
  border-bottom: 1px solid #f1f1f4;
  flex: 0 0 auto;
}

.treatment-cart-header .cart-title {
  font-size: 16px;
  font-weight: 700;
  color: #1d1d1f;
}

.treatment-cart-header .cart-header-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-right: auto;
  padding: 0 6px;
  border-radius: 999px;
  background: #f5f3ff;
  color: #6d28d9;
  font-size: 12px;
  font-weight: 700;
}

.derma-cart-clear {
  height: 44px;
  padding: 0 8px;
  border: none;
  background: none;
  color: #8b8b95;
  font-size: 13px;
  cursor: pointer;
}

.derma-cart-clear:hover {
  color: #3f3f46;
}

.treatment-cart-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
}

.treatment-cart-list::-webkit-scrollbar {
  width: 4px;
}

.treatment-cart-list::-webkit-scrollbar-thumb {
  background: #ddd6fe;
  border-radius: 4px;
}

.derma-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 44px 16px;
  text-align: center;
  color: #6b6b76;
  font-size: 14px;
}

.derma-cart-empty-icon {
  font-size: 34px;
  margin-bottom: 10px;
  display: block;
}

.derma-cart-empty-action {
  display: inline-block;
  height: 44px;
  margin-top: 14px;
  padding: 0 20px;
  border: 1px solid #6d28d9;
  border-radius: 999px;
  background: #fff;
  color: #6d28d9;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.treatment-cart-item {
  background: #fff;
  border: 1px solid #eeeef2;
  border-radius: 12px;
  padding: 12px 12px 10px;
  color: #1d1d1f;
}

.treatment-cart-item .item-name-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.treatment-cart-item .item-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.treatment-cart-item .derma-cnt-wrap {
  display: inline-flex;
  align-items: center;
  border: 1px solid #e4e4ea;
  border-radius: 999px;
}

.treatment-cart-item .derma-cnt {
  width: 30px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: none;
  outline: none;
  background: transparent;
  /* reset.css 가 숫자 입력칸에 좌우 10px 를 준다. 안 풀면 두 자리에서 0 이 잘린다 */
  padding: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}

.treatment-cart-item .derma-cnt::-webkit-outer-spin-button,
.treatment-cart-item .derma-cnt::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 누르는 자리는 44px, 눈에 보이는 동그라미는 28px */
.treatment-cart-item .derma-cnt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  user-select: none;
}

.treatment-cart-item .derma-cnt-btn span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f5f3ff;
  color: #6d28d9;
  font-size: 16px;
  line-height: 1;
}

.treatment-cart-item .derma-cnt-btn:disabled {
  cursor: default;
}

.treatment-cart-item .derma-cnt-btn:disabled span {
  background: #f4f4f6;
  color: #c4c4cc;
}

.treatment-cart-item .item-inner-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.treatment-cart-item .item-price {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* 곱한 값만 보이면 검산이 안 된다. 두 개 이상일 때 단가를 함께 적는다 */
.treatment-cart-item .item-unit {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #8b8b95;
}

.treatment-cart-item .item-remove {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -10px -10px 0 0;
  padding: 0;
  background: none;
  border: none;
  color: #a1a1aa;
  cursor: pointer;
}

.treatment-cart-item .item-remove svg {
  width: 17px;
  height: 17px;
}

.treatment-cart-item .item-remove:hover {
  color: var(--danger);
}

.treatment-cart-foot {
  flex: 0 0 auto;
  border-top: 1px solid #f1f1f4;
  background: #fff;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.treatment-cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #6b6b76;
}

.treatment-cart-sum {
  color: #1d1d1f;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.treatment-cart-reserve {
  width: 100%;
  height: 52px;
  background: #6d28d9;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.treatment-cart-reserve:hover {
  background: #5b21b6;
}

/* 장바구니 띠 — 색·문구·위치를 여성클리닉과 맞춘다. bottom 은 quick-menu.js 가 넣는 값 */
.treatment-cart-show {
  position: fixed;
  bottom: var(--quickmenu-height, 0px);
  left: 0;
  right: 0;
  z-index: 100;
  width: 100%;
  background: #6d28d9;
  color: #fff;
  border: none;
  padding: 16px 0;
  display: none;
  font-size: 16px;
  font-weight: 700;
}

.treatment-cart-show .cart-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255,255,255,0.95);
  color: #6d28d9;
  font-size: 15px;
  font-weight: 800;
  padding: 0 6px;
  margin-left: 6px;
}

.treatment-cart-close {
  display: none;
}

.cart-backdrop {
  display: none;
}

/* 1024px 이하 — 오른쪽 기둥이 아니라 아래에서 올라오는 서랍 */
@media (max-width: 1024px) {
  /* 모바일: 장바구니 보기 버튼 상시 노출 */
  .treatment-cart-show {
    display: block;
  }

  /* [태블릿] 장바구니 사이드바 → 하단 시트 전환 */
  .treatment-cart-wrap {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    height: auto;
    min-width: 0;
    max-height: 78vh;
    margin: 0 auto;
    border: none;
    border-radius: 24px 24px 0 0;
    z-index: 1000;
    /* 닫힘 — 가속 곡선으로 짧게. 사람은 사라지는 것이 빠른 쪽을 자연스럽게 느낀다 */
    transform: translateY(100%);
    visibility: hidden;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0);
    transition:
      transform 0.2s cubic-bezier(0.3, 0, 0.8, 0.15),
      box-shadow 0.2s linear,
      visibility 0s linear 0.2s;
    overscroll-behavior: contain;
  }

  /* 열림 — 감속 곡선으로 길게. 끝에서 천천히 안착해야 툭 멈추지 않는다 */
  .treatment-cart-wrap.active {
    transform: translateY(0);
    visibility: visible;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.18);
    transition:
      transform 0.5s cubic-bezier(0.32, 0.72, 0, 1),
      box-shadow 0.5s linear,
      visibility 0s;
  }

  .derma-cart-grab {
    display: block;
  }

  .treatment-cart-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: none;
    font-size: 20px;
    line-height: 1;
    color: #3f3f46;
    cursor: pointer;
  }

  .treatment-cart-header {
    padding-top: 10px;
  }

  /* display 는 전환이 안 돼 팝 하고 나타났다 — opacity 로 바꾸고 시트와 같은 곡선을 쓴다 */
  .cart-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.3, 0, 0.8, 0.15);
  }

  .cart-backdrop.active {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  }

  /* 움직임을 줄여 달라고 설정한 기기는 즉시 전환한다 */
  @media (prefers-reduced-motion: reduce) {
    .treatment-cart-wrap,
    .treatment-cart-wrap.active,
    .cart-backdrop,
    .cart-backdrop.active {
      transition-duration: 0.01ms;
    }
  }
}
