/* --- CSS Variables (ตัวแปรสี) --- */
:root {
  --primary-color: #41826e;
  /* สีเขียวตุ่นๆ */
  --white-color: #ffffff;
  --dark-grey-color: #333333;
  /* สีตัวอักษรหลัก */
  --light-grey-color: #f4f7f6;
  /* สีพื้นหลังสลับ */
  --border-color: #e0e0e0;
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* --- Global Styles --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  /* กันเมนูบังหัวข้อตอนกดลิงก์ */
}

body {
  font-family: 'Prompt', sans-serif;
  line-height: 1.7;
  color: var(--dark-grey-color);
  background-color: var(--white-color);
  padding-top: 80px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

h1,
h2,
h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.section-title {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 3rem;
}

.section-bg {
  background-color: var(--light-grey-color);
}

section {
  padding: 80px 0;
}

a {
  text-decoration: none;
}

/* --- Header & Navbar --- */
.header {
  background-color: var(--white-color);
  box-shadow: var(--shadow);
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 1000;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 80px;
}

.logo img {
  height: 50px;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 30px;
}

.nav-link {
  text-decoration: none;
  color: var(--dark-grey-color);
  font-weight: 400;
  transition: color 0.3s ease;
}

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

.hamburger {
  display: none;
  cursor: pointer;
}

.bar {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px auto;
  background-color: var(--dark-grey-color);
  transition: all 0.3s ease-in-out;
}

/* --- Hero Section --- */
.hero {
  height: 100vh;
  position: relative;
  overflow: hidden;
  color: var(--white-color);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.slider {
  position: absolute;
  top: 0;
  left: 0;
  width: 500%;
  height: 100%;
  display: flex;
  transition: transform 0.8s ease-in-out;
  z-index: 1;
}

.slide {
  width: 20%;
  height: 100vh;
}

.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.hero-content {
  position: relative;
  z-index: 3;
  max-width: 800px;
}

.hero-title {
  font-size: 3.5rem;
  color: var(--white-color);
  font-weight: 600;
}

.hero-subtitle {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  font-weight: 300;
}

.btn {
  display: inline-block;
  background-color: var(--primary-color);
  color: var(--white-color);
  padding: 12px 30px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.3s ease;
}

.btn:hover {
  background-color: #356a5a;
}

.slider-dots {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 3;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.dot.active {
  background-color: var(--white-color);
}

/* --- Services Section --- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  text-align: center;
}

.service-link {
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
}

.service-item {
  background: var(--white-color);
  padding: 2rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
}

.service-item:hover {
  transform: translateY(-10px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.service-icon {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

/*
===============================================
  ACCORDION STYLES (สำหรับหน้า missions.html)
===============================================
*/

.accordion {
  max-width: 800px;
  margin: 0 auto;
  /* จัดให้อยู่กลางจอ */
}

.accordion-item {
  border-bottom: 1px solid var(--border-color);
}

.accordion-item:first-child {
  border-top: 1px solid var(--border-color);
}

.accordion-header {
  background-color: transparent;
  border: none;
  width: 100%;
  padding: 1.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  text-align: left;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--dark-grey-color);
  transition: background-color 0.3s ease;
  font-family: 'Prompt', sans-serif;
}

.accordion-header:hover,
.accordion-item.active .accordion-header {
  background-color: var(--light-grey-color);
  color: var(--primary-color);
}

.accordion-icon {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--primary-color);
  transition: transform 0.3s ease-in-out;
  flex-shrink: 0;
  /* ป้องกันไอคอนถูกบีบ */
  margin-left: 1rem;
}

.accordion-item.active .accordion-header .accordion-icon {
  transform: rotate(45deg);
}

.accordion-panel {
  max-height: 0;
  /* ซ่อนเนื้อหาไว้ตอนแรก */
  overflow: hidden;
  background-color: var(--white-color);
  transition: max-height 0.4s ease-out, padding 0.4s ease-out;
  /* เพิ่ม padding transition */
  padding: 0 2rem;
  /* เพิ่ม padding ซ้ายขวา แต่บนล่างเป็น 0 */
}

.accordion-item.active .accordion-panel {
  padding: 1.5rem 2rem;
  /* เพิ่ม padding บนล่างเมื่อเปิด */
}


.accordion-content {
  color: #555;
}

.accordion-content p,
.accordion-content ul {
  margin-bottom: 1rem;
}

.accordion-content ul {
  list-style-type: disc;
  padding-left: 25px;
  /* เพิ่มระยะห่างให้ list */
}

.accordion-content li {
  margin-bottom: 0.8rem;
}

.read-more {
  color: var(--primary-color);
  font-weight: 600;
}


/* --- Footer Section --- */
.footer {
  background-color: var(--primary-color);
  color: var(--white-color);
  padding: 50px 0 0;
}

.footer-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  padding-bottom: 40px;
}

.footer h4 {
  margin-bottom: 1rem;
  color: var(--white-color);
  font-size: 1.2rem;
}

.footer p,
.footer a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  display: block;
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

.footer a:hover {
  color: var(--white-color);
}

.footer ul {
  list-style: none;
}

.footer-bottom {
  text-align: center;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/*
=====================================
  ANIMATION & RESPONSIVE STYLES
=====================================
*/

/* --- Fade-in Animation on Scroll --- */
.section-fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.section-fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}


/* --- Responsive (for Mobile) --- */
@media (max-width: 768px) {

  /* -- Hamburger Menu -- */
  .hamburger {
    display: block;
    /* แสดงปุ่ม Hamburger ในมือถือ */
  }

  .hamburger.active .bar:nth-child(2) {
    opacity: 0;
  }

  .hamburger.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }

  .hamburger.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

  .nav-menu {
    position: fixed;
    left: -100%;
    /* ซ่อนเมนูไปทางซ้าย */
    top: 80px;
    flex-direction: column;
    background-color: var(--white-color);
    width: 100%;
    text-align: center;
    transition: 0.3s ease-in-out;
    box-shadow: var(--shadow);
  }

  .nav-menu.active {
    left: 0;
    /* แสดงเมนูเมื่อกด */
  }

  .nav-menu li {
    padding: 1rem 0;
  }

  /* -- General Layout Adjustments -- */
  section {
    padding: 60px 0;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .section-title {
    font-size: 2rem;
  }

  /* -- Page-specific Adjustments -- */
  .about-container {
    flex-direction: column;
    text-align: center;
    /* จัดกลางให้สวยงาม */
  }

  .about-image {
    margin-bottom: 2rem;
  }

  .services-grid,
  .news-grid {
    grid-template-columns: 1fr;
    /* ให้แสดงแค่ 1 คอลัมน์ในมือถือ */
  }

  .accordion-header {
    font-size: 1rem;
    padding: 1.2rem 0.8rem;
  }

  .accordion-panel {
    padding: 0 1rem;
    /* ลด padding ซ้ายขวาในมือถือ */
  }

  .accordion-item.active .accordion-panel {
    padding: 1rem;
  }

  .footer-container {
    text-align: center;
  }
}

/* --- Page Header (แถบหัวข้อสีเขียว) --- */
.page-header {
  background-color: var(--primary-color);
  color: var(--white-color);
  padding: 40px 0;
  text-align: center;
}

.page-header h1 {
  color: var(--white-color);
  font-size: 2.5rem;
}

.page-header p {
  font-size: 1.1rem;
  font-weight: 300;
}

/*
=====================================
  ADMIN PAGE STYLES
=====================================
*/
/* =================================================================== */
/* =============       ADMIN PAGE SPECIFIC STYLES        ============= */
/* =================================================================== */

/* --- Layout & Cards --- */
.admin-card {
  background-color: var(--white-color);
  padding: 2rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* 2 คอลัมน์เท่าๆ กัน */
  gap: 2rem;
}

/* --- Form Elements --- */
.form-inline {
  display: flex;
  gap: 1rem;
}

.form-inline input[type="text"] {
  flex-grow: 1;
  /* ทำให้ช่อง input ขยายเต็มพื้นที่ */
}

/* สไตล์ input และ select ให้ดูโมเดิร์น */
.admin-card input[type="text"],
.admin-card select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: 'Prompt', sans-serif;
  font-size: 1rem;
}

/* --- Buttons --- */
.btn-admin {
  background-color: var(--primary-color);
  color: var(--white-color);
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Prompt', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  transition: background-color 0.3s ease;
  white-space: nowrap;
  /* ป้องกันปุ่มตกบรรทัด */

}

.btn-admin:hover {
  background-color: #356a5a;
}

.btn-danger {
  background-color: #e74c3c;
  /* สีแดงสำหรับปุ่มอันตราย */
}

.btn-danger:hover {
  background-color: #c0392b;
}

.admin-controls {
  display: flex;
  gap: 1rem;
}


/* --- Candidate List --- */
#candidates-list-admin .placeholder {
  color: #888;
  font-style: italic;
}

.candidate-item-admin {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.candidate-item-admin .delete-btn {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: bold;
}


/* --- Code Display --- */
#code-display {
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--primary-color);
  background-color: var(--light-grey-color);
  text-align: center;
  padding: 1rem;
  border-radius: 8px;
  letter-spacing: 5px;
  /* ทำให้ตัวเลขห่างกัน อ่านง่าย */
  margin-bottom: 1rem;
}

.help-text {
  font-size: 0.9rem;
  color: #777;
  margin-top: 1rem;
  text-align: center;
}


/* --- Responsive for Admin Page --- */
@media (max-width: 768px) {
  .admin-grid {
    grid-template-columns: 1fr;
    /* บนมือถือให้แสดง 1 คอลัมน์ */
  }

  .form-inline,
  .admin-controls {
    flex-direction: column;
  }

  #code-display {
    font-size: 2rem;
  }

  .admin-card-header {
    padding-top: 1.5rem;
  }
}

/* --- Admin Page: Vote Adjustment Panel (+/- buttons) --- */
#voting-list-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.vote-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid #eee;
  border-radius: 8px;
}

.vote-item-name {
  font-size: 1.1rem;
  flex-grow: 1;
  /* ดันให้ส่วน control ไปอยู่ด้านขวา */
}

.vote-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.vote-count {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-color);
  min-width: 40px;
  /* กำหนดความกว้างขั้นต่ำให้ตัวเลขไม่ขยับ */
  text-align: center;
}

.vote-btn {
  background-color: var(--light-grey-color);
  border: 1px solid #ddd;
  color: var(--dark-grey-color);
  width: 35px;
  height: 35px;
  border-radius: 50%;
  /* ทำให้ปุ่มกลม */
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
  /* จัดตำแหน่ง + - ให้อยู่กลางปุ่ม */
  transition: background-color 0.2s, color 0.2s;
}

.vote-btn:hover {
  background-color: var(--primary-color);
  color: var(--white-color);
}

/*
=====================================
  VOTING PAGE STYLES
=====================================
*/
.vote-section {
  padding-top: 150px;
  /* ดัน content ลงมาไม่ให้ถูก header บัง */
  padding-bottom: 80px;
  background-color: var(--light-grey-color);
  min-height: 100vh;
}

.vote-container {
  max-width: 500px;
  /* ทำให้กล่องไม่กว้างเกินไป ดูสวยงาม */
}

.vote-card {
  background-color: var(--white-color);
  padding: 2rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  text-align: center;
}

.vote-card h1,
.vote-card h2 {
  margin-top: 0;
}

#code-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: 'Prompt', sans-serif;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 5px;
  margin: 1rem 0;
}

.btn-vote {
  background-color: var(--primary-color);
  color: var(--white-color);
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Prompt', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  transition: background-color 0.3s ease;
  width: 100%;
}

.btn-vote:hover {
  background-color: #356a5a;
}

.status-message {
  margin-top: 1rem;
  font-weight: bold;
}

.status-message.error {
  color: #e74c3c;
}

/* --- Candidate Options (Radio Buttons) --- */
#candidate-options {
  margin: 2rem 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.candidate-label {
  display: block;
  background-color: var(--light-grey-color);
  padding: 1rem;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.3s, background-color 0.3s;
  display: flex;
  align-items: center;
}

.candidate-label:hover {
  background-color: #e9eeed;
}

/* ซ่อน radio button เดิม */
.candidate-label input[type="radio"] {
  display: none;
}

/* สร้างวงกลม radio button ใหม่ */
.custom-radio {
  width: 20px;
  height: 20px;
  border: 2px solid #aaa;
  border-radius: 50%;
  margin-right: 15px;
  display: inline-block;
  position: relative;
}

/* เมื่อ radio ถูกเลือก ให้ label เปลี่ยนสไตล์ */
.candidate-label input[type="radio"]:checked+.custom-radio {
  border-color: var(--primary-color);
}

/* สร้างวงกลมข้างในเมื่อถูกเลือก */
.candidate-label input[type="radio"]:checked+.custom-radio::after {
  content: '';
  width: 10px;
  height: 10px;
  background-color: var(--primary-color);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.candidate-name {
  font-size: 1.1rem;
}

/* Utility class สำหรับซ่อน Element */
.hidden {
  display: none;
}

/*
=====================================
  RESULTS PAGE STYLES
=====================================
*/
.results-section {
  padding-top: 150px;
  padding-bottom: 80px;
  background-color: var(--light-grey-color);
  min-height: 100vh;
}

#total-votes-display {
  text-align: center;
  font-size: 1.2rem;
  color: #555;
  margin-bottom: 2.5rem;
  font-weight: 600;
}

#results-chart-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  /* ระยะห่างระหว่างแท่งกราฟ */
}

.result-item {
  width: 100%;
}

.result-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.result-info .candidate-name {
  font-size: 1.2rem;
  font-weight: 600;
}

.result-info .vote-count-text {
  font-size: 1.1rem;
  color: var(--primary-color);
  font-weight: bold;
}

.progress-bar {
  width: 100%;
  height: 30px;
  background-color: #e0e0e0;
  border-radius: 15px;
  overflow: hidden;
  /* ทำให้ fill ที่เกินขอบถูกซ่อน */
}

.progress-fill {
  height: 100%;
  background-color: var(--primary-color);
  width: 0%;
  /* เริ่มต้นที่ 0% แล้ว JS จะมาอัปเดต */
  border-radius: 15px;
  transition: width 0.5s ease-in-out;
  /* เพิ่ม animation ตอนคะแนนเปลี่ยน */
}

/* --- Style for the new button on thank you page --- */
.btn-results {
  margin-top: 1.5rem;
  /* เพิ่มระยะห่างด้านบนให้ปุ่ม */
  display: inline-block;
  /* ทำให้ margin-top ทำงานได้ */
}

/* --- CSS สำหรับจัดกลาง Card สร้างรหัสโดยเฉพาะ --- */
.code-generator-card {
  display: flex;
  flex-direction: column;
  /* 1. สั่งให้ทุกอย่างเรียงจากบนลงล่าง */
  align-items: center;
  /* 2. สั่งให้ทุกอย่างอยู่กึ่งกลางแนวนอน */
  text-align: center;
  /* 3. เผื่อข้อความบางส่วนไม่ยอมกลาง */
}

/* เพิ่มระยะห่างระหว่างปุ่มกับข้อความด้านบนให้สวยงาม */
.code-generator-card .btn-admin {
  margin-top: 1rem;
}

/* ==========================================================================
   Admin Panel Styles (สไตล์สำหรับหน้าแอดมินโดยเฉพาะ)
   ========================================================================== */

/* คลาสสำหรับซ่อน/แสดงส่วนต่างๆ */
.hidden {
  display: none !important;
}

/* การ์ดหลักในหน้าแอดมิน */
.admin-card {
  background-color: #ffffff;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  margin-bottom: 2rem;
}

/* ฟอร์มที่เรียงเป็นแถวเดียวกัน */
.form-inline {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.form-inline input[type="text"] {
  flex-grow: 1;
  /* ทำให้ช่องกรอกยาวเต็มพื้นที่ที่เหลือ */
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 1rem;
  font-family: 'Prompt', sans-serif;
}

/* ปุ่มในหน้าแอดมิน */
.btn-admin {
  background-color: var(--primary-color);
  color: var(--white-color);
  padding: 12px 25px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-family: 'Prompt', sans-serif;
  transition: background-color 0.3s ease;
  white-space: nowrap;
  /* ป้องกันปุ่มขึ้นบรรทัดใหม่ */
}

.btn-admin:hover {
  background-color: #356a5a;
}

/* ปุ่มสีแดงสำหรับลบ */
.btn-admin.btn-danger {
  background-color: #e74c3c;
}

.btn-admin.btn-danger:hover {
  background-color: #c0392b;
}

/* กล่องแสดงรายการโพลทั้งหมด */
#polls-list-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* สไตล์สำหรับโพลแต่ละรายการ */
.poll-item-admin {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.poll-info h4 {
  margin: 0 0 5px 0;
  color: var(--primary-color);
}

.poll-info p {
  margin: 0;
  font-size: 0.9rem;
  color: #555;
}

/* ส่วนของปุ่มจัดการ */
.poll-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  /* ป้องกันปุ่มถูกบีบ */
}

/* สถานะของโพล */
.poll-status-display span {
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 0.8rem;
  color: #fff;
}

.poll-status-display .status-active {
  background-color: #2ecc71;
  /* สีเขียว */
}

.poll-status-display .status-inactive {
  background-color: #95a5a6;
  /* สีเทา */
}

/* ข้อความ Placeholder */
.placeholder {
  color: #888;
  text-align: center;
  padding: 1rem;
}


/* --- Responsive for Admin Panel --- */
@media (max-width: 768px) {

  /* ทำให้ฟอร์มเรียงจากบนลงล่างในมือถือ */
  .form-inline {
    flex-direction: column;
    align-items: stretch;
    /* ทำให้ input และ button กว้างเต็ม */
  }

  /* ทำให้รายการโพลเรียงจากบนลงล่างในมือถือ */
  .poll-item-admin {
    flex-direction: column;
    align-items: flex-start;
    /* จัดชิดซ้าย */
    gap: 1rem;
  }

  .poll-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* จัดปุ่มเป็น 2 คอลัมน์ */
  }

  .poll-actions .delete-poll-btn {
    grid-column: 1 / -1;
    /* ทำให้ปุ่มลบกว้างเต็มแถว */
  }
}

/* --- Poll List Section --- */
.poll-list-section {
  padding: 40px 0;
  background-color: #f9f9f9;
}

#poll-list-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* ระยะห่างระหว่างแต่ละโพล */
}

.poll-item {
  background-color: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  /* ทำให้รองรับจอเล็ก */
  gap: 15px;
}

.poll-info {
  flex-grow: 1;
  /* ให้ส่วนข้อมูลยืดเต็มที่ */
}

.poll-title {
  margin: 0 0 5px 0;
  font-size: 1.4rem;
  color: #333;
}

.poll-code {
  margin: 0;
  color: #666;
  font-size: 1rem;
}

.poll-code span {
  font-weight: bold;
  color: var(--primary-color);
  background-color: #eaf3f1;
  padding: 3px 8px;
  border-radius: 4px;
}

.poll-status {
  font-weight: bold;
  padding: 5px 15px;
  border-radius: 50px;
  font-size: 0.9rem;
}

.poll-status.active {
  color: #28a745;
  background-color: #eaf7ec;
}

.poll-status.inactive {
  color: #6c757d;
  background-color: #f1f2f3;
}

.poll-actions {
  display: flex;
  gap: 10px;
}

.btn-activate {
  background-color: #28a745;
}

.btn-activate:hover {
  background-color: #218838;
}

.btn-view-results {
  background-color: #007bff;
}

.btn-view-results:hover {
  background-color: #0069d9;
}

/* --- Responsive for Poll List --- */
@media (max-width: 768px) {
  .poll-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .poll-actions {
    width: 100%;
    margin-top: 15px;
  }

  .poll-actions button {
    width: 100%;
  }
}

/* --- iOS-style Toggle Switch --- */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  vertical-align: middle;
}

.ios-switch input {
  display: none;
}

.ios-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #bbb;
  transition: .2s;
  border-radius: 34px;
}

.ios-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 0 2px #999;
}

.ios-switch input:checked+.ios-slider {
  background-color: #41d66e;
}

.ios-switch input:checked+.ios-slider:before {
  transform: translateX(20px);
}

.ios-switch input:disabled+.ios-slider {
  background: #ddd;
  cursor: not-allowed;
}

.ios-toggle-label {
  margin-left: 8px;
  font-size: 1em;
  color: #444;
}

/* เพิ่มในส่วน CSS ของคุณ */
.btn-edit {
  background-color: #ffc107 !important;
  color: #000 !important;
}

/* สำหรับปุ่มแก้ไขในหน้าแอดมิน */
button[data-edit-poll] {
  background-color: #ffc107;
  color: #000;
  padding: 8px 11px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.3s;
}

button[data-edit-poll]:hover {
  background-color: #e0a800;
}

.expired-text {
  color: red;
}

/* =========================
   REPAIR APP STYLES (Addon)
   ใช้คู่กับ voting/style.css
   ========================= */

/* Generic form rows */
.form-row {
  margin-bottom: 0.9rem;
}

.form-row label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #333;
}

.form-row input[type="text"],
.form-row input[type="email"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: 'Prompt', sans-serif;
  font-size: 1rem;
  transition: box-shadow .15s, border-color .15s;
  background: #fff;
}

.form-row textarea {
  resize: vertical;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: #a9d3c8;
  box-shadow: 0 0 0 3px rgba(65, 130, 110, 0.12);
}

/* Status message (error/info) */
.status-message {
  font-size: 0.95rem;
  margin-top: 6px;
  color: #666;
}

.status-message.error {
  color: #e74c3c;
  font-weight: 600;
}

/* Cards for repair app consistent with vote-card */
.repair-card,
.tracking-card,
.admin-card-repair {
  position: relative;
  background-color: #ffffff;
  padding: 1.2rem 1.3rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}
.highlight-card {
  border-color: var(--primary-color);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.5),
              0 0 40px rgba(0, 255, 136, 0.3),
              inset 0 0 20px rgba(0, 255, 136, 0.1);
  transition: all 0.3s ease;
}

/* Center container helper */
.center-container {
  max-width: 760px;
  margin: 0 auto;
}

/* Badge/pill */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  border-radius: 999px;
  font-weight: 600;
  background: #eef3f2;
  color: #2d6a5a;
}

/* Ticket list/grid */
.ticket-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .ticket-list.grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .ticket-list.grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.ticket-card {
  border: 1px solid #e8eceb;
  border-radius: 10px;
  background: #fff;
  padding: 0.95rem 1rem;
  transition:
    box-shadow 0.2s ease-out,
    transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    border-color 0.2s ease-out,
    opacity 0.5s ease-out;
  transform: translateY(20px) scale(0.98);
  opacity: 0;
  /* Stagger delay controlled by JavaScript */
  --delay: 0ms;
  transition-delay: var(--delay);
}

.ticket-card.loaded {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.ticket-card:hover {
  border-color: #d7e5e1;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px) scale(1); /* Reset scale on hover */
}

.ticket-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}

.ticket-title {
  font-weight: 700;
  color: #2e6b5a;
  font-size: 1.05rem;
  line-height: 1.2;
}

.ticket-meta {
  color: #667;
  font-size: 0.93rem;
}

.ticket-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Status background coloring for cards (admin list) */
.status-new {
  background: #fff8e1;
  /* light yellow */
}

.status-inprogress {
  background: #f3f4f6;
  /* light grey */
}

.status-done {
  background: #e8f5e9;
  /* light green */
}

/* Small pill for status label */
.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.status-pill.new {
  background: #ffe9b3;
  color: #705b12;
}

.status-pill.inprogress {
  background: #e5e7eb;
  color: #374151;
}

.status-pill.done {
  background: #bfe8c8;
  color: #12573f;
}

/* Progress bar (tracking + admin detail) */
.progress-track {
  width: 100%;
  height: 12px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #9aa0a6;
  transition: width .35s ease-in-out, background-color .25s ease-in-out;
}

/* color states by progress */
.progress-gray {
  background: #9aa0a6;
}

/* 0% */
.progress-yellow {
  background: #f6c344;
}

/* 25/50/75% */
.progress-green {
  background: #41a36e;
}

/* 100% */

/* Step checklist inside admin detail */
.step-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* Search bar (tracking) */
.search-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-bar input[type="text"] {
  flex: 1 1 260px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 1rem;
}

.search-bar button {
  padding: 12px 18px;
}

/* Empty/placeholder text */
.placeholder {
  text-align: center;
  color: #777;
}

/* Load more */
.load-more-wrap {
  text-align: center;
  margin-top: 12px;
}

.load-more-btn {
  background: #e9ecef;
  color: #333;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.load-more-btn:hover {
  background: #dfe4e7;
}

/* Detail modal (admin) */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0); /* Start fully transparent */
  display: flex; /* Always flex to allow transitions */
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0; /* Start invisible */
  pointer-events: none; /* Ignore clicks when hidden */
  transition:
    opacity 0.3s ease,
    background 0.3s ease;
}

.modal.show {
  opacity: 1;
  pointer-events: auto; /* Allow clicks when visible */
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
}

.modal-card {
  width: min(760px, 92vw);
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem 1.3rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .6rem;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2e6b5a;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: #666;
}

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 720px) {
  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.detail-item {
  background: #f8faf9;
  border: 1px solid #e8eceb;
  border-radius: 8px;
  padding: 10px 12px;
}

.detail-item h5 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: #345;
}

.detail-item p {
  margin: 0;
  color: #333;
}

/* Assign/select tech */
.tech-assign {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.tech-assign select {
  min-width: 180px;
}

/* Action bar in modal bottom */
.modal-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Disabled overlay for done ticket (admin) */
.readonly-mask {
  opacity: 0.7;
  pointer-events: none;
}

/* Little helper spacing */
.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-20 {
  margin-top: 20px;
}

/* Compact small text */
.text-small {
  font-size: 0.92rem;
  color: #666;
}

/* Link-like button */
.btn-link {
  background: transparent;
  color: #19735d;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* Button variants to blend with site */
.btn-secondary {
  background: #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-secondary:disabled {
  background: #bebebe;
  cursor: not-allowed;
}

.btn-info {
  background: #007bff;
  color: #fff;
}

.btn-info:hover {
  background: #0069d9;
}

/* Small tag group */
.tag {
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.85rem;
  border-radius: 999px;
  background: #eef3f2;
  color: #2d6a5a;
  font-weight: 600;
}

.tag.gray {
  background: #e9ecef;
  color: #333;
}

.tag.yellow {
  background: #fff1bf;
  color: #6b550a;
}

.tag.green {
  background: #c5eed2;
  color: #0e4a37;
}

/* Helper to align center */
.center {
  text-align: center;
}

/* Ensure vote-section spacing works well for repair pages too */
.repair-section,
.tracking-section,
.admin-repair-section {
  padding-top: 150px;
  padding-bottom: 80px;
  background-color: var(--light-grey-color);
  min-height: 100vh;
}

/* Ensure buttons inherit Prompt font */
button,
input,
select,
textarea {
  font-family: 'Prompt', sans-serif;
}

/* สีปุ่มใหม่ */
.btn-primary {
  background-color: #2196F3;
  color: white;
}

.btn-success {
  background-color: #4CAF50;
  color: white;
}

/* ปุ่มเมื่อ disabled */
.btn-admin:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* สำหรับแสดงสถานะรายละเอียด */
.status-detail {
  font-size: 0.9rem;
  color: #666;
  font-style: italic;
  margin-top: 0.5rem;
}

/* สำหรับการ์ดเคส */
.ticket-card .status-detail {
  font-size: 0.85rem;
  margin: 0.5rem 0 0.5rem;
  padding: 0 0.5rem;
}

.ticket-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* สำหรับเคสที่ปิดก่อนครบขั้นตอน */
.status-pill.closed {
  background-color: #9c27b0;
  color: white;
}

.status-closed {
  border-left: 4px solid #9c27b0;
}

.close-reason {
  color: #d32f2f;
  font-style: italic;
  font-size: 0.85rem;
}

.text-red {
  color: #d32f2f;
}

/* สำหรับปุ่มใน ticket-actions */
.ticket-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.status-pill.started {
  background-color: #6c757d;
  color: white;
}

.status-pill.approved {
  background-color: #6f42c1;
  color: white;
}

.status-pill.inprogress1 {
  background-color: #fd7e14;
  color: white;
}

.status-pill.inprogress2 {
  background-color: #20c997;
  color: white;
}

.status-pill.inprogress3 {
  background-color: #17a2b8;
  color: white;
}

.status-card.started {
  border-left: 4px solid #6c757d;
}

.status-card.approved {
  border-left: 4px solid #6f42c1;
}

.status-card.inprogress1 {
  border-left: 4px solid #fd7e14;
}

.status-card.inprogress2 {
  border-left: 4px solid #20c997;
}

.status-card.inprogress3 {
  border-left: 4px solid #17a2b8;
}

.green-counter-box {
    padding: 11px 10px 11px 14px;
    font-size: 0.99rem;
}
.green-counter-box button {
    color: #fff;
    font-size: 1.3em;
    font-family: Arial, Helvetica, sans-serif;
}
.green-counter-popup {
  position: fixed;
  bottom: 25px; left: 25px;
  z-index: 10001;
  min-width: 210px;
  transform: translateX(-250px);
  font-family: 'Prompt', sans-serif;
  transition:
        transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        opacity 0.3s ease-out;
    pointer-events: none;
}
.green-counter-popup.show {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}
.green-counter-popup.hide {
    transform: translateX(-250px);
    opacity: 0;
    pointer-events: none;
}
.green-counter-box {
  background: #fff;
  color: #222;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18), 0 1.5px 0 #41826e;
  min-width: 170px;
  min-height: 60px;
  position: relative;
  display: flex; flex-direction: column;
}
.green-counter-title {
  color: #41826e;
  font-weight: 600;
  margin-bottom: 3px;
  font-size: 1.08em;
  letter-spacing: 0.01em;
}
.green-counter-values {
  color: #222;
  letter-spacing: 0.03em;
  font-weight: 400;
}
.green-counter-values b { color: #19705A; font-size: 1.05em; font-weight: 700; }
.green-counter-close-btn {
  position: absolute;
  top: 5px; right: 10px;
  background: #41826e;
  border: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: background .16s;
  z-index: 2;
  padding: 0;
}
.green-leaf-bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.17, 0.67, 0.15, 1);
}

.green-leaf-bg::before {
    content: "\f06c";
    font-family: "Font Awesome 7 Free";
    font-weight: 900;
    position: absolute;
    left: 100px;
    top: 15px;
    color: rgba(29, 124, 96, 0.12);
    font-size: 80px;
    transform: rotate(-15deg);
    line-height: 1;
    transition: 1s;
}
.green-counter-popup:hover .green-leaf-bg::before {
    transform: translateX(10%) scale(1.3);
    transition: 1s;
}

.green-counter-close-btn:hover { background: #ba1e1e; }
#greenCounterThisMonth, #greenCounterTotal {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}
#greenCounterThisMonth.animate, #greenCounterTotal.animate {
    opacity: 1;
    transform: translateY(0);
}
@keyframes fadeIn {from{ opacity:0; transform:translateY(36px) scale(.95);} to{ opacity:1; transform:none;}}
@keyframes fadeOut {from { opacity: 1; transform: none;} to { opacity: 0; transform: translateY(36px) scale(0.95);}}