html {
  scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Noto Sans Thai", sans-serif;
    background: linear-gradient(135deg, #ffffff, #edf2fa);
  }

html, body {
  overflow-x: hidden;
  width: 100%;
}

/*-- หมายเหตุ: ส่วนนี้คือ รูปภาพแบนเนอร์ --*/
.top-banner img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  display: block;
}

.top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    padding: 10px 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.top-bar h4 {
  margin-bottom: 2px;
  color: #00578e;
}

.logo {
  font-size: 32px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 40px; /*-- หมายเหตุ: ส่วนนี้คือ ระยะห่างระหว่างโลโก้กับเมนู --*/
  color: #007fce;
}
  
.top-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 25px 0;
  background-color: #fff;
  border-bottom: 1px solid #ccc;
}

.menu {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}

.menu li a {
  text-decoration: none;
  font-weight: bold;
  color: black;
  padding-bottom: 3px;
}

.menu li a.active {
  border-bottom: 2px solid black;
}


/*-- หมายเหตุ: ส่วนนี้คือ Zoom In / Zoom Out --*/
.zoom-controls {
  position: fixed;
  top: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.zoom-controls button {
  background-color: #ffffff;
  color: rgb(0, 0, 0);
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: background-color 0.3s;
}

.zoom-controls button:hover {
  background-color: #dedede;
}

#zoom-level {
  text-align: center;
  margin-top: 5px;
  font-size: 14px;
  color: #313131;
  font-weight: bold;
}

#main-content {
  transform-origin: top center;
  transition: transform 0.3s ease;
  background: linear-gradient(135deg, #ffffff, #edf2fa);
}

/*-- หมายเหตุ: ส่วนนี้คือทำให้มีกรอบสีเทาเมื่อเอาเม้าส์ไปชี้ที่แถบเมนู --*/
.menu li a {
  text-decoration: none;
  color: black;
  font-weight: bold;
  padding: 6px 10px;
  transition: background-color 0.2s ease;
}
.menu li a:hover {
  background-color: #dfeaf9;
  border-radius: 4px;
}
nav ul.menu li a.active {
    border-bottom: 2px solid #0077cc;
    color: #0077cc;
  }


  /* ทำให้แถบเมนูอยู่กลาง */
nav {
    display: flex;
    justify-content: center;
    width: 100%;
  }
  
  /* จัด ul ด้านใน */
  nav ul {
    list-style: none;
    display: flex;
    gap: 1rem;
    padding: 0;
    margin: 0;
  }
  
  nav a.active {
    border-bottom: 2px solid black;
    padding-bottom: 2px;
  }


  /*-- หมายเหตุ: ส่วนนี้คือการกำหนด class ให้เนื้อหาข้างใน (ตรงกลาง) --*/
  .center  {
    text-align: center;
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
  }
  /*-- หมายเหตุ: ส่วนนี้คือการกำหนด class ให้เนื้อหาข้างใน (ชิดซ้าย) --*/
  .left {
    text-align: left;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
  }


  /*-- หมายเหตุ: ส่วนนี้คือการกำหนด class ให้เว้นระยะห่างในการขึ้นหัวข้อใหม่ --*/
  .subheading {
    margin-top: 60px;
  }
  .subheading2 {
    margin-top: 10px;
  }

  /*-- หมายเหตุ: ส่วนนี้คือการกำหนด class ให้รูปอยู่ตรงกลาง --*/
  .author-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
  }
  .author-image img {
    width: 200px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
  }
  .author-text {
    max-width: 300px;
    font-size: 18px;
    line-height: 1.5;
  }
  /*-- หมายเหตุ: ส่วนนี้คือการกำหนด class ให้รูปอยู่ชิดซ้าย(รูปใหญ่ขึ้น) --*/
  .author-container2 {
    display: flex;
    justify-content: left;
    align-items: left;
    gap: 20px;
    margin-top: 30px;
  }
  .author-image2 img {
    width: 500px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
  }
  .author-text2 {
    max-width: 300px;
    font-size: 15px;
    line-height: 1.5;
  }
  /*-- หมายเหตุ: ส่วนนี้คือการกำหนด class ให้รูปอยู่ชิดซ้าย(ขนาดปานกลาง) --*/
  .author-container4 {
    display: flex;
    justify-content: left;
    align-items: left;
    gap: 20px;
    margin-top: 30px;
  }
  .author-image4 img {
    width: 350px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
  }
  .author-text4 {
    max-width: 3000px;
    font-size: 15px;
    line-height: 1.5;
  }
  /*-- หมายเหตุ: ส่วนนี้คือการกำหนด class ให้รูปอยู่ชิดซ้าย --*/
  .author-container3 {
    display: flex;
    justify-content: left;
    align-items: left;
    gap: 20px;
    margin-top: 30px;
  }
  .author-image3 img {
    width: 200px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
  }
  .author-text3 {
    max-width: 300px;
    font-size: 15px;
    line-height: 1.5;
  }


/* fade in/out ในแถบเมนูใหญ่ */
  section {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.4s ease;
    position: relative;
    height: 0;
    overflow: hidden;
  }
  
  section.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    height: auto;
    overflow: visible;
  }

  
/* เมนูย่อยใน Compare Algorithms */
.sub-menu ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0;
  margin-bottom: 20px;
}

.sub-menu a {
  text-decoration: none;
  color: black;
  font-weight: bold;
  padding: 6px 10px;
  transition: background-color 0.2s ease;
}

.sub-menu a:hover {
  background-color: #f0f0f0;
  border-radius: 4px;
}

.sub-menu a.active {
  border-bottom: 2px solid black;
}

/* ซ่อน/แสดง เนื้อหา */
.compare-content {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.4s ease;
  position: relative;  /* ให้ยึดตำแหน่งเดิม ไม่ลอยทับกัน */
  height: 0;
  overflow: hidden;
}

.compare-content.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  height: auto;
  overflow: visible;
}


/* เมนูย่อยใน My Algorithm */
.tab-btn-myalgo {
  background-color: #f1f5f9;
  color: #1e293b;
  border: none;
  padding: 14px 32px;
  font-size: 18px;
  font-weight: bold;
  font-family: inherit;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.tab-btn-myalgo:hover {
  background-color: #e2e8f0;
}

.tab-btn-myalgo.active {
  background-color: #c9e5f7;
  color: rgb(26, 26, 26);
}

/* เนื้อหา My Algorithm */
.myalgo-content {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.4s ease;
  position: relative;
  height: 0;
  overflow: hidden;
}

.myalgo-content.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  height: auto;
  overflow: visible;
}


/* ตกแต่ง sub menu */
.sub-menu ul {
  display: flex;
  justify-content: center;
  list-style: none;
  padding: 0;
  margin-bottom: 20px;
  gap: 8px;
}

.tab-btn {
  background-color: #f1f5f9;
  color: #1e293b;
  border: none;
  padding: 14px 32px;
  font-size: 18px; 
  font-weight: bold;
  font-family: Noto Sans Thai;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.tab-btn:hover {
  background-color: #e2e8f0;
}

.tab-btn.active {
  background-color: #c9e5f7;
  color: rgb(0, 0, 0);
}

.tab-btn.active {
  background-color: #c9e5f7;
  color: rgb(39, 39, 39);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15); /* เพิ่มเงา */
}


/* ตาราง */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px auto;
  font-size: 16px;
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

thead {
  background-color: #f5f5f5;
}

th, td {
  text-align: center;
  padding: 12px 15px;
  border: 1px solid #ddd;
}

tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

tbody tr:hover {
  background-color: #e6f7ff;
}

th {
  font-weight: bold;
  font-size: 18px;
}

td {
  font-size: 16px;
}

/* .txt */
.download-btn {
  display: inline-block;
  background-color: #73bae6;
  color: rgb(255, 255, 255);
  padding: 12px 24px;
  margin-top: 2px;
  text-decoration: none;
  font-weight: bold;
  border-radius: 8px;
  transition: background-color 0.3s;
}

.download-btn:hover {
  background-color: #2a8ecd;
}

/* ตัวเลขหัวข้อต่างๆ */
.resource-list {
  padding-left: 20px;
  font-size: 16px;
  margin-top: 20px;
}

.resource-list li {
  margin-bottom: 12px;
}

/* Run Again */
.recalculate-btn {
  display: inline-block;
  background-color: #73bae6;
  color: rgb(255, 255, 255);
  padding: 10px 20px;
  margin: 20px 0;
  font-size: 16px;
  font-family: Noto Sans Thai ;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.recalculate-btn:hover {
  background-color: #2a8ecd;
}

/* Run Again อยู่ฝั่งซ้ายของ h*/
.heading-with-button {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.heading-with-button h2 {
  margin: 0;
}

/* ขีดแนวตั้งสีเทาหน้าข้อความ */
.explain-block {
  border-left: 5px solid #eaeaea;
  padding-left: 15px;
  margin: 20px 0;
  color: #000000;
  font-size: 16px;
  line-height: 1.6;
}



/* -- หมายเหตุ: ส่วนนี้คือการโชว์รายละเอียด 8 ข้อ */
.hidden {
  display: none;
}

#steps-details {
  margin-top: 20px;
  background-color: #f8f8f8;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}


.toggle-steps-btn {
  background-color: #73bae6;
  color: #ffffff;
  padding: 10px 20px;
  font-size: 16px;
  font-family: "Noto Sans Thai";
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s;
  margin-top: 10px;
}

.toggle-steps-btn:hover {
  background-color: #2a8ecd;
}

/* -- หมายเหตุ: ส่วนนี้คือการเลื่อน (scroll) ของตาราง */
.table-wrapper {
  overflow-x: auto;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  margin-top: 20px;
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

th, td {
  text-align: center;
  padding: 8px 10px;
  border: 1px solid #ddd;
  font-size: 14px;
  line-height: 1.4;
}

thead {
  background-color: #f5f5f5;
}

tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

tbody tr:hover {
  background-color: #e6f7ff;
}

th {
  font-weight: bold;
  font-size: 17px;
}

/* -- หมายเหตุ: ส่วนนี้คือวีดีโอในหน้า Video Present */
.video-wrapper {
  width: 100%;
  max-width: none;
  margin: 0;
  margin-top: 30px;
  padding: 0;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  overflow: hidden;
}

video {
  width: 100%;
  display: block;
  box-sizing: border-box;
}

/* -- หมายเหตุ: ส่วนนี้คือปุ่มย้อนกลับไปข้างบน (back to top) */
.back-to-top-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 5px;
  margin-bottom: 10px;
}

#back-to-top {
  position: static;
  background-color: #9ed1f0;
  color: white;
  padding: 8px 12px;
  font-size: 18px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: none;
}

#back-to-top:hover {
  background-color: #799ac8;
}


.footer {
  text-align: center;
  padding: 20px;
  background-color: #f1f5f9;
  font-size: 14px;
  color: #64748b;
  margin-top: 40px;
}



/* -- หมายเหตุ: ส่วนนี้คือปุ่ม Dark Mode */
#toggle-theme {
  font-family: "Noto Sans Thai", sans-serif;
  font-size: 14px;
  font-weight: 500;
}


body.dark-mode {
  background: linear-gradient(135deg, #000000, #0f172a);
  color: #282828;
}

body.dark-mode #main-content {
  background: #282828;
}

body.dark-mode .top-bar,
body.dark-mode nav,
body.dark-mode section,
body.dark-mode .compare-content.active,
body.dark-mode .myalgo-content.active {
  background-color: #282828;
  color: #e2e8f0;
}

body.dark-mode .menu li a {
  color: #e2e8f0;
}

body.dark-mode .menu li a:hover {
  background-color: #565656;
}

body.dark-mode .menu li a.active {
  border-bottom: 2px solid #ffffff;
}

body.dark-mode {
  color: #e2e8f0;
}

body.dark-mode .menu li a,
body.dark-mode .sub-menu a,
body.dark-mode .tab-btn,
body.dark-mode .tab-btn-myalgo,
body.dark-mode .heading-with-button h2,
body.dark-mode .explain-block,
body.dark-mode .toggle-steps-btn {
  color: #e2e8f0 !important;
}

body.dark-mode .logo {
  color: #0264a1 !important;
}


/* ปรับสีตารางใน Dark Mode */
body.dark-mode table {
  background-color: #202020;
  color: #e2e8f0;
}

body.dark-mode thead {
  background-color: #1c1c1c;
}

body.dark-mode tbody tr:nth-child(even) {
  background-color: #242424;
}

body.dark-mode tbody tr:hover {
  background-color: #3b4b5a;
}

body.dark-mode th, 
body.dark-mode td {
  border: 1px solid #353535;
}

body.dark-mode pre, 
body.dark-mode code {
  color: #1b1c1d;
}

body.dark-mode pre {
  padding: 15px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: "Courier New", monospace;
  font-size: 14px;
  line-height: 1.6;
}
body.dark-mode pre, 
body.dark-mode code {
  background-color: #262626 !important;
  color: #e2e8f0 !important;
}

/* ปรับสี Sub Menu ใน Dark Mode */
body.dark-mode .tab-btn {
  background-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .tab-btn:hover {
  background-color: #475569;
}

body.dark-mode .tab-btn.active {
  background-color: #64748b;
  color: #ffffff;
}

body.dark-mode .tab-btn-myalgo {
  background-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .tab-btn-myalgo:hover {
  background-color: #475569;
}

body.dark-mode .tab-btn-myalgo.active {
  background-color: #64748b;
  color: #ffffff;
}

/* ปรับสีข้อความ zoom-level ใน Dark Mode */
body.dark-mode #zoom-level {
  color: #e2e8f0;
}

/* ปรับสีข้อความคลิกเพื่อดูรายละเอียด ใน Dark Mode */
body.dark-mode .toggle-steps-btn {
  background-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .toggle-steps-btn:hover {
  background-color: #475569;
}


body.dark-mode #steps-details {
  background-color: #262626;
  color: #e2e8f0;
  border: 1px solid #4b4b4b;
}

body.dark-mode #steps-details p,
body.dark-mode #steps-details li {
  color: #e2e8f0;
}

/* ปรับสี footer ใน Dark Mode */
body.dark-mode {
  background: #282828 !important; /* ปรับเป็นพื้นหลังเข้ม */
}

body.dark-mode .footer {
  background: linear-gradient(135deg, #262626, #1d1d1d);
  color: #e2e8f0;
}

/* Run Again ใน Dark Mode */
body.dark-mode .recalculate-btn {
  background-color: #334155;
  color: #e2e8f0;
  border: none;
}

body.dark-mode .recalculate-btn:hover {
  background-color: #475569;
}

/*-- หมายเหตุ: ส่วนนี้คือ ปุ่มดาวโหลด .txt ใน Dark Mode --*/
body.dark-mode .download-btn {
  background-color: #334155;
  color: #e2e8f0;
  border: none;
}

body.dark-mode .download-btn:hover {
  background-color: #475569;
}

/*-- หมายเหตุ: ส่วนนี้คือ ป๊อบอัพกดยืนยันดาวโหลด --*/
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  
  animation: fadeInModal 0.3s ease forwards;
  zoom: 1.25 !important;
  transform: scale(1) !important;
}

.modal-content {
  background-color: #fff;
  padding: 24px 30px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  max-width: 320px;
  width: 90%;
}

.modal-buttons {
  margin-top: 20px;
  display: flex;
  justify-content: space-around;
  gap: 12px;
}

.modal-buttons button {
  padding: 10px 20px;
  border: none;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}

#confirm-yes {
  background-color: #4caf50;
  color: white;
}

#confirm-no {
  background-color: #f44336;
  color: white;
}

body.dark-mode #confirm-modal .modal-content {
  background-color: #1d1d1d;
  color: #e2e8f0;
  border-radius: 10px;
}

body.dark-mode #confirm-modal .modal-buttons button {
  background-color: #334155;
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  margin: 10px 5px;
  border-radius: 6px;
  cursor: pointer;
}

body.dark-mode #confirm-modal .modal-buttons button:hover {
  background-color: #475569;
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-out {
  animation: fadeOut 0.35s forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}


/* เมนูย่อยใน Applied */
.applied-content {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.4s ease;
  position: relative;
  height: 0;
  overflow: hidden;
}

.applied-content.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  height: auto;
  overflow: visible;
}

.tab-btn-applied {
  background-color: #f1f5f9;
  color: #1e293b;
  border: none;
  padding: 14px 32px;
  font-size: 18px;
  font-weight: bold;
  font-family: Noto Sans Thai;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.tab-btn-applied:hover {
  background-color: #e2e8f0;
}

.tab-btn-applied.active {
  background-color: #c9e5f7;
  color: rgb(0, 0, 0);
}
