/* ============================================================
   SoGood Category Menu Widget – Stylesheet  v1.1.0
   ============================================================
   Uses high-specificity selectors and isolation techniques so
   the widget looks correct regardless of which Elementor version
   or theme is active.
   ============================================================ */

/* ── Wrapper ─────────────────────────────────────────────────────────── */
.sgcm-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  /* Create a stacking context so z-index values are self-contained
     and do not bleed into or conflict with theme / Elementor layers. */
  isolation: isolate;
  z-index: 9999;
}

/* ── Button ───────────────────────────────────────────────────────────── */
.sgcm-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background-color: #e8373e;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  /* Reset theme / Elementor button styles that may bleed in. */
  text-decoration: none;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: none;
  transition:
    background-color 0.2s ease,
    color            0.2s ease,
    box-shadow       0.2s ease;
  outline: none;
  position: relative;
  z-index: 1;
  -webkit-appearance: none;
  appearance: none;
}

.sgcm-btn:focus-visible {
  outline: 3px solid rgba(232, 55, 62, 0.4);
  outline-offset: 2px;
}

.sgcm-btn .sgcm-img {
  display: block;
  width: 20px;
  height: auto;
  flex-shrink: 0;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.sgcm-btn .sgcm-label {
  flex: 1;
}

.sgcm-btn .sgcm-arrow {
  display: inline-flex;
  align-items: center;
  transition: transform 0.25s ease;
  margin-left: 2px;
}

.sgcm-btn .sgcm-arrow svg {
  fill: currentColor;
  display: block;
}

/* Arrow rotates when open */
.sgcm-wrap.sgcm-open .sgcm-btn .sgcm-arrow,
.sgcm-btn[aria-expanded="true"] .sgcm-arrow {
  transform: rotate(180deg);
}

/* ── Dropdown Panel ───────────────────────────────────────────────────── */
.sgcm-dropdown {
  position: absolute;
  top: 110%;
  left: 0;
  min-width: 220px;
  width: 250px;
  background: #ffffff;
  border-radius: 0 6px 6px 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  /* Stay above Elementor sections (z-index ~1) and sticky headers (~100).
     isolation on the wrapper keeps this from conflicting with page layers. */
  z-index: 9998;
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  pointer-events: none;
  transition:
    opacity    0.22s ease,
    transform  0.22s ease,
    visibility 0s    linear 0.22s;
}

/* Visible state */
.sgcm-wrap.sgcm-open .sgcm-dropdown,
.sgcm-dropdown.sgcm-preview-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition:
    opacity    0.22s ease,
    transform  0.22s ease,
    visibility 0s    linear 0s;
}

/* ── Menu List ────────────────────────────────────────────────────────── */
.sgcm-dropdown ul.sgcm-menu {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.sgcm-dropdown ul.sgcm-menu li {
  position: relative;
  margin: 0;
  padding: 0;
}

/*
 * Reset link styles that might bleed from the active theme.
 * "all: unset" is intentionally NOT used because it breaks flex layout.
 */
.sgcm-dropdown ul.sgcm-menu li a,
.sgcm-dropdown ul.sgcm-menu li a:link,
.sgcm-dropdown ul.sgcm-menu li a:visited {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  color: #333333;
  background-color: transparent;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
  /* Prevent any theme box-shadow on links */
  box-shadow: none;
  border: none;
  outline: none;
}

.sgcm-dropdown ul.sgcm-menu li a:hover,
.sgcm-dropdown ul.sgcm-menu li a:focus {
  background-color: #f5f5f5;
  color: #e8373e;
  text-decoration: none;
  box-shadow: none;
  outline: 0;
}

/* Sub-menu expand caret */
.sgcm-dropdown .menu-item-has-children > a::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 5px solid currentColor;
  margin-left: 8px;
  opacity: 0.6;
  transition: opacity 0.15s, transform 0.2s ease;
  flex-shrink: 0;
}

.sgcm-dropdown .menu-item-has-children.sgcm-sub-item-open > a::after {
  transform: rotate(90deg);
  opacity: 1;
}

/* ── Sub-menus ────────────────────────────────────────────────────────── */
.sgcm-dropdown ul ul {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #fafafa;
  /* Hidden by default; JS toggles .sgcm-sub-open */
  display: none;
}

.sgcm-dropdown ul ul.sgcm-sub-open {
  display: block;
}

.sgcm-dropdown ul ul li a {
  padding-left: 36px;
  font-size: 13px;
  color: #555555;
}

/* Third-level */
.sgcm-dropdown ul ul ul li a {
  padding-left: 52px;
}

/* ── No-menu placeholder ──────────────────────────────────────────────── */
.sgcm-no-menu {
  padding: 16px 20px;
  margin: 0;
  font-size: 13px;
  color: #999;
  font-style: italic;
}

/* ── Elementor editor: always show dropdown as a preview ──────────────── */
.elementor-editor-active .sgcm-dropdown.sgcm-preview-open {
  position: static;
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  box-shadow: none;
  border: 1px dashed #ccc;
  margin-top: 4px;
}

/* ── RTL ──────────────────────────────────────────────────────────────── */
[dir="rtl"] .sgcm-dropdown,
.rtl .sgcm-dropdown {
  left: auto;
  right: 0;
  border-radius: 6px 0 6px 6px;
}

@media(max-width:767px){
    .sgcm-dropdown{

        right:0px;
        left:auto!important;
    }
}

/* ── Print: hide the whole widget ────────────────────────────────────── */
@media print {
  .sgcm-wrap { display: none !important; }
}
