/* ============================================================
   LMS ERP — Sidebar Refinement
   Pure CSS — works on your EXISTING markup. No HTML changes,
   so the branch switcher, links and mobile drawer keep working.
   Load AFTER app.css.
   ============================================================ */

:root { --sidebar-w: 252px; }

/* ── Shell ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0B1220 0%, #0A101C 100%);
  border-right: 1px solid rgba(148,163,184,.08);
  display: flex;
  flex-direction: column;
}

/* ── Brand block — much tighter ────────────────────────── */
.sidebar-brand {
  padding: 16px 16px 14px;
  gap: 10px;
  border-bottom: 1px solid rgba(148,163,184,.08);
}
.brand-icon svg, .brand-icon img { width: 32px; height: 32px; }
.brand-name    { font-size: 15px; font-weight: 700; letter-spacing: -.01em; line-height: 1.1; }
.brand-tagline { font-size: 9.5px; letter-spacing: .11em; color: var(--text-muted); margin-top: 1px; }

/* ── Scroll area ───────────────────────────────────────── */
.sidebar-nav {
  padding: 8px 10px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,.18) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(148,163,184,.16); border-radius: 99px; }
.sidebar-nav:hover::-webkit-scrollbar-thumb { background: rgba(148,163,184,.3); }

/* ── Section labels ────────────────────────────────────── */
.nav-section {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .13em;
  color: rgba(148,163,184,.55);
  padding: 0 10px;
  margin: 16px 0 6px;
  text-transform: uppercase;
}
.nav-section:first-child { margin-top: 4px; }

/* ── Nav rows — the big fix: ~66px tall becomes ~34px ──── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  margin-bottom: 1px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: rgba(203,213,225,.72);
  position: relative;
  transition: background .14s ease, color .14s ease;
}
.nav-item:hover { background: rgba(148,163,184,.07); color: var(--text-primary); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(37,99,235,.16) 0%, rgba(37,99,235,.05) 100%);
  color: #93C5FD;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

/* ── Icons: normalise mismatched emoji ─────────────────────
   Emoji can't be recoloured, so desaturate them so they sit
   quietly, then restore full colour on hover/active. This is
   what makes the rail read as one consistent icon set.      */
.nav-icon {
  width: 18px; min-width: 18px; height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  filter: grayscale(.85) opacity(.7);
  transition: filter .14s ease;
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { filter: grayscale(0) opacity(1); }
.nav-icon svg { width: 16px; height: 16px; stroke-width: 1.9; }

.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Optional count badge on a nav row */
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  line-height: 1.5;
}

/* ── Footer — replaces the big floating avatar ─────────── */
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid rgba(148,163,184,.08);
  background: rgba(0,0,0,.18);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  transition: background .14s ease;
}
.user-info:hover { background: rgba(148,163,184,.07); }

.sidebar-footer .user-avatar,
.sidebar-footer .avatar {
  width: 30px; height: 30px; min-width: 30px;
  font-size: 12px; font-weight: 600;
  border-radius: 50%;
}
.user-meta { min-width: 0; flex: 1; }
.user-name {
  font-size: 12.5px; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.25;
}
.user-role {
  font-size: 10.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-footer .logout-btn {
  margin-left: auto;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
  transition: all .14s ease;
}
.sidebar-footer .logout-btn:hover { background: var(--danger-dim); color: var(--danger); }

/* ── Accessibility ─────────────────────────────────────── */
.nav-item:focus-visible,
.user-info:focus-visible,
.sidebar-footer .logout-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: 7px;
}
@media (prefers-reduced-motion: reduce) {
  .nav-item, .nav-icon, .user-info { transition: none; }
}

/* ── Mobile drawer polish ──────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { box-shadow: 8px 0 32px rgba(0,0,0,.55); }
  .nav-item { padding: 9px 10px; font-size: 13.5px; }
  .sidebar-close {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: 6px;
    color: var(--text-muted);
    margin-left: auto;
  }
  .sidebar-close:hover { background: var(--bg-hover); color: var(--text-primary); }
}
/* ── Sidebar footer: profile + settings + logout ────────── */
.sidebar-footer {
  padding: 8px;
  border-top: 1px solid rgba(148,163,184,.08);
  background: rgba(0,0,0,.22);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: 6px 7px;
  border-radius: 8px;
  text-decoration: none;
  transition: background .14s ease;
}
.sb-user:hover { background: rgba(148,163,184,.08); }

.sb-avatar {
  width: 30px; height: 30px; min-width: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.sb-meta { display: flex; flex-direction: column; min-width: 0; }
.sb-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-role {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sb-actions { display: flex; gap: 3px; flex-shrink: 0; }

.sb-act {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--text-muted);
  transition: all .14s ease;
}
.sb-act svg { width: 15px; height: 15px; }
.sb-act:hover { background: rgba(148,163,184,.1); color: var(--text-primary); }
.sb-act.danger:hover { background: rgba(239,68,68,.14); color: #F87171; }
.sb-act:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* ============================================================
   FIX — search dropdowns clipped inside cards
   Affects: Issue Book (member + title search), any panel with
   an autocomplete list inside a .card
   ============================================================ */

/* The card and its body must stop clipping their children */
.card:has(.search-dropdown),
.card:has(#memberResults),
.card:has(#bookResults) {
  overflow: visible;
}
.card:has(.search-dropdown) .card-body,
.card:has(#memberResults) .card-body,
.card:has(#bookResults) .card-body {
  overflow: visible;
}

/* Give the wrapper a stacking context above sibling cards */
.form-group:has(> .search-dropdown),
.input-wrap:has(> .search-dropdown),
.scanner-wrap:has(+ .search-dropdown) {
  position: relative;
  z-index: 50;
}

/* The dropdown itself */
.search-dropdown,
#memberResults,
#bookResults {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 900;                       /* above cards, below modals (1000) */
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .65);
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;       /* stop page scrolling at list ends */
}

/* Rows need breathing room and a clear hover */
.search-dropdown .search-result-item,
#memberResults .search-result-item,
#bookResults .search-result-item {
  padding: 10px 14px;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-dropdown .search-result-item:last-child,
#memberResults .search-result-item:last-child,
#bookResults .search-result-item:last-child { border-bottom: none; }

.search-dropdown .search-result-item:hover,
#memberResults .search-result-item:hover,
#bookResults .search-result-item:hover {
  background: var(--primary-dim);
}

/* Thin scrollbar inside the list */
.search-dropdown::-webkit-scrollbar,
#memberResults::-webkit-scrollbar,
#bookResults::-webkit-scrollbar { width: 5px; }
.search-dropdown::-webkit-scrollbar-thumb,
#memberResults::-webkit-scrollbar-thumb,
#bookResults::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,.25);
  border-radius: 99px;
}

/* The two search cards must sit above the Issue Details card below them */
.issue-form-grid { position: relative; z-index: 20; }
.issue-form-grid + .card { position: relative; z-index: 1; }