/* ==========================================================================
   LEFT SIDEBAR NAVIGATION
   Full-height fixed rail on desktop/tablet — the sidebar itself never
   scrolls; .app-main is the single scrolling viewport for everything below
   the header. Folded into the mobile drawer (see header.css) below 861px.
   Reuses the existing design tokens — no new colours, radii, or type sizes
   are introduced.
   ========================================================================== */

.app-shell {
  display: flex;
  align-items: stretch;
  height: calc(100vh - var(--header-height));
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--sidebar-width);
  height: 100%;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: var(--space-4) var(--space-3) var(--space-6);
  transition: background-color var(--duration-theme) var(--ease-in-out),
    border-color var(--duration-theme) var(--ease-in-out);
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ---- Nav list --------------------------------------------------------------- */
.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-3) var(--space-2);
}

.sidebar-section-title {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px var(--space-3);
  border: none;
  border-left: 3px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--duration-hover) var(--ease-out),
    color var(--duration-hover) var(--ease-out),
    border-color var(--duration-hover) var(--ease-out);
}

.sidebar-link:hover {
  background: var(--hover);
  color: var(--text-primary);
}

.sidebar-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: var(--weight-semibold);
}

.sidebar-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
}

.sidebar-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Focus ring, consistent with the rest of the app. */
.sidebar-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Footer: destructive "Clear All Data" action --------------------------- */
.app-sidebar .sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.sidebar-clear-btn {
  color: var(--danger);
}

.sidebar-clear-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Tablet: narrow to an icon-only rail to keep content width comfortable.
   This is a fixed breakpoint behaviour, not a user toggle — there is no
   button to opt back into the full-width rail at this size. */
@media (max-width: 1100px) {
  .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .app-sidebar .sidebar-label,
  .app-sidebar .sidebar-section-title {
    display: none;
  }

  .app-sidebar .sidebar-link {
    justify-content: center;
    padding-inline: 0;
  }

  .app-sidebar .sidebar-divider {
    margin: var(--space-2) auto;
    width: 60%;
  }
}

/* Mobile: the persistent rail disappears; navigation lives in the header's
   slide-out drawer instead (see .mobile-drawer .sidebar-list below). */
@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    display: none;
  }
}

.mobile-drawer .sidebar-divider {
  margin: var(--space-4) 0;
}

.mobile-drawer .sidebar-list {
  gap: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .sidebar-link {
    transition-duration: 0.01ms !important;
  }
}
