/* ==============================================
   購物車側邊欄
   ============================================== */

/* 遮罩 */
.cart_sidebar_overlay {
  position: fixed;
  inset: 0;
  background-color: var(--color-bg-overlay);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.cart_sidebar_overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* 側邊欄 */
.cart_sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100%;
  height: 100vh;
  background-color: var(--color-bg-white);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s ease;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

.cart_sidebar.is-open {
  transform: translateX(0);
}

/* Header */
.cart_sidebar_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-grey-200);
  flex-shrink: 0;
}

.cart_sidebar_header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.cart_sidebar_close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-grey-500);
  font-size: 1.1rem;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.cart_sidebar_close:hover {
  background-color: var(--color-grey-100);
  color: var(--color-text-primary);
}

/* Body - 商品列表 */
.cart_sidebar_body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

/* 商品項目 */
.cart_item {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-grey-100);
  position: relative;
}

.cart_item:last-child {
  border-bottom: none;
}

.cart_item_img {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--color-grey-50);
}

.cart_item_img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cart_item_info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cart_item_name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-decoration: none;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.2s ease;
}

.cart_item_name:hover {
  color: var(--color-primary);
}

.cart_item_spec {
  font-size: 0.78rem;
  color: var(--color-grey-500);
}

.cart_item_price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-top: 2px;
}

.cart_item_price del {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-grey-500);
  margin-right: 4px;
}

/* 數量 */
.cart_item_qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-grey-300);
  border-radius: 3px;
  overflow: hidden;
  width: fit-content;
  margin-top: 4px;
}

.cart_qty_btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-grey-50);
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-primary);
  font-family: var(--font-family-base);
  transition: background 0.2s ease;
}

.cart_qty_btn:hover {
  background: var(--color-grey-200);
}

.cart_qty_input {
  width: 36px;
  height: 28px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--color-grey-300);
  border-right: 1px solid var(--color-grey-300);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-family-base);
  appearance: textfield;
  -moz-appearance: textfield;
  color: var(--color-text-primary);
}

.cart_qty_input::-webkit-outer-spin-button,
.cart_qty_input::-webkit-inner-spin-button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

/* 空購物車 */
.cart_empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
}

.cart_empty p {
  font-size: 0.9rem;
  color: var(--color-grey-400);
  margin: 0;
}

/* 刪除按鈕 */
.cart_item_remove {
  position: absolute;
  top: 16px;
  right: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-grey-400);
  font-size: 0.85rem;
  padding: 4px;
  transition: color 0.2s ease;
}

.cart_item_remove:hover {
  color: var(--color-danger-hover);
}

/* Footer */
.cart_sidebar_footer {
  padding: 20px 24px;
  border-top: 1px solid var(--color-grey-200);
  flex-shrink: 0;
}

.cart_sidebar_total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.cart_sidebar_total span:first-child {
  font-size: 0.9rem;
  color: var(--color-grey-600);
}

.cart_total_price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.cart_checkout_btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 14px 0;
  font-size: 0.95rem;
}

/* ==============================================
   響應式
   ============================================== */
@media (max-width: 480px) {
  .cart_sidebar {
    width: 100%;
  }
}
