/* ---------- Mega Menu BASE ---------- */
.mega-menu {
  position: static !important;
}

.mega-menu .nav-link {
  font-weight: 600;
  color: #000;
  text-decoration: none;
  font-family: "Poppins", sans-serif;
  display: inline-block;
  padding: 10px 15px;
  cursor: pointer;
}

.mega-menu .mega-menu-content {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #fff;
  border-top: 3px solid #007bff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  min-height: 420px;
  display: flex;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.35s ease;
}

/* Desktop hover behavior */
.mega-menu:hover .mega-menu-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ---------- LEFT PANEL ---------- */
.mega-menu-left {
  width: 28%;
  border-right: 1px solid #e6e6e6;
  background-color: #f9f9f9;
}

.mega-menu-left ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mega-menu-left li {
  padding: 12px 20px;
  font-weight: 500;
  cursor: pointer;
  color: #333;
  transition: all 0.3s;
  font-family: "Poppins", sans-serif;
}

.mega-menu-left li:hover,
.mega-menu-left li.active {
  background: #007bff;
  color: #fff;
}

/* ---------- RIGHT PANEL ---------- */
.mega-menu-right {
  flex: 1;
  padding: 25px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 25px;
  align-content: flex-start;
  overflow-y: auto;
  max-height: 520px;
  scroll-behavior: smooth;
}

/* Scrollbar style (blue) */
.mega-menu-right::-webkit-scrollbar {
  width: 8px;
}
.mega-menu-right::-webkit-scrollbar-thumb {
  background: #007bff;
  border-radius: 10px;
}

/* ---------- PRODUCT CARD ---------- */
.product-card {
  text-align: center;
  transition: all 0.3s ease;
}
.product-card a {
  text-decoration: none;
  display: block;
  padding: 0px;
  border-radius: 8px;
  transition: background 0.3s;
}
.product-card a:hover {
  background: #f1f7ff;
}
.product-card img {
  width: 100px;
  height: auto;
  object-fit: cover;
  transition: transform 0.3s;
}
.product-card h5 {
  font-size: 15px;
  margin-top: 10px;
  color: #222;
  font-weight: 600;
  text-transform: uppercase;
}
.product-card p {
  font-size: 13px;
  color: #666;
  margin-top: 5px;
}
.product-card:hover img {
  transform: scale(1.1);
}

/* ---------- MOBILE VIEW ---------- */
@media (max-width: 992px) {
  .mega-menu .mega-menu-content {
    position: static;
    flex-direction: column;
    box-shadow: none;
    border-top: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    display: none;
  }

  .mega-menu.open .mega-menu-content {
    display: block;
  }

  .mega-menu-left {
    width: 100%;
    border: none;
    background: #fff;
  }

  .mega-menu-left li {
    border-bottom: 1px solid #eaeaea;
  }

  .mega-menu-right {
    display: none;
  }

  /* ---------- Subcategory Expand Below Category ---------- */
  .subcategory {
    display: none;
    background: #f9f9f9;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    border-radius: 6px;
  }

  /* 👇 2-column grid + scrollable (max 350px height) */
  .subcategory.show {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-height: 350px; /* limit height */
    overflow-y: auto; /* enable scroll */
    animation: slideDown 0.3s ease;
  }

  /* Scrollbar inside mobile subcategory */
  .subcategory.show::-webkit-scrollbar {
    width: 6px;
  }
  .subcategory.show::-webkit-scrollbar-thumb {
    background: #007bff;
    border-radius: 6px;
  }

  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .subcategory .product-card h5 {
    font-size: 14px;
  }

  .subcategory .product-card img {
    width: 100%;
  }
}

/* For very small phones */
@media (max-width: 480px) {
  .subcategory.show {
    grid-template-columns: 1fr 1fr;
    max-height: 300px;
  }
}

.subcategory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  padding-right: 30px;
  border-right: 1px solid #eee;
}

.subcategory-item {
  cursor: pointer;
  background: #f8f9fa;
  border-radius: 8px;
  text-align: center;
  padding: 12px;
  transition: all 0.3s;
}

.subcategory-item:hover {
  background: #007bff;
  color: #fff;
}

.product-display {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  padding-left: 30px;
}

.product-display .product-card img {
  max-height: 100px;
  object-fit: contain;
}


/* ---------- MOBILE VIEW (Updated) ---------- */
@media (max-width: 992px) {
  .mega-menu-content { display: none; }
  .mega-menu.open .mega-menu-content { display: block; }

  .mega-menu-left li {
    border-bottom: 1px solid #eaeaea;
  }

  /* Subcategory section below category */
  .subcategory-block {
    display: none;
    background: #f9f9f9;
    padding: 12px 15px;
    border-top: 1px solid #eee;
  }
  .subcategory-block.show {
    display: block;
    animation: slideDown 0.3s ease;
  }

  .subcategory-item {
    padding: 10px;
    background: #fff;
    border-radius: 6px;
    margin-bottom: 8px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #ddd;
  }
  .subcategory-item:hover {
    background: #007bff;
    color: #fff;
  }

  /* Product block inside subcategory */
  .product-block {
    display: none;
  }
  .product-block.show {
    display: block;
    margin-top: 8px;
  }

  /* Product grid inside subcategory */
  .subcategory.show {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-height: 350px;
    overflow-y: auto;
    background: #fff;
    padding: 10px;
    border-radius: 8px;
  }
  .subcategory.show::-webkit-scrollbar {
    width: 6px;
  }
  .subcategory.show::-webkit-scrollbar-thumb {
    background: #007bff;
    border-radius: 6px;
  }

  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* MOBILE: hide middle panel and subcategory bar on small screens */
/* Mobile better look */
@media(max-width:992px){
  .mega-menu.open .mega-menu-content {
    position: fixed;
    top: 60px; /* navbar height adjust */
    left: 0;
    right: 0;
    bottom: 0;
    /*height: calc(100vh - 60px);*/
    overflow-y: auto; /* MAIN SCROLL HERE */
    -webkit-overflow-scrolling: touch;
  }
  .subcategory-mobile{
    background:#f9f9f9;
    padding:12px;
    border-top:1px solid #ddd;
  }
  .sub-mobile-item{
    padding:12px;
    background:#fff;
    margin-bottom:10px;
    border-radius:6px;
    font-weight:500;
    border:1px solid #ddd;
  }
  .sub-mobile-item:hover{
    background:#007bff;
    color:#fff;
  }
  .mobile-products.show{
    margin-top:8px;
  }
  .sub-grid{
    display:grid;
    grid-template-columns:repeat(2,1fr);
    gap:12px;
    max-height:350px;
    overflow-y:auto;
  }
  .subcategory.show .product-card h5,
  .mobile-products .product-card h5,
  .product-card h5 {
    font-size: 12px !important;
    line-height: 1.3;
  }
}
