/* ============================================
   MEGA DROPDOWN KATEGORI
   v2.0 — Redesigned: Trigger in header-row-top
   Card-style desktop grid with category images
   ============================================ */

/* ============================================
   1. DESKTOP MEGA DROPDOWN (≥1024px)
   ============================================ */

/* Trigger wrapper - now inside header-row-top */
.mega-dropdown-wrapper {
  position: relative;
  flex-shrink: 0;
  z-index: 60;
}

.mega-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e293b;
  background: transparent;
  border: none;
  border-radius: 8px;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

.mega-dropdown-trigger:hover,
.mega-dropdown-trigger.active {
  color: #1e293b;
  background: rgba(0, 0, 0, 0.08);
}

.mega-dropdown-trigger .kategori-grid-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: inherit;
}

.mega-dropdown-trigger .trigger-chevron {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  margin-left: 2px;
}

.mega-dropdown-trigger.active .trigger-chevron {
  transform: rotate(-135deg) translateY(-2px);
}

/* Dropdown panel — centered, width based on content (5 columns) */
.mega-dropdown-panel {
  position: fixed;
  top: var(--mega-dropdown-top, 140px);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 1250px;
  max-height: 80vh;
  overflow-y: auto;
  background: #fff;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.06);
  z-index: 9999;

  /* Animation properties */
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-8px);
  pointer-events: none;
  transition:
    opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.3s;
  contain: layout style;
  will-change: opacity, transform;
}

/* Closing transition — faster for responsiveness */
.mega-dropdown-panel:not(.is-open) {
  transition:
    opacity 0.2s cubic-bezier(0.4, 0, 1, 1),
    transform 0.2s cubic-bezier(0.4, 0, 1, 1),
    visibility 0.2s;
}

.mega-dropdown-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Backdrop overlay */
.mega-dropdown-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.25);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.35s;
}

.mega-dropdown-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Inner container */
.mega-dropdown-inner {
  max-width: 100%;
  margin: 0;
  padding: 28px 32px;
}

/* Keyframes for staggered entrance animation */
@keyframes fadeInUpItem {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Grid layout — 5 equal columns like the reference image */
.mega-dropdown-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
}

/* Individual category card */
.mega-cat-column {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #fff;
  border-radius: 0;
  overflow: hidden;
  /* Initial state for entrance animation */
  opacity: 0;
  transform: translateY(20px);
}

/* When dropdown is open - animate all columns */
.mega-dropdown-panel.is-open .mega-cat-column {
  animation: fadeInUpItem 0.4s ease-out forwards;
}

/* Staggered delay for each column (10 items total) */
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(1) { animation-delay: 0ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(2) { animation-delay: 50ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(3) { animation-delay: 100ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(4) { animation-delay: 150ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(5) { animation-delay: 200ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(6) { animation-delay: 250ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(7) { animation-delay: 300ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(8) { animation-delay: 350ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(9) { animation-delay: 400ms; }
.mega-dropdown-panel.is-open .mega-cat-column:nth-child(10) { animation-delay: 450ms; }

/* Category image — horizontal banner style */
.mega-cat-image {
  width: 100%;
  aspect-ratio: 2 / 1;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
  background: #f0f4f8;
}

.mega-cat-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.mega-cat-column:hover .mega-cat-image img {
  transform: scale(1.05);
}

/* Category header (title) */
.mega-cat-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: none;
  text-decoration: none;
  color: inherit;
  transition: color 0.2s;
}

.mega-cat-header:hover {
  color: var(--primary-red, #e53935);
}

.mega-cat-icon {
  display: none;
}

.mega-cat-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--gray-900, #111827);
  margin: 0;
}

.mega-cat-header:hover .mega-cat-title {
  color: var(--primary-red, #e53935);
}

/* Sub-category list */
.mega-sub-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.mega-sub-list li a {
  display: block;
  padding: 3px 0;
  font-size: 0.88rem;
  color: var(--gray-600, #4b5563);
  text-decoration: none;
  transition: color 0.15s;
  line-height: 1.6;
}

.mega-sub-list li a:hover {
  color: var(--primary-red, #e53935);
}

/* "More..." link — red/coral like the reference */
.mega-cat-more {
  display: inline-block;
  margin-top: 4px;
  padding-left: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-red, #e53935);
  text-decoration: none;
  transition: opacity 0.15s;
}

.mega-cat-more:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* Loading state */
.mega-dropdown-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500, #6b7280);
  font-size: 0.9rem;
}

.mega-dropdown-loading .spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(0, 174, 239, 0.2);
  border-top-color: var(--primary-cyan, #00aeef);
  border-radius: 50%;
  animation: megaSpin 0.7s linear infinite;
  margin-bottom: 10px;
}

@keyframes megaSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive: 4 columns on medium screens */
@media (min-width: 1024px) and (max-width: 1279px) {
  .mega-dropdown-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Responsive: 3 columns on smaller desktop */
@media (min-width: 768px) and (max-width: 1023px) {
  .mega-dropdown-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================
   2. MOBILE — HIDE DESKTOP MEGA DROPDOWN
   ============================================ */
@media (max-width: 1023px) {

  .mega-dropdown-wrapper,
  .mega-dropdown-panel,
  .mega-dropdown-backdrop {
    display: none !important;
  }
}

/* ============================================
   3. MOBILE CATEGORY ACCORDION (≤1023px)
   Inside #mobileMenuModal
   ============================================ */

/* Mobile category trigger item */
.mobile-cat-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 24px;
  font-size: 1rem;
  color: var(--gray-700, #374151);
  text-decoration: none;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-family: inherit;
}

.mobile-cat-trigger:hover,
.mobile-cat-trigger.active {
  background-color: rgba(0, 174, 239, 0.05);
  border-left-color: var(--primary-cyan, #00aeef);
}

.mobile-cat-trigger .trigger-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-cat-trigger .trigger-label .mobile-cat-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.mobile-cat-trigger .trigger-chevron-mobile {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.mobile-cat-trigger.active .trigger-chevron-mobile {
  transform: rotate(-135deg);
}

/* Mobile accordion container */
.mobile-cat-accordion {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(0, 0, 0, 0.015);
  will-change: max-height;
}

.mobile-cat-accordion.is-open {
  max-height: 2000px;
}

/* Parent category in accordion */
.mobile-cat-parent {
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.mobile-cat-parent-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 24px 12px 44px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-800, #1f2937);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  font-family: inherit;
}

.mobile-cat-parent-btn:hover {
  background: rgba(0, 174, 239, 0.06);
}

.mobile-cat-parent-btn .parent-icon {
  font-size: 1rem;
  width: 22px;
  text-align: center;
  margin-right: 8px;
  flex-shrink: 0;
}

.mobile-cat-parent-btn .parent-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-cat-parent-btn .sub-chevron {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  color: var(--gray-400, #9ca3af);
}

.mobile-cat-parent-btn.open .sub-chevron {
  transform: rotate(-135deg);
}

/* Sub-category accordion */
.mobile-sub-accordion {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: max-height;
}

.mobile-sub-accordion.is-open {
  max-height: 1000px;
}

.mobile-sub-accordion a {
  display: block;
  padding: 8px 24px 8px 74px;
  font-size: 0.82rem;
  color: var(--gray-600, #4b5563);
  text-decoration: none;
  transition:
    color 0.15s,
    background 0.15s;
}

.mobile-sub-accordion a:hover {
  color: var(--primary-cyan, #00aeef);
  background: rgba(0, 174, 239, 0.04);
}

/* "Lihat Semua" at the bottom of mobile accordion */
.mobile-cat-view-all {
  display: block;
  padding: 10px 24px 10px 44px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-cyan, #00aeef);
  text-decoration: none;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  transition: background 0.15s;
}

.mobile-cat-view-all:hover {
  background: rgba(0, 174, 239, 0.06);
}

/* ============================================
   4. DESKTOP ONLY — show trigger
   ============================================ */
@media (min-width: 1024px) {

  .mobile-cat-trigger,
  .mobile-cat-accordion {
    display: none !important;
  }
}

/* ============================================
   5. SCROLLBAR styling for panel
   ============================================ */
.mega-dropdown-panel::-webkit-scrollbar {
  width: 6px;
}

.mega-dropdown-panel::-webkit-scrollbar-track {
  background: transparent;
}

.mega-dropdown-panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
}

.mega-dropdown-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}