/* ================================================================
   SIDEBAR.CSS — Shared sidebar + layout system
   FIX: Sidebar no longer overlaps the footer — uses sticky
        positioning within a flex layout that stops at the footer.
   ================================================================ */

/* ── Page Layout ─────────────────────────────────────────────── */
.layout {
  display: flex;
  align-items: stretch;          /* both sidebar & content grow to full layout height */
  background: var(--cream-100);
  position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  /* sticky so it stays in view while scrolling,
     but still lives in the normal flow — never past the footer */
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;        /* allows sticky to work inside a stretch container */
  width: 256px;
  flex-shrink: 0;

  /* Always fill at least the visible viewport height so there
     is no gap between the sidebar bottom and the footer */
  min-height: calc(100vh - var(--header-h));

  /* Scroll within sidebar only when its own content overflows */
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;

  background: #fff;
  border-right: 1px solid var(--cream-300);
  box-shadow: 2px 0 20px rgba(0,0,0,.05);
  z-index: 800;
  transition: transform var(--trans-slow), box-shadow var(--trans-slow);
}

/* Thin scrollbar inside sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--green-200);
  border-radius: 2px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--green-600); }

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

.sidebar h2 i,
.sidebar h2 .material-icons {
  font-size: 1.1rem;
  color: var(--green-600);
}

/* ── Main Category ───────────────────────────────────────────── */
.sidebar .main_cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--dark);
  cursor: pointer;
  border-bottom: 1px solid var(--cream-200);
  transition: background var(--trans-fast), color var(--trans-fast);
  margin: 0;
  letter-spacing: .01em;
  user-select: none;
}
.sidebar .main_cat::after {
  content: '›';
  font-size: 1rem;
  color: var(--warm-gray);
  transition: transform var(--trans-base);
  line-height: 1;
}
.sidebar .main_cat.open::after {
  transform: rotate(90deg);
  color: var(--green-600);
}
.sidebar .main_cat:hover {
  background: var(--green-50);
  color: var(--green-800);
}

/* ── Sub-category Container ──────────────────────────────────── */
.sidebar .dic1 {
  display: none;
  background: var(--green-50);
  border-bottom: 1px solid var(--cream-200);
}
.sidebar .dic1.show {
  display: block;
  animation: slideDown .2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Sub-category Link ───────────────────────────────────────── */
.sidebar .sub_cat {
  display: flex;
  align-items: center;
  padding: 9px 20px 9px 34px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--mid-gray);
  cursor: pointer;
  transition: background var(--trans-fast), color var(--trans-fast), padding-left var(--trans-fast);
  margin: 0;
  border-bottom: 1px solid rgba(0,0,0,.04);
  position: relative;
}
.sidebar .sub_cat::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green-300, #86efac);
  transition: background var(--trans-fast), transform var(--trans-fast);
}
.sidebar .sub_cat:hover {
  background: #fff;
  color: var(--green-800);
  padding-left: 38px;
}
.sidebar .sub_cat:hover::before {
  background: var(--green-600);
  transform: translateY(-50%) scale(1.4);
}
.sidebar .sub_cat.active {
  color: var(--green-800);
  font-weight: 600;
  background: #fff;
}

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

/* ── Floating Mobile Toggle Button ──────────────────────────── */
.sidebar-toggle-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 16px;
  z-index: 900;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green-800);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-green);
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all var(--trans-base);
}
.sidebar-toggle-btn:hover {
  background: var(--green-700);
  transform: scale(1.08);
}

/* ── Layout Content Area ─────────────────────────────────────── */
.layout-content {
  flex: 1;
  min-width: 0;                  /* prevents flex blowout */
  background: var(--cream-100);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 991px) {
  /* On mobile the sidebar goes back to fixed/off-canvas */
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100vh - var(--header-h));
    max-height: none;
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 1050;
  }
  .sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.15);
  }
  .layout-content {
    /* Full width when sidebar is off-canvas */
    width: 100%;
  }
  .sidebar-toggle-btn {
    display: flex;
  }
}