/* ─── App Shell — Sidebar (desktop) + Bottom nav (mobile) ─── */

/* Global resets — applied to all /app/* pages via shell.css */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* enforce hidden attr — badges/elements must not leak */

html {
  scrollbar-gutter: stable;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
}

:root {
  --shell-sidebar-width: 220px;
  --shell-sidebar-collapsed: 60px;
  --shell-bottom-nav-height: 60px;
  --shell-bg: #1f2937;
  --shell-text: #f9fafb;
  --shell-text-muted: #9ca3af;
  --shell-active-bg: rgba(79, 70, 229, 0.15);
  --shell-active-color: #818cf8;
  --shell-hover-bg: rgba(255, 255, 255, 0.06);
  --shell-border: rgba(255, 255, 255, 0.08);
  --shell-accent: #4f46e5;
}

/* ─── Layout wrapper ─── */
.app-shell-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.app-shell-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--shell-sidebar-width);
  background: var(--shell-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.2s ease;
  overflow: hidden;
}

.app-shell-sidebar.collapsed {
  width: var(--shell-sidebar-collapsed);
}

/* Brand */
.shell-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--shell-border);
  min-height: 64px;
  white-space: nowrap;
  overflow: hidden;
}

.shell-brand__icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  text-align: center;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
  padding: 2px;
}

.shell-brand__name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--shell-text);
  opacity: 1;
  transition: opacity 0.15s;
}

.collapsed .shell-brand__name {
  opacity: 0;
  pointer-events: none;
}

/* Nav items */
.shell-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.75rem 0.5rem;
  overflow: hidden;
}

.shell-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  color: var(--shell-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  min-height: 40px; /* prevent layout shift when inline badge appears */
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.shell-nav-item:hover {
  background: var(--shell-hover-bg);
  color: var(--shell-text);
}

.shell-nav-item.active {
  background: var(--shell-active-bg);
  color: var(--shell-active-color);
  font-weight: 500; /* lock weight — prevent subpixel reflow on color change */
}

.shell-nav-item__icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  position: relative; /* contain badge absolutely */
  line-height: 1; /* prevent icon height jumping */
}

.shell-nav-item__label {
  opacity: 1;
  transition: opacity 0.15s;
  font-size: 0.9rem; /* explicit — prevent inheritance shifts */
  font-weight: 500;
  line-height: 1.2;
}

.collapsed .shell-nav-item__label {
  opacity: 0;
  pointer-events: none;
}

/* Footer (user + sign out) */
.shell-footer {
  border-top: 1px solid var(--shell-border);
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shell-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  overflow: hidden;
}

.shell-user__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--shell-accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shell-user__name {
  font-size: 0.8rem;
  color: var(--shell-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 0.15s;
}

.collapsed .shell-user__name {
  opacity: 0;
}

/* Collapse toggle */
.shell-collapse-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--shell-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.shell-collapse-btn:hover {
  background: var(--shell-hover-bg);
  color: var(--shell-text);
}

.shell-collapse-btn__icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  transition: transform 0.2s;
}

.collapsed .shell-collapse-btn__icon {
  transform: rotate(180deg);
}

.shell-collapse-btn__label {
  opacity: 1;
  transition: opacity 0.15s;
}

.collapsed .shell-collapse-btn__label {
  opacity: 0;
  pointer-events: none;
}

/* ─── Page content offset ─── */
.page-content {
  margin-left: var(--shell-sidebar-width);
  flex: 1;
  min-width: 0;
  transition: margin-left 0.2s ease;
}

.app-shell-sidebar.collapsed ~ .page-content,
body.sidebar-collapsed .page-content {
  margin-left: var(--shell-sidebar-collapsed);
}

/* ─── Mobile: bottom nav ─── */
.app-shell-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--shell-bottom-nav-height);
  background: var(--shell-bg);
  border-top: 1px solid var(--shell-border);
  z-index: 100;
}

.bottom-nav-inner {
  display: flex;
  height: 100%;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--shell-text-muted);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  transition: color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--shell-active-color);
  font-weight: 500; /* prevent font-weight shift on active */
}

.bottom-nav-item__icon {
  font-size: 1.3rem;
  line-height: 1;
}

.bottom-nav-item__label {
  text-align: center;
}

@media (max-width: 768px) {
  .app-shell-sidebar {
    display: none;
  }

  .app-shell-bottom-nav {
    display: block;
  }

  .page-content {
    margin-left: 0 !important;
    padding-bottom: var(--shell-bottom-nav-height);
  }
}

/* ─── Skill count badge (#444) ───────────────────────────────────────────── */

/* Sidebar badge — on icon (collapsed state + mobile) */
.shell-nav-item__icon {
  position: relative;
}

.shell-skills-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--shell-active-color, #7c6fcd);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  /* Sit in the top-right corner of the icon wrapper */
  position: absolute;
  top: -6px;
  right: -8px;
  pointer-events: none;
  /* Smooth in/out */
  transition: opacity 0.2s;
}

/* Inline badge — appears after label on expanded desktop sidebar */
.shell-skills-badge--inline {
  position: static;
  top: unset;
  right: unset;
  margin-left: 6px;
  font-size: 0.7rem;
  min-width: 22px;
  height: 17px;
  border-radius: 6px;
  padding: 0 7px;
}

/* On expanded sidebar: hide icon badge, show inline badge */
.app-shell-sidebar:not(.collapsed) .shell-nav-item__icon .shell-skills-badge:not(.shell-skills-badge--inline),
.app-shell-sidebar:not(.collapsed) .shell-nav-item__icon .shell-achievements-badge:not(.shell-achievements-badge--inline) {
  display: none;
}

/* On collapsed sidebar: hide inline badge, show icon badge */
.collapsed .shell-nav-item__icon .shell-skills-badge:not(.shell-skills-badge--inline) {
  top: -4px;
  right: -4px;
}
.collapsed .shell-skills-badge--inline,
.collapsed .shell-achievements-badge--inline {
  display: none !important;
}

/* Achievement badge — same style as skills badge */
.shell-achievements-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--shell-active-color, #7c6fcd);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  position: absolute;
  top: -6px;
  right: -8px;
  pointer-events: none;
  transition: opacity 0.2s;
}

.shell-achievements-badge--inline {
  position: static;
  top: unset;
  right: unset;
  margin-left: 6px;
  font-size: 0.7rem;
  min-width: 22px;
  height: 17px;
  border-radius: 6px;
  padding: 0 7px;
}

.collapsed .shell-nav-item__icon .shell-achievements-badge:not(.shell-achievements-badge--inline) {
  top: -4px;
  right: -4px;
}

/* Bottom nav achievement badge */
.bottom-nav-item__icon .shell-achievements-badge {
  top: -5px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  font-size: 0.6rem;
  border-radius: 8px;
}

/* Bottom nav — same badge, slightly smaller, anchored to icon */
.bottom-nav-item__icon {
  position: relative;
}

.bottom-nav-item__icon .shell-skills-badge {
  top: -5px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  font-size: 0.6rem;
  border-radius: 8px;
}
