/* SME Mega Menu - Scoped & Robust Reset */
.sme-mega-wrap {
  display: block;
  position: relative;
  line-height: normal;
}

.sme-mega-root-indicator,
.sme-mega-host > a > i.icon-angle-down {
  display: inline-block;
  margin-left: 7px;
  opacity: 0.72;
  transform: translateY(1px) rotate(0deg);
  transform-origin: 50% 50%;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-item:hover > a .sme-mega-root-indicator,
.current-menu-item > a .sme-mega-root-indicator,
.current-menu-ancestor > a .sme-mega-root-indicator,
.sme-mega-host:hover > a > i.icon-angle-down,
.sme-mega-host.current-menu-item > a > i.icon-angle-down,
.sme-mega-host.current-menu-ancestor > a > i.icon-angle-down {
  opacity: 1;
}

.sme-mega-host-open > a .sme-mega-root-indicator,
.sme-mega-host-open > a > i.icon-angle-down {
  opacity: 1;
  transform: translateY(1px) rotate(180deg);
}

.nav-dropdown-has-arrow li.sme-mega-host::before,
.nav-dropdown-has-arrow li.sme-mega-host::after,
li.sme-mega-host::before,
li.sme-mega-host::after {
  display: none !important;
  content: none !important;
  border: 0 !important;
}

.sme-mega-host > .nav-dropdown,
.sme-mega-host > ul.sub-menu,
.sme-mega-host > .sub-menu {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide by default */
.sme-mega-dropdown {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 99999;
  padding-top: 5px;
  /* Tiny gap for hover stability */
  max-width: calc(100vw - 24px);
}

/* Show on open */
.sme-mega-wrap.is-open>.sme-mega-dropdown,
body>.sme-mega-dropdown.is-open {
  display: block !important;
}

.sme-mega-inner {
  background: #fff;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  border: 1px solid #eee;
  border-radius: 4px;
  display: flex !important;
  width: 100%;
  max-height: var(--sme-max-h, 450px);
  overflow: hidden;
  color: #333;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.sme-mega-inner * {
  box-sizing: border-box;
}

/* Scrollbar Styling */
.sme-mega-col-left::-webkit-scrollbar,
.sme-mega-col-content::-webkit-scrollbar {
  width: 6px;
}

.sme-mega-col-left::-webkit-scrollbar-track,
.sme-mega-col-content::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.sme-mega-col-left::-webkit-scrollbar-thumb,
.sme-mega-col-content::-webkit-scrollbar-thumb {
  background: var(--sme-scroll, #ccc);
  border-radius: 10px;
}

/* Base column styles */
.sme-mega-col {
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100% !important;
}

.sme-mega-title {
  display: none;
}

/* COLUMN LEFT: Main Categories */
.sme-mega-col-left {
  width: 280px !important;
  background: var(--sme-sidebar-bg, #f8f9fa);
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  flex-shrink: 0 !important;
  display: flex !important;
  flex-direction: column;
  overflow-y: auto !important;
  /* Force scroll */
  overflow-x: hidden;
  min-height: 0;
  /* Allow shrinking for scroll */
}

.sme-mega-l1 {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.sme-mega-l1-item {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

.sme-mega-l1-item {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sme-mega-l1-item:last-child {
  border-bottom: none;
}

.sme-mega-l1-item>a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, var(--sme-pad-l1, 10px)) 20px;
  color: #333;
  text-decoration: none !important;
  font-size: var(--sme-fs-l1, 14px);
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.sme-mega-l1-item.is-active>a,
.sme-mega-l1-item>a:hover {
  background: #fff;
  color: var(--sme-accent, #ffa500);
  border-left-color: var(--sme-accent, #ffa500);
  font-weight: 600;
}

.sme-mega-l1-icon {
  width: 24px;
  height: 24px;
  margin-right: 12px;
  object-fit: contain;
}

/* COLUMN CONTENT (RIGHT) */
.sme-mega-col-content {
  background: #fff;
  padding: 18px 22px 22px;
  overflow-y: auto !important;
  flex: 1;
  min-height: 0;
  display: flex !important;
  flex-direction: column;
}

.sme-mega-content-panel {
  display: none;
  width: 100%;
}

.sme-mega-content-panel.is-active {
  display: block;
  animation: smeFadeIn 0.3s ease-out;
}

.sme-mega-grid-l2 {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.sme-mega-grid-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  align-self: flex-start;
}

.sme-mega-grid-l2[data-column-count="2"] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
  row-gap: 10px;
  justify-content: stretch;
}

.sme-mega-grid-l2[data-column-count="2"] .sme-mega-grid-column {
  width: 100% !important;
  max-width: none;
}

.sme-mega-grid-l2[data-column-count="2"] .sme-mega-group-card,
.sme-mega-grid-l2[data-column-count="2"] .sme-mega-grid-item.is-l2-header,
.sme-mega-grid-l2[data-column-count="3"] .sme-mega-group-card,
.sme-mega-grid-l2[data-column-count="3"] .sme-mega-grid-item.is-l2-header {
  width: 100%;
  align-items: stretch;
}

.sme-mega-group-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  align-items: flex-start;
}

.sme-mega-group-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sme-mega-grid-item a {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-left: 3px solid transparent;
  border-radius: 8px;
  color: #2f2f2f;
  text-decoration: none !important;
  font-size: var(--sme-fs-l2, 14px);
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, transform 0.18s ease;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.sme-mega-grid-item a:hover,
.sme-mega-grid-item a:focus-visible {
  background: #fff6f6;
  background: color-mix(in srgb, var(--sme-accent, #d60000) 7%, #fff);
  border-color: #f0c4c4;
  border-color: color-mix(in srgb, var(--sme-accent, #d60000) 28%, #fff);
  border-left-color: var(--sme-accent, #ffa500);
  color: var(--sme-accent, #ffa500);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
  outline: none;
}

.sme-mega-grid-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
  min-width: 0;
  transition: transform 0.18s ease;
}

.sme-mega-grid-icon {
  width: 21px;
  height: 21px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.82;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.sme-mega-grid-item a:hover .sme-mega-grid-title-wrap,
.sme-mega-grid-item a:focus-visible .sme-mega-grid-title-wrap {
  transform: translateX(4px);
}

.sme-mega-grid-item a:hover .sme-mega-grid-icon,
.sme-mega-grid-item a:focus-visible .sme-mega-grid-icon {
  opacity: 1;
  transform: scale(1.08);
}

/* Level 2 Header - thumbnail chip list */
.sme-mega-grid-item.is-l2-header a {
  background: #fff;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 4px 14px 4px 8px;
  border: 1px solid #dfe3e8;
  border-left: 1px solid #dfe3e8;
  border-radius: 8px;
  font-weight: 700;
  color: #050505;
  font-size: max(var(--sme-fs-l2, 14px), 18px);
  letter-spacing: 0;
  box-shadow: none;
}

.sme-mega-grid-item.is-l2-header .sme-mega-grid-title-wrap {
  gap: 12px;
  width: 100%;
}

.sme-mega-grid-item.is-l2-header .sme-mega-grid-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sme-mega-grid-item.is-l2-header .sme-mega-grid-icon {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 3px;
  object-fit: contain;
  opacity: 0.62;
  filter: grayscale(1) contrast(0.72) brightness(1.35);
}

.sme-mega-grid-item.is-l2-header a:hover,
.sme-mega-grid-item.is-l2-header a:focus-visible {
  background: #fff;
  border-color: #cfd6df;
  color: #050505;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.sme-mega-grid-item.is-l2-header a:hover .sme-mega-grid-icon,
.sme-mega-grid-item.is-l2-header a:focus-visible .sme-mega-grid-icon {
  opacity: 0.78;
  filter: grayscale(1) contrast(0.82) brightness(1.2);
}

.sme-mega-grid-item.is-l2-header a:hover .sme-mega-grid-title-wrap,
.sme-mega-grid-item.is-l2-header a:focus-visible .sme-mega-grid-title-wrap {
  transform: translateX(2px);
}

.sme-mega-group-card.span-2 .sme-mega-grid-item.is-l2-header .sme-mega-grid-text {
  white-space: nowrap;
}

/* Level 3 Item - Clean & Simple */
.sme-mega-grid-item.is-l3-item a {
  background: #fff;
  font-size: 13px;
  color: #555;
  min-height: 40px;
  padding: 7px 10px;
  border-left-width: 1px;
  box-shadow: none;
}

.sme-mega-grid-item.is-l3-item a::before {
  content: "";
  display: block;
  width: 4px;
  height: 4px;
  background: #ddd;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}

.sme-mega-grid-item.is-l3-item a:hover::before {
  background: var(--sme-accent, #ffa500);
}

@media (prefers-reduced-motion: reduce) {
  .sme-mega-grid-item a,
  .sme-mega-grid-title-wrap,
  .sme-mega-grid-icon {
    transition: none;
  }

  .sme-mega-grid-item a:hover,
  .sme-mega-grid-item a:focus-visible,
  .sme-mega-grid-item a:hover .sme-mega-grid-title-wrap,
  .sme-mega-grid-item a:focus-visible .sme-mega-grid-title-wrap,
  .sme-mega-grid-item a:hover .sme-mega-grid-icon,
  .sme-mega-grid-item a:focus-visible .sme-mega-grid-icon {
    transform: none;
  }
}

/* Promotions / Banners in Content area - Compact version */
.sme-mega-promotions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px dashed #eee;
  width: 100%;
}

.sme-mega-promo-card a {
  display: block !important;
  height: 90px;
  background-size: cover;
  background-position: center;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  text-decoration: none !important;
  transition: all 0.3s ease;
}

.sme-mega-promo-card.no-image a {
  background: linear-gradient(135deg, #fdfdfd 0%, #f5f5f5 100%);
  border: 1px solid #e5e5e5;
  display: flex !important;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.sme-mega-promo-card.no-image .sme-mega-promo-overlay {
  background: transparent;
  position: relative;
  inset: auto;
  padding: 15px;
  width: 100%;
}

.sme-mega-promo-card.no-image .sme-mega-promo-title {
  color: #333;
  text-shadow: none;
  font-size: 15px;
}

.sme-mega-promo-desc {
  display: block;
  font-size: 12px;
  opacity: 0.8;
  margin-top: 3px;
  font-weight: 400;
}

.sme-mega-promo-card.has-image .sme-mega-promo-desc {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.sme-mega-promo-card.no-image .sme-mega-promo-desc {
  color: #666;
}

.sme-mega-promo-card a:hover {
  transform: scale(1.02);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.sme-mega-promo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.7), transparent);
  display: flex;
  align-items: center;
  padding: 20px;
}

.sme-mega-promo-content {
  color: #fff;
}

.sme-mega-promo-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Parent relative for absolute badges */
.sme-mega-grid-item a,
.sme-mega-promo-card,
.sme-mega-l1-item {
  position: relative !important;
}

/* Sophisticated Minimalist Badge (Like requested image) */
.sme-mega-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--sme-accent, #e31e24);
  /* Premium Red default */
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px 10px 10px 2px;
  /* Asymmetric sophisticated round */
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  z-index: 10;
  pointer-events: none;
  line-height: 1.2;
}

.sme-mega-badge.promo {
  top: 10px;
  right: 10px;
  border-radius: 4px;
}

/* Animations */
@keyframes smeFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .sme-mega-grid-l2 {
    flex-wrap: wrap;
  }

  .sme-mega-grid-column {
    width: calc(50% - 8px) !important;
  }
}

@media (max-width: 1024px) {
  .sme-mega-dropdown {
    max-width: 100vw;
  }
}

.sme-mega-dropdown.is-open .sme-mega-inner {
  animation: smeFadeIn 0.3s ease-out;
}

/* Detached Mode Handling (Body level) */
body>.sme-mega-dropdown {
  pointer-events: none;
}

body>.sme-mega-dropdown.is-open {
  pointer-events: auto;
}

/* Responsiveness Fix */
@media (max-width: 1024px) {
  .sme-mega-inner {
    grid-template-columns: 180px 1fr;
    max-height: calc(100vh - 100px);
  }

  .sme-mega-grid-l2 {
    flex-wrap: wrap;
  }
}

@media (max-width: 767px) {
  .sme-mega-dropdown {
    padding: 0 10px;
  }

  .sme-mega-inner {
    grid-template-columns: 110px 1fr;
    max-height: 70vh;
  }

  .sme-mega-l1-item>a {
    padding: 10px;
    font-size: 13px;
    flex-direction: column;
    text-align: center;
    gap: 5px;
  }

  .sme-mega-l1-icon {
    margin: 0;
  }

  .sme-mega-grid-l2 {
    flex-direction: column;
  }

  .sme-mega-grid-column {
    width: 100% !important;
  }

  .sme-mega-col-content {
    padding: 10px;
  }

  .sme-mega-title {
    display: none;
  }
}

/* CLEAN LINKS GRID (KHUNG 2) */
.sme-mega-grid-clean {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px 0;
}

.sme-mega-grid-item.is-clean-link {
  position: relative;
  display: inline-block;
}

.sme-mega-grid-item.is-clean-link a {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 3px 8px !important;
  background: var(--sme-ql-bg, #fff) !important;
  border: 1px solid var(--sme-ql-border, #e1e1e1) !important;
  border-radius: 4px !important;
  color: #333 !important;
  font-size: var(--sme-ql-fs, 13px) !important;
  font-weight: 400 !important;
  min-width: 40px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02) !important;
  transition: all 0.2s ease !important;
  line-height: 1.2 !important;
}

.sme-mega-grid-item.is-clean-link a:hover {
  border-color: var(--sme-accent, #ffa500) !important;
  color: var(--sme-accent, #ffa500) !important;
  background: #fff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05) !important;
}

.sme-mega-badge.clean {
  position: absolute;
  top: -8px;
  right: -4px;
  background: var(--sme-ql-badge, #d32f2f);
  color: #fff;
  font-size: 8.5px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  z-index: 2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  line-height: 1.2;
}
