/* ============ MEGA MENU — CATEGORY TREE SKIN (v1) ============
   BaNaNa-style layout: left rail of top-level categories (from
   ggt_categories, managed in admin → หมวดหมู่สินค้า), subcategory
   columns on the right with drill-down for deeper levels, and an
   Advice-style brand logo strip along the bottom. Loaded alongside
   mega-menu.min.css, which still styles the shell (#mega-menu,
   .mega-inner, .mega-overlay, .mega-footer-bar) and the legacy
   CMS-column fallback (.mega-body / .mega-col). */

.mega-tree-body {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  min-height: 300px;
  max-height: calc(100vh - 250px);
}

/* ---- left rail ---- */
.mega-tree-rail {
  width: 252px;
  flex: none;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 12px 8px;
}
.mega-tree-rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.mega-tree-rail-item:hover {
  background: var(--hover-bg);
  color: var(--text);
}
.mega-tree-rail-item.active {
  background: var(--hover-bg);
  border-left-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}
.mega-tree-rail-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 5px;
  flex: none;
}
.mega-tree-rail-icon {
  width: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--accent);
  flex: none;
}
.mega-tree-rail-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mega-tree-rail-chev {
  font-size: 9px;
  color: var(--muted);
  flex: none;
}
.mega-tree-rail-item.active .mega-tree-rail-chev { color: var(--accent); }

/* ---- right panel ---- */
.mega-tree-panel {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 16px 20px 20px;
}
.mega-tree-crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 12px;
}
.mega-tree-crumb {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mega-tree-crumb:hover { text-decoration: underline; }
.mega-tree-crumb-sep {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.mega-tree-crumb-sep i { font-size: 8px; }
.mega-tree-crumb-current { color: var(--text); font-weight: 600; }

.mega-tree-cols {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px 26px;
  align-items: start;
}
.mega-tree-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
  margin-bottom: 6px;
}
.mega-tree-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}
a.mega-tree-group-title:hover { color: var(--accent); }
.mega-tree-plain-title {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.mega-tree-drill {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mega-tree-drill:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}
.mega-tree-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, padding-left 0.15s;
}
.mega-tree-link:hover {
  background: var(--hover-bg);
  color: var(--text);
  padding-left: 10px;
}
.mega-tree-link-chev { font-size: 8px; color: var(--muted); }
.mega-tree-more {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.mega-tree-more:hover { text-decoration: underline; }
.mega-tree-more i { font-size: 9px; }

/* leaf category (no children) */
.mega-tree-leaf { padding: 18px 6px; }
.mega-tree-leaf-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s;
}
.mega-tree-leaf-link:hover { border-color: var(--accent); }
.mega-tree-leaf-link i { color: var(--accent); font-size: 13px; }
.mega-tree-leaf-desc {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
  max-width: 560px;
}

/* ---- bottom brand strip (Advice-style) ---- */
.mega-brand-strip {
  border-top: 1px solid var(--line);
  padding: 12px 20px 14px;
  max-width: 1440px;
  margin: 0 auto;
}
.mega-brand-strip-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 9px;
}
.mega-brand-strip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.mega-brand-tile {
  flex: none;
  width: 96px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  /* brand logos are artwork drawn for light backgrounds — keep the tile
     white in both themes so every logo stays legible */
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s, transform 0.15s;
  text-decoration: none;
}
.mega-brand-tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.mega-brand-tile img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.mega-brand-tile span {
  font-size: 11px;
  font-weight: 700;
  color: #333;
  text-align: center;
}

@media (max-width: 1024px) {
  .mega-tree-rail { width: 208px; }
  .mega-tree-cols { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px 18px; }
}