/* Universal Styles and Font */
:root {
  --primary-color: #286e2b; /* Green color for accents */
  --light-green: #e9f5e9;
  --dark-green: #388e3c;
  --yellow: #ebde25;
  --text-color: #333;
  --light-gray: #f4f4f4;
  --border-color: #e0e0e0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Kanit", sans-serif;
  color: var(--text-color);
  line-height: 1.6;
  background-color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ✅ เนื้อหาหลักของแต่ละหน้า */
.page-content {
  flex: 1; /* ดัน footer ลงล่าง */
  opacity: 0; /* ตอนเริ่มจาง */
  transition: opacity 1.25s ease;
}

.page-content.page-loaded {
  opacity: 1; /* โหลดเสร็จค่อย ๆ ชัด */
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header Section */
.header {
  position: relative;
  background-color: #fff;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
}

.logo-img {
  height: 60px;
  margin-right: 10px;
}

.logo-text {
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary-color);
}

.nav a {
  text-decoration: none;
  color: var(--text-color);
  margin-left: 20px;
  font-size: 1.15rem;
  font-weight: 500;
}

/* Hero Section - Carousel Full-Width */
.hero-section-carousel {
  position: relative;
  width: 100%;
  height: 700px; /* กำหนดความสูงของ carousel */
  overflow: hidden;
}

.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;

  transition:
    opacity 1.2s ease,
    transform 1.2s ease,
    filter 1.2s ease;

  transform: scale(1.02);
  filter: blur(6px);
}

.hero-slide.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  filter: blur(0);
}

.slide-background {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: brightness(100%); /* ทำให้ภาพมืดลงเล็กน้อยเพื่อให้ข้อความอ่านง่าย */
}

.hero-content-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

/* Dropdown Menu Styles */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
}

.dropdown-toggle::after {
  content: " \25BE"; /* เพิ่มสัญลักษณ์ลูกศรชี้ลง */
  font-size: 0.8em;
  margin-left: 5px;
  transition: transform 0.3s ease;
}

.dropdown:hover .dropdown-toggle::after {
  transform: rotate(-180deg);
}

.nav-link.dropdown-toggle {
  display: flex;
  align-items: center;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #fff;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  min-width: 250px;
  z-index: 1000;
  border-radius: 0 0 8px 8px; /* ทำให้มุมด้านล่างโค้งมน */
  padding: 10px 0; /* เพิ่ม padding ภายในเมนู */
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

/* แสดง Dropdown เมื่ออยู่บน hover */
.dropdown:hover .dropdown-menu {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.dropdown-menu a {
  color: var(--text-color);
  padding: 12px 20px;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

.dropdown-menu a:hover {
  background-color: var(--light-gray);
  color: var(--primary-color);
}

/* ปุ่ม Previous/Next - ปรับสีให้เข้ากับพื้นหลัง */
.hero-section-carousel .prev,
.hero-section-carousel .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  padding: 1rem;
  color: white;
  font-weight: bold;
  font-size: 1.5rem;
  transition: 0.6s ease;
  user-select: none;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  z-index: 10;
}

.hero-section-carousel .next {
  right: 15px;
}

.hero-section-carousel .prev {
  left: 15px;
}

.hero-section-carousel .prev:hover,
.hero-section-carousel .next:hover {
  background-color: rgba(0, 0, 0, 0.6);
}

/* จุดนำทางด้านล่าง */
.carousel-dots-bottom {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
}

.dot {
  cursor: pointer;
  height: 15px;
  width: 15px;
  margin: 0 4px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.dot.active,
.dot:hover {
  background-color: #717171;
}

/* Responsive */
@media (max-width: 768px) {
  .hero-section-carousel {
    height: 400px;
  }
  .hero-title {
    font-size: 2rem;
  }
  .hero-subtitle {
    font-size: 1rem;
  }
}

/* Poster Slideshow Styles */
.poster-slideshow-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
}

.poster-slide {
  display: none; /* ซ่อนภาพทั้งหมดไว้ก่อน */
  width: 100%;
  height: 100%;
}

.poster-slide img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Animation */
.fade {
  animation-name: fade;
  animation-duration: 1.5s;
}

@keyframes fade {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 1;
  }
}

/* Hero Section - ปรับปรุงใหม่ */
.hero-section {
  background: linear-gradient(135deg, #e9f5e9, #c8e6c9);
  padding: 4rem 0;
  text-align: center;
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  color: var(--yellow);
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(195, 12, 12, 0.1);
}

.hero-subtitle {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--yellow);
  margin-bottom: 2rem;
  text-shadow: 1px 1px 2px rgba(195, 12, 12, 0.1);
}

.hero-content {
  display: flex; /* ใช้ Flexbox เพื่อจัดเรียงข้อความและ carousel */
  justify-content: center;
  align-items: center;
  gap: 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.hero-text-content {
  flex: 1; /* ทำให้ส่วนนี้ขยายเต็มพื้นที่ที่เหลือ */
  text-align: left;
  max-width: 600px;
}

.hero-text-content p {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

/* Carousel Styles */
.carousel-container {
  position: relative;
  width: 300px; /* กำหนดขนาดของ Carousel */
  height: 300px;
  border-radius: 50%;
  overflow: hidden; /* ซ่อนส่วนเกินของภาพ */
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.carousel-slide {
  display: none; /* ซ่อนภาพทั้งหมดไว้ก่อน */
  width: 100%;
  height: 100%;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ปุ่ม Previous/Next */
.prev,
.next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 1rem;
  margin-top: -22px;
  color: white;
  font-weight: bold;
  font-size: 1.5rem;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

.prev {
  left: 0;
  border-radius: 0 3px 3px 0;
}

.prev:hover,
.next:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

/* จุดนำทาง */
.carousel-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.dot {
  cursor: pointer;
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active,
.dot:hover {
  background-color: #717171;
}

/* Animation */
.fade {
  animation-name: fade;
  animation-duration: 1.5s;
}

@keyframes fade {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .hero-content {
    flex-direction: column;
    text-align: center;
  }
  .hero-text-content {
    max-width: 100%;
  }
  .carousel-container {
    width: 100%;
    height: auto;
    border-radius: 10px;
    margin-top: 2rem;
  }
  .carousel-slide img {
    border-radius: 10px;
  }
}

/* Sections */
.section-title {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
  margin-top: 3rem;
}

/* Services Section */
.services-section {
  padding: 3rem 0;
  background-color: var(--light-gray);
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  text-align: center;
}

.service-item {
  background-color: #b3d9d9;
  border-radius: 10px;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s;
}

.service-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.service-item img {
  height: 80px;
  margin-bottom: 1rem;
}

.service-text {
  font-size: 1.15rem;
  font-weight: 500;
}

/* News Section */
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  padding-bottom: 5rem;
}

.news-item {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.3s;
  /* เพิ่มโค้ดส่วนนี้เพื่อกำหนดขนาดคงที่ */
  height: 500px; /* กำหนดความสูงคงที่ตามที่คุณต้องการ */
  display: flex;
  flex-direction: column;
}

.news-item:hover {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.news-img {
  width: 100%;
  /* กำหนดความสูงของรูปภาพให้คงที่ */
  height: 300px;
  object-fit: cover; /* ครอบตัดรูปภาพให้เต็มพื้นที่โดยไม่ผิดสัดส่วน */
}

/* ปรับปรุง Poster Slideshow */
.poster-slideshow-container {
  position: relative;
  width: 100%;
  /* กำหนดความสูงของ Slideshow container ให้คงที่ */
  height: 500px;
  overflow: hidden;
  border-radius: 10px;
}

.poster-slide img {
  width: 100%;
  height: 100%; /* ทำให้ภาพเต็มความสูงของ container */
  object-fit: cover;
}

.news-content {
  padding: 1rem;
  flex-grow: 1; /* ทำให้ส่วนเนื้อหาขยายเต็มพื้นที่ที่เหลือ */
  display: flex;
  flex-direction: column;
}

.news-content h3 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.news-content p {
  font-size: 1.15rem;
  color: #666;
  margin-bottom: 0.25rem;
}

.read-more {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  margin-top: auto; /* ดันปุ่มลงไปอยู่ด้านล่างสุด */
  display: inline-block;
}

/* Poster Slideshow Styles */
.poster-slideshow-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
}

.poster-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* เพิ่ม CSS สำหรับปุ่ม */
.poster-slideshow-container .prev,
.poster-slideshow-container .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 1rem;
  margin-top: -22px;
  color: white;
  font-weight: bold;
  font-size: 1.5rem;
  transition: 0.6s ease;
  user-select: none;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.poster-slideshow-container .next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

.poster-slideshow-container .prev {
  left: 0;
  border-radius: 0 3px 3px 0;
}

.poster-slideshow-container .prev:hover,
.poster-slideshow-container .next:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

/* ===== Header base ===== */
.header .header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nav-toggle {
  display: none;
  border: 0;
  background: transparent;
  padding: 10px;
  cursor: pointer;
}
.nav-toggle .bar {
  display: block;
  width: 24px;
  height: 2px;
  margin: 5px 0;
  background: #1f2937;
  border-radius: 999px;
}

/* dropdown desktop (hover ได้) */
.dropdown {
  position: relative;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  z-index: 50;
}
.dropdown:hover .dropdown-menu {
  display: block;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  /* ซ่อนเมนูจนกว่าจะกด hamburger */
  .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    display: none;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    z-index: 60;
  }
  .nav.is-open {
    display: block;
  }

  .nav-menu {
    display: flex;
    flex-direction: column;
    padding: 12px 16px 16px;
    gap: 6px;
  }

  .nav-link {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border-radius: 12px;
  }

  .nav-menu > a:last-child {
    border-bottom: none;
  }

  .nav-menu > .dropdown {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 6px;
  }

  /* ยกเลิก dropdown แบบ hover บนมือถือ */
  .dropdown:hover .dropdown-menu {
    display: none;
  }

  /* dropdown เป็น accordion */
  .dropdown-menu {
    position: static;
    border: 0;
    box-shadow: none;
    padding: 6px 0 0;
    border-radius: 0;
    display: none; /* เปิดด้วย JS */
  }
  .dropdown.is-open .dropdown-menu {
    display: block;
  }

  .dropdown-item {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
  }
}

/* Media Query สำหรับหน้าจอขนาดเล็ก */
@media (max-width: 1024px) {
  .news-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .news-grid {
    grid-template-columns: 1fr;
  }
  .news-item {
    height: auto; /* ยกเลิกความสูงคงที่บนมือถือ */
  }
  .news-img {
    height: 200px; /* ลดความสูงของรูปภาพบนมือถือ */
  }
}

/* ITA and Contact Section */
.footer-cta-section {
  background-color: var(--light-green);
  padding: 3rem 0;
}

.ita-group {
  text-align: center;
  margin-bottom: 2rem;
}

.ita-title {
  font-size: 2rem;
  font-weight: 700;
}

.ita-subtitle,
.ita-description {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.ita-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ✅ ปุ่ม (ใช้กับ <a class="ita-btn"> ) */
.ita-btn,
.ita-btn:visited {
  font-family: "Kanit", sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 10px 22px;
  min-width: 92px;

  background: #1f7a1f;
  color: #ffffff;

  font-weight: 600;
  border-radius: 8px;

  text-decoration: none; /* ✅ กันเส้นใต้ */
  border: 2px solid #111; /* ถ้าไม่อยากมีเส้นขอบ ดึงออกได้ */
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);

  transition:
    background 0.2s ease,
    transform 0.05s ease,
    box-shadow 0.2s ease;
}

.ita-btn:hover {
  background: #166316;
}

/* ✅ เปลี่ยนสี "เฉพาะตอนกดค้าง" */
.ita-btn:active {
  background: #1dab56;
  transform: translateY(1px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* ✅ ปีปัจจุบัน/หน้าปัจจุบัน */
.ita-btn.active {
  background: #14532d;
}

/* ✅ กันวง focus แปลก ๆ (ถ้าต้องการให้สวยขึ้น) */
.ita-btn:focus {
  outline: none;
}
.ita-btn:focus-visible {
  outline: 3px solid rgba(18, 240, 18, 0.783);
  outline-offset: 3px;
}

.ita-images {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.ita-img {
  max-width: 300px;
  border-radius: 10px;
}

/* Footer Section */
.footer {
  background-color: #f1f1f1;
  padding: 2rem 0;
  text-align: center;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-contact-item {
  background-color: #b3d9d9;
  border-radius: 10px;
  padding: 1.5rem;
}

.icon-label {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 1rem;
}

.icon-label img {
  height: 30px;
}

.contact-number {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.contact-info {
  font-size: 0.9rem;
}

.footer-bottom {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.logo-footer {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.logo-footer img {
  height: 30px;
  margin-right: 10px;
}

.logo-footer span {
  font-weight: 600;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .service-grid,
  .news-grid,
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .ita-images {
    flex-direction: column;
    align-items: center;
  }
  .ita-img {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    text-align: center;
  }
  .nav {
    margin-top: 1rem;
  }
  .nav a {
    margin: 0 10px;
  }
  .hero-title {
    font-size: 2rem;
  }
  .hero-subtitle {
    font-size: 1rem;
  }
  .hero-content {
    align-items: center;
    text-align: center;
    padding-left: 0;
  }
  .hero-circle {
    display: none;
  }
  .service-grid,
  .news-grid,
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .footer-bottom {
    text-align: center;
  }
}

.visitor-stat {
  margin-left: 12px;
  margin-top: 12px;
  margin-bottom: 15px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 14px;
}
.visitor-stat .v-item {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 6px 12px;
}
.visitor-stat b {
  font-size: 15px;
}
