/* ── Page Layout ─────────────────────────────────────────────── */
.layout {
  display: flex;
  align-items: stretch;
  position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  width: 256px;
  flex-shrink: 0;
  min-height: calc(100vh - var(--header-h));
  max-height: calc(100vh - var(--header-h));
  overflow: visible;
  background: #fff;
  border-right: 1px solid #f8f5f5;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.05);
  z-index: 800;
  transition:
    transform 0.4s ease,
    box-shadow 0.4s ease;
}

.main_cat_group {
  position: relative;
}

/* Thin scrollbar inside sidebar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: #a8f0c6;
  border-radius: 2px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: #22a355;
}

/* ── Sidebar Header ──────────────────────────────────────────── */
.sidebar h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #145c30;
  padding: 20px 20px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #f8f5f5;
  letter-spacing: -0.01em;
}

.sidebar h2 i,
.sidebar h2 .material-icons {
  font-size: 1.1rem;
  color: #22a355;
}

/* ── Main Category Row ───────────────────────────────────────── */
.sidebar .main_cat_row {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 1px solid #f8f5f5;
  transition: background 0.15s ease;
}

.sidebar .main_cat_row:hover {
  background: #f0fdf6;
}

.sidebar .main_cat_link {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 12px 20px;
  font-size: 0.875rem;
  font-weight: 700;
  color: #1c1a17;
  text-decoration: none;
  transition: color 0.15s ease;
}

.sidebar .main_cat_link:hover {
  color: #145c30;
}

.sidebar .main_cat_toggle {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 0;
  background: transparent;
  transition: background 0.15s ease;
}

.sidebar .main_cat_toggle:hover {
  background: rgba(0, 0, 0, 0.03);
}

.sidebar .main_cat_arrow {
  font-size: 1rem;
  color: #8a8278;
  transition: transform 0.25s ease;
  line-height: 1;
  pointer-events: none;
}

.sidebar .main_cat_group:hover .main_cat_arrow,
.sidebar .main_cat_group:focus-within .main_cat_arrow,
.sidebar .main_cat_group.is-open .main_cat_arrow,
.sidebar .main_cat_row.open .main_cat_arrow {
  transform: rotate(90deg);
  color: #22a355;
}

/* ── Sub-category Container ──────────────────────────────────── */
.sidebar .dic1 {
  position: absolute;
  top: 4px;
  left: calc(100% + 10px);
  width: min(320px, calc(100vw - 310px));
  max-height: min(420px, calc(100vh - var(--header-h) - 32px));
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border: 1px solid #dfeadd;
  box-shadow: 0 18px 46px rgba(16, 55, 26, 0.16);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-6px);
  transition:
    opacity 0.15s ease,
    visibility 0.15s ease,
    transform 0.15s ease;
  z-index: 1200;
}

.sidebar .main_cat_group:hover .dic1,
.sidebar .main_cat_group:focus-within .dic1,
.sidebar .main_cat_group.is-open .dic1,
.sidebar .dic1.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

.flyout-card__heading {
  padding: 8px 10px 10px;
  color: #145c30;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  border-bottom: 1px solid #edf6e8;
  margin-bottom: 4px;
}

/* ── Sub-category Link ───────────────────────────────────────── */
.sidebar .sub_cat {
  display: flex;
  align-items: center;
  padding: 10px 12px 10px 26px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #5a5550;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    padding-left 0.15s ease;
  margin: 0;
  border-bottom: 1px solid #edf6e8;
  position: relative;
}
.sidebar .sub_cat::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 2px;
  background:#145c30;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}
.sidebar .sub_cat:hover {
  color: #145c30;
  background: #f0fdf6;
  padding-left: 30px;
}

.sidebar .sub_cat.active {
  color: #145c30;
  font-weight: 600;
  background: #fff;
}

.sidebar a {
  text-decoration: none;
  color: inherit;
}

/* ── Layout Content Area ─────────────────────────────────────── */
.layout-content {
  flex: 1;
  min-width: 0;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 991px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    display: block;
    position: relative;
    top: auto;
    align-self: stretch;
    width: 100%;
    min-height: 0;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid #e5efe1;
    box-shadow: none;
    z-index: 10;
  }

  .layout-content {
    width: 100%;
  }

  .sidebar h2 {
    padding: 14px 18px 10px;
    margin: 0;
    color: #145c30;
    font-size: 0.86rem;
    font-weight: 700;
    border-bottom: 1px solid #edf6e8;
  }

  .main_cat_group {
    position: relative;
  }

  .sidebar .main_cat_row {
    border-bottom: 1px solid #edf6e8;
    background: #ffffff;
  }

  .sidebar .main_cat_link {
    padding: 12px 18px;
    color: #1c1a17;
    font-size: 0.88rem;
  }

  .sidebar .main_cat_toggle {
    padding: 12px 18px;
  }

  .sidebar .dic1,
  .sidebar .main_cat_group:hover .dic1,
  .sidebar .main_cat_group:focus-within .dic1 {
    position: static;
    width: auto;
    max-height: 0;
    margin: 0 14px;
    padding: 0 8px;
    overflow: hidden;
    border: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition:
      max-height 0.2s ease,
      margin 0.2s ease,
      padding 0.2s ease;
  }

  .sidebar .main_cat_group.is-open .dic1 {
    max-height: 420px;
    margin: 8px 14px 14px;
    padding: 8px;
    border: 1px solid #d7ead0;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(18, 72, 26, 0.12);
  }

  .flyout-card__heading {
    padding: 8px 8px 10px;
  }

  .sidebar .sub_cat {
    padding: 11px 14px 11px 30px;
    color: #3a8020;
    font-weight: 650;
  }

  .sidebar .sub_cat::before {
    left: 14px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #a8d48e;
  }

  .sidebar .sub_cat:hover {
    padding-left: 34px;
  }
}
