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

.sme-mega-root-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.75;
  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 {
  opacity: 1;
}

.sme-mega-host-open > a .sme-mega-root-indicator {
  opacity: 1;
  transform: translateY(0) rotate(225deg);
}

/* 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: 12px;
  min-width: 0;
  align-self: flex-start;
}

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

.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%;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  /* More rounded */
  color: #444;
  text-decoration: none !important;
  font-size: var(--sme-fs-l2, 14px);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.sme-mega-grid-item a:hover {
  background: #fff;
  border-color: var(--sme-accent, #ffa500);
  color: var(--sme-accent, #ffa500);
  transform: translateY(-3px);
  /* Lift effect */
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
  /* Deep shadow */
}

.sme-mega-grid-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.4;
}

.sme-mega-grid-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sme-mega-grid-item a:hover .sme-mega-grid-icon {
  transform: scale(1.1);
  /* Micro-animation */
}

/* Level 2 Header - Bold & Distinct */
.sme-mega-grid-item.is-l2-header a {
  background: #fbfbfb;
  border-left: 4px solid var(--sme-accent, #ffa500);
  font-weight: 700;
  color: #222;
  font-size: 14.5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.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;
  border-left: 1px solid rgba(0, 0, 0, 0.06);
}

.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);
}

/* 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;
}
