
/* ===============================
   Category Sort Modal Overlay
================================ */
.cat-sort-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.cat-sort-modal.active {
  display: flex;
}

/* ===============================
   Modal Box
================================ */
.cat-sort-box {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  padding: 22px 22px 18px;
  animation: catSortPop 0.25s ease-out;
  font-family: 'Kanit', sans-serif;
}





/* ===============================
   Title
================================ */
.cat-sort-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: #222;
}

/* ===============================
   Category List
================================ */
.cat-sort-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 50vh;
  overflow-y: auto;
  border-radius: 10px;
}

/* Scrollbar */
.cat-sort-list::-webkit-scrollbar {
  width: 6px;
}
.cat-sort-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 6px;
}

/* ===============================
   Category Item
   (ใช้ร่วมกับ li ที่คุณสร้างจาก JS)
================================ */
.cat-sort-list .category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #f8f9fb;
  border-radius: 12px;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s;
}

.cat-sort-list .category-item:last-child {
  margin-bottom: 0;
}

.cat-sort-list .category-item::before {
  content: "≡";
  font-size: 18px;
  color: #999;
}

/* Hover */
.cat-sort-list .category-item:hover {
  background: #eef1f7;
}

/* Dragging */
.cat-sort-list .category-item.dragging {
  opacity: 0.85;
  transform: scale(1.03);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  cursor: grabbing;
}

/* ===============================
   Footer / Buttons
================================ */
.cat-sort-actions {
  margin-top: 15px;
  text-align: right;
}

.cat-sort-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: #e9ecf3;
  color: #333;
}

.cat-sort-btn + .cat-sort-btn {
  margin-left: 6px;
}

.cat-sort-btn-primary {
  background: linear-gradient(135deg, #6c63ff, #8a7dff);
  color: #ffffff;
}

.cat-sort-btn-primary:hover {
  opacity: 0.9;
}

/* ===============================
   Animation
================================ */
@keyframes catSortPop {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===============================
   Mobile Responsive
================================ */
@media (max-width: 480px) {
  .cat-sort-box {
    max-width: 94%;
    padding: 18px 16px 16px;
  }

  .cat-sort-list .category-item {
    padding: 12px 14px;
    font-size: 14px;
  }
}

.cat-sort-order {
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #6c63ff;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cat-sort-name {
  font-size: 15px;
  font-weight: 500;
  color: #222;
}


/* ปิดการเลือกข้อความทั้งหมดใน popup เรียงหมวด */
.cat-sort-modal,
.cat-sort-box,
.cat-sort-list,
.cat-sort-list * {
  -webkit-user-select: none;
  user-select: none;
}

/* บอก browser ว่า element นี้ไว้ drag */
.cat-sort-list {
  touch-action: pan-y; /* อนุญาต scroll แนวตั้ง */
}

.cat-sort-list .category-item.dragging {
  touch-action: none; /* lock เฉพาะตอนลาก */
}


/* ล็อก scroll หน้าเว็บ เฉพาะตอนเปิดเรียงหมวด */
body.cat-sort-lock {
  overflow: hidden;
  position: fixed;
  width: 100%;
}


