/* =====================================================
   APEX AUTO – BLACK PREMIUM MEGA MENU (FINAL)
===================================================== */

/* Safety */
.apex-submenu,
.apex-submenu * {
  box-sizing: border-box;
}

/* =====================================================
   MAIN CATEGORY BAR (ORIGINAL COLORS RESTORED)
===================================================== */
.apex-submenu__list {
  display: flex;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.apex-submenu__list > li {
  position: relative;
}

.apex-submenu__list > li > a {
  font-size: 14px;
  font-weight: 700;
  color: #444; /* ⬅ RESTORED */
  text-decoration: none;
  padding: 6px 0;
  transition: .2s ease;
}

/* tablet / smaller desktop: allow 2-line category labels */
@media (max-width: 1320px) and (min-width: 769px) {
  .apex-submenu__list {
    gap: 14px;
  }

  .apex-submenu__list > li > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    max-width: 118px;
    min-height: 34px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.apex-submenu__list > li:hover > a {
  color: #dc2626;
}

/* caret – desktop (Font Awesome) */
.apex-submenu__list > li.menu-item-has-children > a::after {
  content: "\f078"; /* fa-chevron-down */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;

  font-size: 10px;
  margin-left: 6px;
  color: #aaa;

  display: inline-block;
  vertical-align: middle;
  transition: transform .25s ease, color .25s ease;
}
.apex-submenu__list > li.menu-item-has-children:hover > a::after {
  transform: rotate(180deg);
  color: #dc2626;
}

/* =====================================================
   MEGA MENU WRAPPER (BASE)
===================================================== */
.apex-submenu__list > li > ul.sub-menu {
  position: absolute;
  top: calc(100% + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(14px);

  padding: 36px;
  background: #050505;
  border: 1px solid rgba(220,38,38,.45);

  box-shadow:
    0 40px 120px rgba(0,0,0,.65),
    inset 0 0 0 1px rgba(255,255,255,.03);

  display: grid;
  gap: 28px;

  opacity: 0;
  visibility: hidden;
  transition: .25s ease;
  z-index: 999;
}

/* show */
.apex-submenu__list > li.menu-item-has-children:hover > ul.sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* =====================================================
   GRID LOGIC BY SUBCATEGORY COUNT
===================================================== */

/* DEFAULT: 4+ subcategories */
.apex-submenu__list > li > ul.sub-menu {
  grid-template-columns: repeat(4, 1fr);
  min-width: min(1100px, calc(100vw - 32px));
  max-width: min(1400px, calc(100vw - 32px));
}

/* 3 subcategories → 3 cards */
.apex-submenu__list > li > ul.sub-menu:has(> li:nth-child(3):last-child) {
  grid-template-columns: repeat(3, 1fr);
  min-width: min(960px, calc(100vw - 32px));
}

/* 2 subcategories → 2 cards */
.apex-submenu__list > li > ul.sub-menu:has(> li:nth-child(2):last-child) {
  grid-template-columns: repeat(2, 1fr);
  min-width: min(640px, calc(100vw - 32px));
}

/* =====================================================
   1 SUBCATEGORY – FEATURED MODE
===================================================== */
.apex-submenu__list > li > ul.sub-menu:has(> li:only-child) {
  grid-template-columns: 1fr;

  min-width: 0;
  max-width: 380px;      /* ⬅ CRITICAL */
  padding: 24px;

  justify-content: center;
}

/* Center the single card */
.apex-submenu__list > li > ul.sub-menu:has(> li:only-child) > li {
  justify-self: center;
}



/* Card */
.apex-submenu__list ul.sub-menu li a {
  position: relative;
  display: block;

  aspect-ratio: 1 / 1;                /* ⬅ PERFECT SQUARE */

  width: 100%;
  height: auto;

  text-decoration: none;
  color: #fff;

  border: 1px solid rgba(220,38,38,.55);

  box-shadow:
    0 18px 45px rgba(0,0,0,.55);

  transition: .35s ease;
}

/* hover */
.apex-submenu__list ul.sub-menu li a:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow:
    0 35px 90px rgba(0,0,0,.85),
    inset 0 0 0 3px rgba(220,38,38,.75);
}

/* =====================================================
   FULL BACKGROUND IMAGE
===================================================== */
.apex-submenu__list ul.sub-menu .mega-thumb {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 1;
}

/* dark automotive overlay */
.apex-submenu__list ul.sub-menu .mega-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      to top,
      rgba(0,0,0,.9),
      rgba(0,0,0,.35)
    );
}

/* =====================================================
   CARD CONTENT
===================================================== */
.apex-submenu__list ul.sub-menu .mega-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;

  padding: 22px;
  z-index: 2;
}

.apex-submenu__list ul.sub-menu .mega-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .6px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.apex-submenu__list ul.sub-menu .mega-count {
  font-size: 13px;
  color: rgba(255,255,255,.8);
}

/* DEFAULT: DESKTOP */
.apex-mobile-menu {
  display: none;
}

/* =====================================================
   APEX AUTO – MOBILE MENU (FINAL)
===================================================== */

/* ---------------------------------
   HAMBURGER BUTTON
--------------------------------- */
.apex-hamburger {
  display: none;
  background: none;
  border: none;
  width: 34px;
  height: 26px;
  position: relative;
  cursor: pointer;
}

.apex-hamburger span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 3px;
  background: #111;
  border-radius: 3px;
  transition: .3s ease;
}

.apex-hamburger span:nth-child(1) { top: 0; }
.apex-hamburger span:nth-child(2) { top: 11px; }
.apex-hamburger span:nth-child(3) { bottom: 0; }

/* Active (X) */
.apex-hamburger.active span:nth-child(1) {
  transform: rotate(45deg);
  top: 11px;
}
.apex-hamburger.active span:nth-child(2) {
  opacity: 0;
}
.apex-hamburger.active span:nth-child(3) {
  transform: rotate(-45deg);
  bottom: 11px;
}

/* ---------------------------------
   MOBILE MENU CONTAINER
--------------------------------- */
.apex-mobile-menu {
  display: none;
  background: #fff;
  border-top: 1px solid #e5e5e5;
}

.apex-mobile-menu.open {
  display: block;
}

/* ---------------------------------
   MOBILE MENU LIST
--------------------------------- */
.apex-mobile-menu__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.apex-mobile-menu__list > li {
  position: relative;
  border-bottom: 1px solid #eee;
}

/* Main link */
.apex-mobile-menu__list > li > a {
  margin-left: 10px;
  display: block;
  padding: 14px 0;
  font-size: 16px;
  font-weight: 700;
  color: #111;
  text-decoration: none;
  text-transform: uppercase;
}

/* ---------------------------------
   DROPDOWN ARROW
--------------------------------- */
.apex-mobile-menu__list > li.menu-item-has-children > a {
  padding-right: 28px;
}

.apex-mobile-menu__list > li.menu-item-has-children > a::after {
  content: "\f078"; /* fa-chevron-down */
  font-family: "Font Awesome 6 Free";
  font-weight: 900; /* REQUIRED for solid icons */
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: #dc2626;
  transition: transform .25s ease;
  margin-right: 20px;
}

.apex-mobile-menu__list > li.open > a::after {
  transform: translateY(-50%) rotate(180deg);
}


/* ---------------------------------
   SUBMENU (INLINE ACCORDION)
--------------------------------- */
.apex-mobile-menu__list ul {
  display: none;
  padding-left: 8px; /* subtle hierarchy */
}

.apex-mobile-menu__list li.open > ul {
  display: block;
}

.apex-mobile-menu__list ul li {
  list-style: none;
}

.apex-mobile-menu__list ul li a {
  display: block;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 500;
  color: #444;
  text-decoration: none;
}

.apex-mobile-menu__list ul li a:hover {
  color: #dc2626;
}

/* ---------------------------------
   MOBILE VISIBILITY CONTROL
--------------------------------- */
@media (max-width: 768px) {

  .apex-hamburger{
    display: block;
    margin: 0;
  }

  .apex-main-menu,
  .apex-subbar {
    display: none;
  }
}

/* =====================================================
   FIX: keep specific mega menus fully inside viewport
===================================================== */
#menu-item-1586,
#menu-item-1577 {
  position: relative !important;
  overflow: visible !important;
}

#menu-item-1586 > .sub-menu,
#menu-item-1577 > .sub-menu {
  left: auto !important;
  right: 0 !important;
  margin-left: 0 !important;
  transform: translateX(0) translateY(14px) !important;
  max-width: min(1400px, calc(100vw - 24px)) !important;
}

#menu-item-1586.menu-item-has-children:hover > .sub-menu,
#menu-item-1577.menu-item-has-children:hover > .sub-menu {
  transform: translateX(0) translateY(0) !important;
}

/* Elektricni alati needs a bit more right shift than masine za vrt i dom */
#menu-item-1577 > .sub-menu {
  right: -120px !important;
}
