/* Sidebar shell: collapse, drawer, layout sync (html[data-sidebar]) */

html[data-sidebar="collapsed"] .app {
  grid-template-columns: 72px 1fr;
}

html[data-sidebar="expanded"] .app {
  grid-template-columns: 248px 1fr;
}

html[data-sidebar="collapsed"] .rec-bar-wrap:not(.rec-bar-wrap--hidden) {
  left: 72px;
}

html[data-sidebar="expanded"] .rec-bar-wrap:not(.rec-bar-wrap--hidden) {
  left: 248px;
}

.app--no-sidebar {
  grid-template-columns: 1fr !important;
}

.app--no-sidebar .rec-bar-wrap:not(.rec-bar-wrap--hidden) {
  left: 0 !important;
}

.sidebar {
  background: #0b0b0b;
  color: #edede6;
  width: 248px;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

html[data-sidebar="collapsed"] .sidebar,
.sidebar[data-collapsed="1"] {
  width: 72px;
}

.sidebar .brand {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #1c1c1c;
}

.sidebar .brand .mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  background-color: var(--accent);
  background-image: url("../uploads/claude_avatar.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.sidebar .brand .name {
  font-family: "Lispako", "Roboto", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 16px;
  line-height: 1.1;
  color: #fff;
  white-space: nowrap;
}

.sidebar .brand .name span {
  display: block;
  color: var(--accent);
}

html[data-sidebar="collapsed"] .sidebar .brand,
.sidebar[data-collapsed="1"] .brand {
  padding: 22px 0 18px;
  justify-content: center;
}

html[data-sidebar="collapsed"] .sidebar .brand .name,
.sidebar[data-collapsed="1"] .brand .name {
  display: none;
}

.sidebar nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
}

.sidebar .section {
  font-family: "Lispako", "Roboto", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10.5px;
  color: #6e6e66;
  padding: 14px 12px 6px;
}

html[data-sidebar="collapsed"] .sidebar .section,
.sidebar[data-collapsed="1"] .section {
  visibility: hidden;
  height: 12px;
  padding: 6px 0;
}

.sidebar .item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #c8c8c0;
  font-size: 13.5px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar .item:hover {
  background: #1a1a1a;
  color: #fff;
}

.sidebar .item.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.sidebar .item .ico {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar .item .ico svg {
  width: 20px;
  height: 20px;
  display: block;
}

.sidebar .item .label {
  flex: 1;
}

.sidebar .item .count {
  font-size: 11.5px;
  color: inherit;
  opacity: 0.7;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.sidebar .item.active .count {
  background: rgba(0, 0, 0, 0.15);
  opacity: 0.9;
}

html[data-sidebar="collapsed"] .sidebar .item,
.sidebar[data-collapsed="1"] .item {
  justify-content: center;
  padding: 11px 0;
}

html[data-sidebar="collapsed"] .sidebar .item .label,
html[data-sidebar="collapsed"] .sidebar .item .count,
.sidebar[data-collapsed="1"] .item .label,
.sidebar[data-collapsed="1"] .item .count {
  display: none;
}

.sidebar .foot {
  padding: 14px 12px;
  border-top: 1px solid #1c1c1c;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .foot .avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  background: #2a2a26;
  color: #edede6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.sidebar .foot .who {
  flex: 1;
  min-width: 0;
}

.sidebar .foot .who .n {
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .foot .who .e {
  font-size: 11.5px;
  color: #8b8b85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .foot .collapse-btn {
  background: transparent;
  border: 0;
  color: #8b8b85;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar .foot .collapse-btn:hover {
  background: #1a1a1a;
  color: #fff;
}

html[data-sidebar="collapsed"] .sidebar .foot,
.sidebar[data-collapsed="1"] .foot {
  flex-direction: column;
  padding: 14px 0;
  gap: 10px;
}

html[data-sidebar="collapsed"] .sidebar .foot .who,
.sidebar[data-collapsed="1"] .foot .who {
  display: none;
}

html[data-sidebar="collapsed"] .sidebar .foot .collapse-btn svg,
.sidebar[data-collapsed="1"] .foot .collapse-btn svg {
  transform: rotate(180deg);
}

/* Mobile drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 49;
}

.sidebar-backdrop.is-open {
  display: block;
}

body.sidebar-drawer-open {
  overflow: hidden;
}

.topbar .sidebar-drawer-btn {
  display: none;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .topbar .sidebar-drawer-btn {
    display: inline-flex;
  }

  html[data-sidebar="collapsed"] .app,
  html[data-sidebar="expanded"] .app {
    grid-template-columns: 1fr !important;
  }

  html[data-sidebar="collapsed"] .rec-bar-wrap:not(.rec-bar-wrap--hidden),
  html[data-sidebar="expanded"] .rec-bar-wrap:not(.rec-bar-wrap--hidden) {
    left: 0 !important;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    width: 248px !important;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Drawer always shows full labels; desktop collapsed width rules skipped above */
  html[data-sidebar="collapsed"] .sidebar.open .brand .name,
  .sidebar[data-collapsed="1"].open .brand .name {
    display: block;
  }

  html[data-sidebar="collapsed"] .sidebar.open .brand,
  .sidebar[data-collapsed="1"].open .brand {
    padding: 22px 20px 18px;
    justify-content: flex-start;
  }

  html[data-sidebar="collapsed"] .sidebar.open .section,
  .sidebar[data-collapsed="1"].open .section {
    visibility: visible;
    height: auto;
    padding: 14px 12px 6px;
  }

  html[data-sidebar="collapsed"] .sidebar.open .item,
  .sidebar[data-collapsed="1"].open .item {
    justify-content: flex-start;
    padding: 11px 12px;
  }

  html[data-sidebar="collapsed"] .sidebar.open .item .label,
  .sidebar[data-collapsed="1"].open .item .label {
    display: block;
    flex: 1;
    min-width: 0;
  }

  html[data-sidebar="collapsed"] .sidebar.open .item .count,
  .sidebar[data-collapsed="1"].open .item .count {
    display: inline-flex;
    align-items: center;
  }

  html[data-sidebar="collapsed"] .sidebar.open .foot .who,
  .sidebar[data-collapsed="1"].open .foot .who {
    display: block;
    flex: 1;
    min-width: 0;
  }

  html[data-sidebar="collapsed"] .sidebar.open .foot,
  .sidebar[data-collapsed="1"].open .foot {
    flex-direction: row;
    padding: 14px 12px;
  }
}
