/* พื้นฐานของหน้าเว็บ */
body {
  font-family: Arial, sans-serif;
  background-color: #f4f4f4;
  margin: 0;
  padding: 0;
}

/* แถบนำทาง */
nav ul {
  display: flex;
  background-color: #333;
  padding: 10px;
  list-style: none;
  justify-content: center;
}

nav ul li {
  margin-right: 15px;
}

nav ul li a {
  color: white;
  text-decoration: none;
  font-weight: bold;
}

nav ul li a:hover {
  text-decoration: underline;
}

/* ช่องค้นหา */
#searchInput {
  margin: 20px auto;
  padding: 10px;
  width: 80%;
  border: 1px solid #ccc;
  border-radius: 5px;
  display: block;
}

/* ตัวกรอง */
#filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

/* ปุ่มกรอง */
.filter-btn {
  background-color: #444;
  border: none;
  border-radius: 10px;
  margin: 5px;
  cursor: pointer;
  width: 60px;
  height: 60px;
  transition: background-color 0.3s, transform 0.2s, opacity 0.3s;
}

.filter-btn.selected {
  background-color: #222;
  opacity: 1;
}

.filter-btn:hover {
  background-color: #555;
  transform: scale(1.1);
}

.filter-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.6;
}

.filter-btn.selected img {
  opacity: 1;
}

/* ปุ่มกรองระดับดาว */
.filter-btn.rarity {
  width: 80px;
  height: 80px;
  font-size: 24px;
  color: white;
  background-color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.filter-btn.rarity.selected {
  background-color: #222;
}

.filter-btn.rarity:hover {
  background-color: #555;
  transform: scale(1.1);
}

/* การ์ดตัวละคร */
#characterGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  padding: 20px;
}

.character-card {
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  width: 150px;
  text-align: center;
  padding: 10px;
  transition: transform 0.2s;
}

.character-card:hover {
  transform: scale(1.05);
}

.character-card img {
  width: 100%;
  height: auto;
  border-radius: 10px;
}

/* ไอคอนของตัวละคร */
.icons {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 10px;
}

.icons img {
  width: 30px;
  height: 30px;
  object-fit: cover;
}

/* ป๊อปอัป */
.popup.hidden {
  display: none;
}

/* ป๊อปอัป */
.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  width: 950px;  /* เพิ่มความกว้างให้พอดีกับการแบ่ง */
  height: 580px;  /* เพิ่มความสูงให้รายละเอียดดูสมดุล */
  display: flex;
  flex-direction: column;
  gap: 15px;
}
/* จัดเนื้อหาภายในป๊อปอัปเป็น 2 ฝั่ง */
.popup-body {
  display: flex;
  gap: 20px;
  height: 100%; /* ให้เนื้อหาสูงเต็มป๊อปอัป */
}

/* ฝั่งซ้าย: รูปภาพและ Slider */
.left-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 40%; /* ฝั่งซ้ายใช้พื้นที่ 40% */
  align-items: flex-start; /* จัดรูปและ Slider ชิดซ้าย */
}


/* จัดให้เนื้อหาภายในป๊อปอัปเป็น Flexbox */
.popup-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

/* จัดรูปภาพและรายละเอียดในแนวนอน */
.popup-header {
  display: flex;
  width: 100%;
  gap: 20px;
  align-items: flex-start;
}

/* รูปภาพของตัวละคร */
.character-popup-image {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  margin-left: 0; /* ชิดซ้ายสุด */
}

/* กลุ่มรายละเอียดและ Slider */
.details-and-sliders {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 15px;
}
/* รายละเอียดของตัวละคร */

.character-details {
  background-color: #333;
  color: white;
  padding: 1px; /* ระยะห่างภายในกรอบ */
  border-radius: 5px;
  height: 100%; /* ให้กรอบขยายเต็มความสูง */
  overflow-y: auto; /* เพิ่ม Scroll หากเนื้อหายาวเกิน */
  white-space: pre-wrap; /* รองรับการเว้นบรรทัด */
  word-wrap: break-word; /* ตัดคำอัตโนมัติ */
  display: flex; /* ใช้ Flexbox เพื่อจัดข้อความ */
  align-items: flex-start; /* จัดแนวข้อความชิดด้านบน */
  justify-content: flex-start; /* จัดข้อความชิดซ้าย */
}

/* กลุ่ม Slider */
.sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%; /* ขยาย Slider ให้เต็มความกว้างของฝั่งซ้าย */
}

/* ฝั่งขวา: รายละเอียด */
.right-section {
  width: 60%; /* ฝั่งขวาใช้พื้นที่ 60% */
}
.sliders input {
  width: 200px; /* ลดความกว้างของ Slider */
}

/* คำสั่ง */
.command-display {
  background-color: #d3d3d3;
  padding: 5px;
  border-radius: 5px;
  text-align: center;
}


/* การจัดกลุ่ม Slider */
.slider-group {
  width: 100%; /* ขยายให้เต็มพื้นที่ของ container */
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* จัดองค์ประกอบชิดซ้าย */
  text-align: left; /* จัดข้อความชิดซ้าย */
  margin-bottom: 5px; /* ลดช่องว่างใต้ Slider */
}


.command-display {
  background-color: #d3d3d3;
  padding: 5px;
  border-radius: 5px;
  width: 100%;
  text-align: center;
}



.close-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 30px; /* ลดขนาดฟอนต์เพื่อให้พอดีกับปุ่ม */
  background-color: #a3a3a3;
  color: rgb(0, 0, 0);
  cursor: pointer;
  border-radius: 50%; /* ทำให้พื้นหลังเป็นวงกลม */
  width: 30px; /* กำหนดความกว้างและความสูง */
  height: 30px;
  display: flex; /* จัดตำแหน่งตัวอักษรให้อยู่ตรงกลาง */
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* เพิ่มเงาเพื่อความสวยงาม */
}

.close-btn:hover {
  background-color: #888; /* เปลี่ยนสีพื้นหลังเมื่อวางเมาส์ */
}


.command-display {
  background-color: #d3d3d3;
  padding: 5px;
  border-radius: 5px;
  margin-top: 10px;
  text-align: center; /* ชิดซ้าย */
  width: 200px; /* กำหนดความกว้างที่ต้องการ */
  max-width: 100%; /* ป้องกันไม่ให้เกินขนาด container */
}

/* การจัดกลุ่ม Slider */
.slider-group {
  margin: 15px 0; /* เพิ่มช่องว่างระหว่าง Slider */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* เว้นระยะห่างระหว่าง Label และ Slider */
.slider-group label {
  margin-bottom: 5px;
}

.slider-group input {
  margin-top: 5px; /* เพิ่มระยะห่างระหว่าง Label และ Slider */
}
/* ปุ่มกรองระดับดาวเมื่อถูกเลือก */
.filter-btn.rarity.selected {
  color: gold; /* เปลี่ยนสีตัวอักษรเป็นทอง */
  font-weight: bold; /* ทำให้ตัวอักษรหนาขึ้น */
  background-color: #333; /* เพิ่มความแตกต่างให้ชัดเจน */
}
/* สไตล์สำหรับ Description */
.description {
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5; /* ความสูงของบรรทัด */
}
.highlight {
  background-color: rgb(97, 97, 97); /* กำหนดสีพื้นหลัง */
  padding: 2px; /* เพิ่มระยะห่างภายใน */
  border-radius: 3px; /* มุมโค้งเล็กน้อย */
}
#popupDescription img {
  width: 30px;
  height: 30px;
}
/* ============================ */
/* ✅ Responsive fix เพิ่มเติม  */
/* ============================ */

/* ทำให้ Popup ขนาดยืดหยุ่นบนมือถือ */
@media (max-width: 600px) {
  .popup {
    width: 95%;
    height: auto;
    max-height: 95%;
    overflow-y: auto;
    padding: 10px;
  }

  .popup-body {
    flex-direction: column;
    gap: 10px;
  }

  .left-section, .right-section {
    width: 100%;
  }

  .character-popup-image {
    width: 100%;
    height: auto;
  }

  .sliders input {
    width: 100%;
  }

  .command-display {
    width: 100%;
  }
}

/* Grid ของตัวละครให้ปรับอัตโนมัติ */
@media (max-width: 768px) {
  #characterGrid {
    justify-content: center;
    padding: 10px;
    gap: 10px;
  }

  .character-card {
    width: 45%; /* ให้แถวละ 2 ตัวบนมือถือ */
  }
}

@media (max-width: 480px) {
  .character-card {
    width: 100%; /* แถวละ 1 ตัว */
  }
}
