/* ==========================================================================
   HK Side Navigation Widget
   Matches Figma: Hokheng-1 › "Hokheng 2 - Homepage" › "Side Menu"
   ========================================================================== */

/* ── Card shell ──────────────────────────────────────────────────────────── */
.hk-side-nav {
  background: #ffffff;
  border-radius: 24px;
  box-shadow:
    0 10px 7.5px rgba(0, 0, 0, 0.10),
    0 4px  3px   rgba(0, 0, 0, 0.10);
  overflow: hidden;
  padding-bottom: 24px;
  width: 100%;          /* let the Elementor column control the width */
  max-width: 360px;
}

/* ── Header bar ──────────────────────────────────────────────────────────── */
.hk-side-nav__header {
  /* CSS-variable gradient so Elementor style controls can override */
  --hk-nav-grad-start: #1b5e20;
  --hk-nav-grad-end:   #2e7d32;
  background: linear-gradient(
    90deg,
    var(--hk-nav-grad-start) 0%,
    var(--hk-nav-grad-end)   100%
  );
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;   /* center the lone hamburger icon */
  gap: 8px;
  padding: 0 20px;
  border-radius: 24px 24px 0 0;  /* top corners only */
}

.hk-side-nav__header-icon {
  flex-shrink: 0;
}

.hk-side-nav__header-title {
  display: none;   /* title text removed — keep only the green bar + hamburger */
  color: #ffffff;
  font-family: var(--font-menu, 'Noto Sans Thai', sans-serif);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

/* "เมนู" label + toggle chevron — desktop hidden, shown only on mobile. */
.hk-side-nav__mobile-label { display: none; }
.hk-side-nav__toggle-arrow { display: none; }

/* ── Navigation wrapper ──────────────────────────────────────────────────── */
.hk-side-nav__nav {
  padding-top: 8px;
}

.hk-side-nav__list {
  list-style: none;
  margin:  0;
  padding: 0;
}

/* ── Individual menu item ────────────────────────────────────────────────── */
.hk-side-nav__item {
  /* nothing — wrapper for semantics */
}

.hk-side-nav__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 50px;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 8px;     /* clips the yellow active-bg */
  overflow: hidden;
  transition: background 0.15s;
}

/* Hover state for non-active items — same yellow as active */
.hk-side-nav__item:not(.hk-side-nav__item--active) .hk-side-nav__link:hover {
  background: #f9a825;
}

/* ── Active background (yellow pill) ────────────────────────────────────── */
.hk-side-nav__active-bg {
  position: absolute;
  inset: 0;
  background: #f9a825;
  border-radius: 8px;
  z-index: 0;
}

/* ── Icon pill ───────────────────────────────────────────────────────────── */
.hk-side-nav__icon-pill {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width:  28px;
  height: 28px;
  border-radius: 50%;
  background: #f1f8e9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hk-side-nav__item--active .hk-side-nav__icon-pill {
  /* slightly lighter pill on yellow bg */
  background: rgba(255, 255, 255, 0.55);
}

.hk-side-nav__icon-pill i {
  font-size: 12px;
  color: #1b5e20;
  line-height: 1;
}

/* ── Label text ──────────────────────────────────────────────────────────── */
.hk-side-nav__label {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 19px;
  font-weight: 400;
  color: #1b5e20;
  line-height: 1.4;
  word-break: break-word;
}

/* Keep the link vertically centered when label wraps to two lines */
.hk-side-nav__link:has(.hk-side-nav__label br) {
  align-items: center;
}

.hk-side-nav__item--active .hk-side-nav__label {
  font-weight: 600;
}

/* ── Chevron arrow ───────────────────────────────────────────────────────── */
/* Hidden to give menu label text more room. Children flyouts (if any) still
   work on hover; only the visual cue is removed. */
.hk-side-nav__arrow {
  display: none;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  color: #1b5e20;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.15s;
}

.hk-side-nav__item:not(.hk-side-nav__item--active) .hk-side-nav__link:hover .hk-side-nav__arrow {
  opacity: 1;
  transform: translateX(2px);
}

.hk-side-nav__item--active .hk-side-nav__arrow {
  opacity: 1;
}

/* ── Keep parent highlighted while its flyout is open ───────────────────── */
/* When JS adds .hk-sub-open the cursor may be over the portal flyout (body
   child), so CSS :hover is lost on the <li>. This rule restores the yellow
   highlight so the parent item stays visually "selected" the whole time. */
.hk-side-nav__item--has-children.hk-sub-open .hk-side-nav__link {
  background: #f9a825;
}

/* Rotate the chevron 90° to point right → open, matching flyout direction */
.hk-side-nav__item--has-children.hk-sub-open .hk-side-nav__arrow {
  opacity: 1;
  transform: rotate(90deg);
}

/* ── Sticky offset — push below admin bar for logged-in users ──────────── */
/* ── Sticky top offset ─────────────────────────────────────────────────── */
.hk-sidebar {
  top: 20px !important; /* gap for normal visitors */
}

.admin-bar .hk-sidebar {
  top: 60px !important; /* 32px admin bar + 28px gap for logged-in users */
}

/* ── Mobile: collapse the whole menu behind a "เมนู" toggle ──────────────── */
@media (max-width: 767px) {
  /* Fill the column width on mobile (drop the 360px desktop cap) so the
     menu bar lines up with the mission/activity/newsletter blocks. */
  .hk-side-nav {
    max-width: none;
  }

  /* Header becomes a tappable bar: hamburger + "เมนู" on the left, chevron right. */
  .hk-side-nav__header {
    height: 48px;
    justify-content: flex-start;
    gap: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .hk-side-nav__mobile-label {
    display: inline;
    color: #ffffff;
    font-family: 'Noto Sans Thai', sans-serif;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
  }

  .hk-side-nav__toggle-arrow {
    display: block;
    margin-left: auto;
    color: #ffffff;
    transition: transform 0.2s ease;
  }

  .hk-side-nav.is-open .hk-side-nav__toggle-arrow {
    transform: rotate(180deg);
  }

  /* Menu list is collapsed by default, revealed when the card has .is-open. */
  .hk-side-nav__nav {
    display: none;
  }

  .hk-side-nav.is-open .hk-side-nav__nav {
    display: block;
  }

  /* No bottom padding while collapsed so the card is just the header bar. */
  .hk-side-nav:not(.is-open) {
    padding-bottom: 0;
  }
}
