/* ============================================================
   TI Survey — Main Navigation (menu.php)
   ย้ายมาจาก <style> ใน menu.php เพื่อแก้ไขจุดเดียวมีผลทุกหน้า
   ============================================================ */

/* ===== NAV MENU - White Theme ===== */
.navmenu ul {
  display: flex;
  align-items: center;
  gap: 0;
}
.navmenu ul li a {
  font-size: 16px !important;
  font-weight: 800 !important;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #0d3b8e !important;
  padding: 22px 18px !important;
  transition: all 0.3s ease;
  position: relative;
  white-space: nowrap;
}
.navmenu ul li a::after {
  content: '';
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: linear-gradient(135deg, #e8611a 0%, #f0943a 100%);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.navmenu ul li a:hover::after,
.navmenu ul li a.active::after {
  width: 80%;
}
.navmenu ul li a:hover,
.navmenu ul li a.active {
  color: #e8611a !important;
}
.navmenu ul li a.active {
  font-weight: 800 !important;
}

/* ===== MEGA MENU (Desktop Only) ===== */
@media (min-width: 1200px) {
  .mobile-nav-toggle { display: none !important; }

  .mega-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 900px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.12);
    padding: 0;
    z-index: 1000;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
    margin-top: 0;
  }
  .mega-menu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: transparent;
  }
  .services-dropdown:hover .mega-menu {
    display: block;
    animation: megaSlideIn 0.3s ease;
  }
}

@keyframes megaSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.mega-menu-header {
  padding: 22px 30px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.mega-menu-header h4 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #0d3b8e;
}

.mega-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 20px 10px;
}
.mega-menu-col {
  padding: 0 12px;
  border-right: 1px solid #f5f5f5;
}
.mega-menu-col:last-child {
  border-right: none;
}

.col-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #0d3b8e;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #e8611a;
}

.mega-item {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.25s ease;
  margin-bottom: 2px;
}
.mega-item:hover {
  background: linear-gradient(135deg, rgba(232,97,26,0.06) 0%, rgba(240,148,58,0.06) 100%);
  transform: translateX(4px);
  padding-left: 18px;
}
.mega-item:hover .item-title {
  color: #e8611a;
}
.item-title {
  font-size: 13px;
  font-weight: 500;
  color: #444;
  line-height: 1.3;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

/* ===== LANGUAGE SWITCHER ===== */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f2f6fd;
  border: 1px solid rgba(13, 59, 142, 0.12);
  border-radius: 50px;
  padding: 5px 6px;
  flex-shrink: 0;
}
.lang-btn {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #0d3b8e;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 50px;
  line-height: 1;
  transition: all 0.3s ease;
}
.lang-btn:hover:not(.active) {
  color: #e8611a;
}
.lang-btn.active {
  background: linear-gradient(135deg, #e8611a 0%, #f0943a 100%);
  color: #fff;
  box-shadow: 0 3px 12px rgba(232, 97, 26, 0.35);
}

/* Desktop: เมนูชิดขวา ปุ่มภาษาต่อท้ายเมนู */
@media (min-width: 1200px) {
  #navmenu { margin-left: auto; }
  .lang-switcher { margin-left: 18px; }
}

/* ===== RESPONSIVE & HAMBURGER (ปรับจุดตัดเป็น 1199px เพื่อป้องกันเมนูเกยโลโก้) ===== */
@media (max-width: 1199px) {
  /* ซ่อนเมนูแบบ Desktop */
  .navmenu ul { display: none !important; }

  /* แสดงเมนูเมื่อมีการคลิก (ต้องมี JS เพิ่มคลาส mobile-nav-active ให้ body หรือ header) */
  .mobile-nav-active .navmenu > ul {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #fff;
    z-index: 999;
    padding-top: 80px;
    overflow-y: auto;
  }
  .mobile-nav-active .navmenu ul li a {
    display: block;
    padding: 15px 24px !important;
    border-bottom: 1px solid #f0f0f0;
  }
  .mobile-nav-active .navmenu ul li a::after { display: none; } /* ซ่อนเส้น underline บนมือถือ */

  /* ปรับ Mega Menu ให้เรียงแนวตั้งบนมือถือ */
  .mobile-nav-active .mega-menu {
    position: static;
    width: 100%;
    box-shadow: none;
    border: none;
    transform: none;
    animation: none;
    display: block !important;
  }
  .mobile-nav-active .mega-menu-grid {
    grid-template-columns: 1fr;
    padding: 10px 20px;
  }
  .mobile-nav-active .mega-menu-col {
    border-right: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 10px 0;
  }

  /* ===== FLOATING HAMBURGER: ปุ่มแฮมเบอร์เกอร์ลอยมุมล่างซ้าย ===== */
  .mobile-nav-toggle {
    display: flex !important;
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 54px;
    height: 54px;
    font-size: 30px;
    color: #fff;
    background: linear-gradient(135deg, #e8611a, #f0943a);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(232, 97, 26, 0.45);
    z-index: 998;
    transition: all 0.3s ease;
    margin: 0;
    padding: 0;
    line-height: 1;
    cursor: pointer;
  }
  .mobile-nav-toggle:active { transform: scale(0.92); }

  /* ตอนเมนูเปิด: ปุ่มค้างอยู่มุมเดิม เปลี่ยนเป็น X */
  .mobile-nav-active .mobile-nav-toggle {
    color: #fff;
    font-size: 28px;
    z-index: 9999;
  }

  /* จัดการ Language Switcher บนหน้าจอเล็ก */
  .lang-switcher {
    order: 2;
    margin-left: auto;
    margin-right: 16px; /* เพิ่มระยะห่างจากขอบขวา */
    padding: 4px 5px;
  }
  .lang-btn { font-size: 12px; padding: 5px 11px; }
  .lang-globe { display: none; }
  #hamburgerBtn { order: 3; }
  #navmenu { order: 4; }
}
