/* ═══════════════════════════════════════════════════════════════════
   SIDEBAR NAV — CCare Kitchen
   ═══════════════════════════════════════════════════════════════════ */

/* ── Layout shell ────────────────────────────────────────────────── */
#app-layout {
  display: flex;
  min-height: calc(100vh - 66px);
  position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
:root { --sb-width: 224px; --sb-anim: .22s cubic-bezier(.4,0,.2,1); }

#sidebar {
  width: var(--sb-width);
  min-width: var(--sb-width);
  background: var(--forest);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 66px;
  height: calc(100vh - 66px);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--sb-anim), min-width var(--sb-anim), transform var(--sb-anim);
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
  flex-shrink: 0;
}
#sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 39;
  opacity: 0;
  transition: opacity .22s;
}
#sidebar-backdrop.visible { opacity: 1; }

/* ── Toggle button ───────────────────────────────────────────────── */
#sidebar-toggle {
  position: fixed;
  top: 78px;
  left: 0;
  width: 26px;
  height: 48px;
  background: var(--moss);
  border: none;
  border-radius: 0 10px 10px 0;
  color: rgba(255,255,255,.8);
  font-size: 13px;
  cursor: pointer;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left var(--sb-anim), background .15s;
  box-shadow: 2px 0 8px rgba(0,0,0,.2);
}
#sidebar-toggle:hover { background: var(--sage); color: #fff; }
#sidebar-toggle .toggle-icon { display: block; }

/* ── Main content ────────────────────────────────────────────────── */
#main-content { flex: 1; min-width: 0; }
#main-content main { padding: 22px 24px 22px 36px; }
#sidebar:not(.collapsed) ~ #main-content main { padding-left: 24px; }

/* ── Sidebar inner ───────────────────────────────────────────────── */
.sb-inner {
  padding: 0 0 12px;
  min-width: var(--sb-width);
  width: var(--sb-width);
}

/* ── Search bar ──────────────────────────────────────────────────── */
.sb-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 10px 6px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 5px 8px;
  transition: background .15s, border-color .15s;
}
.sb-search-wrap:focus-within {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.25);
}
.sb-search-icon {
  font-size: 11px;
  opacity: .5;
  flex-shrink: 0;
  line-height: 1;
  filter: grayscale(1);
}
.sb-search-inp {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: rgba(255,255,255,.85);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  min-width: 0;
  caret-color: var(--gold);
}
.sb-search-inp::placeholder { color: rgba(255,255,255,.3); }
.sb-search-clear {
  background: none;
  border: none;
  color: rgba(255,255,255,.3);
  font-size: 10px;
  cursor: pointer;
  padding: 1px 2px;
  border-radius: 3px;
  line-height: 1;
  opacity: 0;
  transition: opacity .12s, color .12s;
  flex-shrink: 0;
}
.sb-search-clear:hover { color: rgba(255,255,255,.7); }

/* Search results — flat list of all matching items */
.sb-search-results {
  padding: 4px 0;
}

/* ── Compact favourites strip ────────────────────────────────────── */
.sb-fav-strip {
  padding: 2px 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  margin-bottom: 2px;
}
.sb-fav-strip-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(233,168,76,.55);
  margin-bottom: 5px;
  padding-left: 2px;
}
.sb-fav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.sb-fav-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 6px;
  background: rgba(233,168,76,.12);
  border: 1px solid rgba(233,168,76,.25);
  border-radius: 20px;
  color: rgba(233,168,76,.85);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  max-width: 96px;
}
.sb-fav-pill:hover {
  background: rgba(233,168,76,.22);
  border-color: rgba(233,168,76,.5);
  color: #fff;
}
.sb-fav-pill.active {
  background: rgba(233,168,76,.28);
  border-color: var(--gold);
  color: #fff;
}
.sb-fav-icon { font-size: 12px; line-height: 1; }
.sb-fav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Group header ────────────────────────────────────────────────── */
.sb-group { margin-bottom: 0; }
.sb-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px 4px 16px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.sb-group-header:hover { background: rgba(255,255,255,.06); }
.sb-group-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: rgba(255,255,255,.4);
  white-space: nowrap;
}
.sb-group-header.has-active .sb-group-label { color: rgba(255,255,255,.7); }
.sb-chevron {
  font-size: 9px;
  color: rgba(255,255,255,.3);
  transition: transform .18s;
  flex-shrink: 0;
}
.sb-group.open .sb-chevron { transform: rotate(180deg); }

/* ── Tab items ───────────────────────────────────────────────────── */
.sb-tabs {
  overflow: hidden;
  max-height: 0;
  transition: max-height .22s cubic-bezier(.4,0,.2,1);
}
.sb-group.open .sb-tabs { max-height: 600px; }

.sb-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px 6px 24px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,.55);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .12s, color .12s;
  white-space: nowrap;
  position: relative;
  border-left: 3px solid transparent;
  font-family: 'DM Sans', sans-serif;
}
.sb-tab:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.sb-tab.active {
  color: #fff;
  background: rgba(255,255,255,.1);
  border-left-color: var(--mint);
  font-weight: 700;
}
.sb-tab .sb-badge {
  margin-left: auto;
  background: var(--tc);
  color: #fff;
  font-size: 9px;
  border-radius: 9px;
  padding: 1px 5px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Star button — hover-only, right-aligned ─────────────────────── */
.sb-tab .sb-star {
  margin-left: auto;
  opacity: 0;
  font-size: 11px;
  color: rgba(255,255,255,.35);
  transition: opacity .12s, color .12s;
  padding: 2px 3px;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
}
/* Only show star on hover of the parent tab */
.sb-tab:hover .sb-star { opacity: 1; }
/* Starred items always show their star (gold) */
.sb-tab .sb-star.starred {
  opacity: 1;
  color: var(--gold);
}
.sb-tab .sb-star:hover { color: var(--gold); background: rgba(255,255,255,.1); }
/* When badge also present, push star after it */
.sb-tab .sb-badge ~ .sb-star { margin-left: 4px; }

/* ── Misc ────────────────────────────────────────────────────────── */
.sb-group-empty {
  padding: 5px 14px 5px 24px;
  font-size: 11px;
  color: rgba(255,255,255,.25);
  font-style: italic;
}
.sb-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 3px 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  :root { --sb-width: 200px; }
  #main-content main { padding: 16px; }
}

@media (max-width: 767px) {
  :root { --sb-width: 240px; }
  #app-layout { display: block; }
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--sb-anim);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  #sidebar.mobile-open { transform: translateX(0); }
  #sidebar.collapsed {
    width: var(--sb-width);
    min-width: var(--sb-width);
  }
  #sidebar-backdrop { display: block; position: fixed; }
  #sidebar-toggle {
    top: 14px; left: 14px;
    width: 38px; height: 38px;
    border-radius: 10px;
    font-size: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
    z-index: 55;
  }
  #main-content main { padding: 12px; }
  .hdr-stats { display: none; }
  .logo-text span { display: none; }
  header { padding: 0 12px 0 60px; height: 56px; }
}

@media (max-width: 480px) {
  header { height: 52px; }
  #sidebar-toggle { top: 10px; }
}

#main-nav { display: none !important; }


/* ── Layout shell ────────────────────────────────────────────────── */
#app-layout {
  display: flex;
  min-height: calc(100vh - 66px); /* below header */
  position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
:root { --sb-width: 224px; --sb-anim: .22s cubic-bezier(.4,0,.2,1); }

#sidebar {
  width: var(--sb-width);
  min-width: var(--sb-width);
  background: var(--forest);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 66px; /* below header */
  height: calc(100vh - 66px);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--sb-anim), min-width var(--sb-anim), transform var(--sb-anim);
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
  flex-shrink: 0;
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

/* Backdrop for mobile */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 39;
  opacity: 0;
  transition: opacity .22s;
}
#sidebar-backdrop.visible {
  opacity: 1;
}

/* ── Sidebar toggle button ───────────────────────────────────────── */
#sidebar-toggle {
  position: fixed;
  top: 78px;
  left: 0;
  width: 26px;
  height: 48px;
  background: var(--moss);
  border: none;
  border-radius: 0 10px 10px 0;
  color: rgba(255,255,255,.8);
  font-size: 13px;
  cursor: pointer;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left var(--sb-anim), background .15s;
  box-shadow: 2px 0 8px rgba(0,0,0,.2);
}
#sidebar-toggle:hover { background: var(--sage); color: #fff; }
#sidebar-toggle .toggle-icon { display: block; }

/* ── Main content ────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  min-width: 0;
}
#main-content main {
  padding: 22px 24px 22px 36px; /* 36px left clears toggle button */
}
#sidebar:not(.collapsed) ~ #main-content main {
  padding-left: 24px; /* sidebar visible — no need for extra left pad */
}

/* ── Sidebar inner sections ──────────────────────────────────────── */
.sb-inner {
  padding: 6px 0 12px;
  min-width: var(--sb-width);
  width: var(--sb-width);
}

/* ── Group header ────────────────────────────────────────────────── */
.sb-group { margin-bottom: 0; }

.sb-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px 4px 16px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
  border-radius: 0;
}
.sb-group-header:hover { background: rgba(255,255,255,.06); }

.sb-group-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: rgba(255,255,255,.4);
  white-space: nowrap;
}
.sb-group-header.has-active .sb-group-label { color: rgba(255,255,255,.7); }

.sb-chevron {
  font-size: 9px;
  color: rgba(255,255,255,.3);
  transition: transform .18s;
  flex-shrink: 0;
}
.sb-group.open .sb-chevron { transform: rotate(180deg); }

/* ── Tab items ───────────────────────────────────────────────────── */
.sb-tabs {
  overflow: hidden;
  max-height: 0;
  transition: max-height .22s cubic-bezier(.4,0,.2,1);
}
.sb-group.open .sb-tabs { max-height: 500px; }

.sb-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px 6px 24px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,.55);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .12s, color .12s;
  white-space: nowrap;
  position: relative;
  border-left: 3px solid transparent;
  font-family: 'DM Sans', sans-serif;
}
.sb-tab:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.sb-tab.active {
  color: #fff;
  background: rgba(255,255,255,.1);
  border-left-color: var(--mint);
  font-weight: 700;
}
.sb-tab .sb-badge {
  margin-left: auto;
  background: var(--tc);
  color: #fff;
  font-size: 9px;
  border-radius: 9px;
  padding: 1px 5px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Favourites star button (appears on hover over each tab) ──────── */
.sb-tab .sb-star {
  margin-left: auto;
  opacity: 0;
  font-size: 11px;
  color: rgba(255,255,255,.4);
  transition: opacity .12s, color .12s;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
}
.sb-tab:hover .sb-star { opacity: 1; }
.sb-tab .sb-star.starred { opacity: 1; color: var(--gold); }
.sb-tab .sb-star:hover { color: var(--gold); background: rgba(255,255,255,.1); }
/* When badge also present, star replaces badge position */
.sb-tab .sb-badge + .sb-star { margin-left: 4px; }

/* ── Favourites group special styling ────────────────────────────── */
.sb-group[data-group="favourites"] .sb-group-label { color: rgba(233,168,76,.7); }
.sb-group[data-group="favourites"] .sb-tab.active { border-left-color: var(--gold); }
.sb-group[data-group="favourites"] .sb-group-header.has-active .sb-group-label { color: var(--gold); }
.sb-group-empty {
  padding: 5px 14px 5px 24px;
  font-size: 11px;
  color: rgba(255,255,255,.25);
  font-style: italic;
}

/* ── Sidebar divider ─────────────────────────────────────────────── */
.sb-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 3px 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

/* ── Tablet (768–1024px) — sidebar starts open, can close ──────── */
@media (max-width: 1024px) {
  :root { --sb-width: 200px; }
  #main-content main { padding: 16px 16px; }
}

/* ── Mobile (< 768px) — sidebar is an overlay drawer ────────────── */
@media (max-width: 767px) {
  :root { --sb-width: 240px; }

  #app-layout { display: block; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--sb-anim);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }
  #sidebar.collapsed {
    /* On mobile "collapsed" means hidden — use transform not width */
    width: var(--sb-width);
    min-width: var(--sb-width);
  }

  #sidebar-backdrop { display: block; position: fixed; }

  #sidebar-toggle {
    top: 14px;
    left: 14px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
    z-index: 55;
  }

  #main-content main { padding: 12px 12px; }

  /* Hide header stats on mobile */
  .hdr-stats { display: none; }
  .logo-text span { display: none; }

  /* Stack header more tightly */
  header { padding: 0 12px 0 60px; height: 56px; }
}

/* ── Very small screens ──────────────────────────────────────────── */
@media (max-width: 480px) {
  header { height: 52px; }
  #sidebar-toggle { top: 10px; }
}

/* ── Keep old nav hidden (compat) ───────────────────────────────── */
#main-nav { display: none !important; }
