/* RESET */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; padding-top: 80px;
  font-family: 'Kanit', sans-serif;
  font-size: 16px;
  color: #132143;
  background: #fff;
}

/* TOP BAR */
.top-bar {
  position: fixed; top: 0; left: 0; width: 100vw; height: 36px;
  background: linear-gradient(90deg, #2e7d32 0%, #c0a040 100%);
  display: flex; justify-content: flex-end; align-items: center;
  padding: 0 20px; box-shadow: 0 2px 10px rgba(46, 125, 50, 0.08);
  z-index: 10000; font-size: 14px;
}
.top-bar ul {
  list-style: none; display: flex; gap: 18px;
  margin: 0; padding: 0; align-items: center;
}
.top-bar li { font-weight: 500; color: #fff; }
.top-bar li.divider {
  pointer-events: none; font-weight: 400; font-size: 16px; opacity: .7;
}
.top-bar a {
  color: #fff; text-decoration: none;
  padding: 3px 8px; border-radius: 4px;
  transition: background .2s, color .2s;
}
.top-bar a:hover, .top-bar a:focus {
  background: rgba(46, 125, 50, 0.15);
  color: #2e7d32;
}

/* MAIN HEADER */
.main-header {
  position: fixed; top: 36px; left: 50%;
  transform: translateX(-50%);
  width: 100vw; max-width: 1240px;
  background: #fff;
  box-shadow: 0 2px 18px rgba(46, 125, 50, 0.12);
  border-radius: 0 0 12px 12px;
  padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 9999;
}
.logo img {
  height: 34px; cursor: pointer; transition: transform 0.18s;
}
.logo img:hover { transform: scale(1.06) rotate(-2deg); }

/* MAIN MENU - Desktop */
.main-menu ul {
  list-style: none; display: flex; gap: 16px;
  margin: 0; padding: 0; align-items: center;
}
.main-menu li { position: relative; }
.main-menu a {
  text-decoration: none; color: #2e7d32;
  padding: 7px 14px; border-radius: 6px;
  font-weight: 500;
  transition: background 0.2s, color 0.18s;
}
.main-menu a:hover, .main-menu a:focus {
  background: #c0a040; color: #fff;
}
.has-submenu::after {
  content: ' ▼'; font-size: 11px; color: #c0a040;
}

/* SUBMENU - Desktop */
.submenu {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  align-items: flex-start;
  gap: 18px;
  position: absolute;
  top: 110%;
  left: 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(46,125,50,0.15);
  padding: 18px 28px;
  max-width: 100vw;
  min-width: 260px;
  z-index: 11000;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.21s, transform 0.22s;
  color: #2e7d32;
  border-top: 3px solid #c0a040;
}
.main-menu li:hover > .submenu,
.main-menu li:focus-within > .submenu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* SUBMENU COLUMN - Responsive 3+ columns */
.submenu-column {
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 280px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s;
}
.submenu-column:hover { transform: translateY(-2px); }
.submenu-column-lower { margin-top: 16px; }

/* ถ้ามี container column group ก็ใช้ได้เลย */
.submenu-columns-top,
.submenu-columns-bottom {
  display: flex;
  flex-direction: row;
  gap: 14px;
  width: 100%;
  justify-content: flex-start;
}

/* Headings in submenu */
.submenu-column h4 {
  font-size: 15px;
  font-weight: 600;
  color: #c0a040;
  border-bottom: 1.5px solid #c0a040;
  padding-bottom: 5px;
  margin: 0 0 8px 0;
  letter-spacing: 0.02em;
}

/* Links in submenu */
.submenu-column a {
  font-weight: 400;
  font-size: 14px;
  color: #2e7d32;
  padding: 5px 0;
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.16s, padding-left 0.15s, background-color 0.18s;
  display: block;
}
.submenu-column a:hover, .submenu-column a:focus {
  color: #fff;
  background: #c0a040;
  padding-left: 13px;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 28px;
  height: 24px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 10001;
}
.hamburger-line {
  width: 100%;
  height: 3px;
  background: #2e7d32;
  border-radius: 2px;
  transition: all .3s;
}
.hamburger.active .hamburger-line:nth-child(1) { transform: rotate(45deg); }
.hamburger.active .hamburger-line:nth-child(2) { opacity: 0; }
.hamburger.active .hamburger-line:nth-child(3) { transform: rotate(-45deg); }

/* Responsive - มือถือและแท็บเล็ต */
@media (max-width: 980px) {
  .main-header { max-width: 100vw; padding: 10px 10px; }
  .main-menu ul { gap: 0; }
}

@media (max-width: 820px) {
  .main-menu {
    position: fixed;
    top: 72px; left: 0; right: 0;
    background: #fff;
    width: 100vw;
    box-shadow: 0 4px 16px rgba(46, 125, 50, 0.09);
    padding: 18px 0 6px 0;
    transform: translateY(-120%);
    transition: transform .29s cubic-bezier(.7,0,.2,1);
    z-index: 15000;
  }
  .main-menu.open { transform: translateY(0); }
  .main-menu ul { flex-direction: column; align-items: flex-start; width: 100%; }
  .main-menu li { width: 100%; }
  .main-menu a { display: block; width: 100%; border-radius: 0; padding: 13px 22px; font-size: 15.5px; }
  .hamburger { display: flex; margin-left: 10px; }

  .submenu {
    display: block !important;
    position: static !important;
    background: #f3f7fa;
    border-radius: 0 0 14px 14px;
    box-shadow: none;
    border-left: 4px solid #c0a040;
    padding: 8px 12px 8px 16px;
    min-width: unset;
    max-width: 100vw;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scaleY(0.96);
    transition: max-height 0.44s cubic-bezier(.3,1.2,.3,1), opacity 0.22s, transform 0.22s;
    margin-bottom: 0;
  }
  .main-menu li.open > .submenu {
    max-height: 900px;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scaleY(1);
    overflow-y: auto;
  }
  .submenu-column,
  .submenu-columns-top,
  .submenu-columns-bottom {
    display: block !important;
    min-width: 100px;
    gap: 2px;
    margin-bottom: 0;
    font-size: 15px;
    color: #132143;
  }
  .submenu-column h4 {
    color: #c0a040;
    border-bottom: 1px solid #c0a040;
    font-size: 15.5px;
    margin-top: 10px;
    margin-bottom: 5px;
    letter-spacing: 0.01em;
  }
  .submenu-column a {
    padding: 4px 0 4px 10px;
    font-size: 15px;
    color: #2e7d32;
    background: transparent;
    border-radius: 5px;
    transition: background 0.15s, color 0.16s, padding-left 0.14s;
  }
  .submenu-column a:hover, .submenu-column a:focus {
    background: #c0a040;
    color: #fff;
    padding-left: 18px;
  }
}
/* ================= DARK MODE ================= */
body.dark-mode {
  background-color: #121212;
  color: #e0e0e0;
}

/* TOP BAR */
body.dark-mode .top-bar {
  background: linear-gradient(90deg, #2e7d32 0%, #c0a040 100%);
  box-shadow: 0 2px 10px rgba(0,0,0,0.6);
}
body.dark-mode .top-bar li { color: #fff; }
body.dark-mode .top-bar a {
  color: #fff;
  transition: background .2s, color .2s;
}
body.dark-mode .top-bar a:hover,
body.dark-mode .top-bar a:focus {
  background: rgba(192,160,64,0.15);
  color: #c0a040;
}

/* MAIN HEADER */
body.dark-mode .main-header {
  background: #1a1a1a;
  box-shadow: 0 2px 18px rgba(0,0,0,0.7);
  border: 1px solid #2a2a2a;
}
body.dark-mode .main-menu a {
  color: #ddd;
}
body.dark-mode .main-menu a:hover,
body.dark-mode .main-menu a:focus {
  background: linear-gradient(135deg, #ffffff 0%, #c0a040 100%);
  color: #fff;
}
body.dark-mode .has-submenu::after {
  color: #c0a040;
}

/* SUBMENU */
body.dark-mode .submenu {
  background: #1a1a1a;
  color: #ddd;
  border-top: 3px solid #c0a040;
  box-shadow: 0 8px 28px rgba(0,0,0,0.7);
}
body.dark-mode .submenu-column h4 {
  color: #c0a040;
  border-bottom: 1.5px solid #c0a040;
}
body.dark-mode .submenu-column a {
  color: #ccc;
}
body.dark-mode .submenu-column a:hover,
body.dark-mode .submenu-column a:focus {
  background: linear-gradient(135deg, #ffffff 0%, #c0a040 100%);
  color: #fff;
  padding-left: 13px;
}

/* HAMBURGER */
body.dark-mode .hamburger-line {
  background: #c0a040;
}

/* RESPONSIVE - MOBILE */
@media (max-width: 820px) {
  body.dark-mode .main-menu {
    background: #1a1a1a;
    box-shadow: 0 4px 16px rgba(0,0,0,0.7);
  }
  body.dark-mode .submenu {
    background: #181818;
    border-left: 4px solid #c0a040;
  }
  body.dark-mode .submenu-column h4 {
    color: #c0a040;
    border-bottom: 1px solid #c0a040;
  }
  body.dark-mode .submenu-column a {
    color: #ccc;
  }
  body.dark-mode .submenu-column a:hover,
  body.dark-mode .submenu-column a:focus {
    background: linear-gradient(135deg, #2e7d32 0%, #c0a040 100%);
    color: #fff;
    padding-left: 18px;
  }
}
