/* Navigation — Admin sidebar · Topbar · Member nav */
/* Premium sidebar with smooth animations, refined hierarchy,
   beautiful active/hover states, and Linear.app-level polish. */

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR CONTAINER
   ═══════════════════════════════════════════════════════════════ */
.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--card);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: var(--z-sticky);
  overflow: hidden;
  border-right: 1px solid var(--border);
  transition: transform var(--transition-base);
}

/* ═══════════════════════════════════════════════════════════════
   BRAND SECTION
   ═══════════════════════════════════════════════════════════════ */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--fw-semibold);
  color: var(--foreground);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  letter-spacing: -0.01em;
  height: 3.5rem;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}
.sidebar-brand:hover { opacity: 0.8; }
.sidebar-brand .brand-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--color-primary-fg);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.sidebar-brand:hover .brand-icon { transform: scale(1.05); }
.sidebar-brand .brand-icon svg {
  width: 15px; height: 15px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR HEADER (brand row with toggle)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3) 0 var(--space-4);
  height: 3.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header .sidebar-brand {
  flex: 1;
  min-width: 0;
  padding: 0;
  border-bottom: none;
  height: auto;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR TOGGLE BUTTON (Lucide columns icon, reference style)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 150ms, background 150ms, border-color 150ms;
}
.sidebar-toggle-btn:hover {
  background: var(--muted);
  color: var(--foreground);
  border-color: var(--border);
}
.sidebar-toggle-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.sidebar-toggle-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════════════
   NAVIGATION LIST (scrollable)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-nav {
  flex: 1;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.3s ease;
}
.sidebar-nav:hover {
  scrollbar-color: var(--border) transparent;
}
/* Webkit scrollbar styling */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 4px;
  transition: background 0.3s ease;
}
.sidebar-nav:hover::-webkit-scrollbar-thumb {
  background: var(--border);
}
.sidebar-nav:hover::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

/* ═══════════════════════════════════════════════════════════════
   BASE NAV LINK
   ═══════════════════════════════════════════════════════════════ */
.sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
  padding: var(--space-4) var(--space-3) var(--space-2);
  margin: 0;
  user-select: none;
}
/* No :first-child rule — the dashboard link precedes the first label */

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3);
  height: 2.375rem; /* 38px — better touch target */
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
  font-size: var(--font-size-sm);
  font-weight: var(--fw-normal);
  line-height: 1;
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.sidebar-link:hover {
  background: var(--muted);
  color: var(--foreground);
}
/* Active state: subtle background tint + left accent bar */
.sidebar-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary-text);
  font-weight: var(--fw-medium);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-2));
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--color-primary);
  opacity: 1;
  transition: opacity 150ms ease;
}
[data-bs-theme="dark"] .sidebar-link.active::before {
  background: var(--color-primary);
}
.sidebar-link.disabled {
  opacity: 0.45;
  cursor: default;
  color: var(--muted-foreground);
}
.sidebar-link.disabled:hover { background: none; }

/* ═══════════════════════════════════════════════════════════════
   SUB-LINK (nested inside groups)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-link.sub {
  padding-left: 44px; /* clear hierarchy */
  font-size: var(--font-size-xs);
  height: 2.25rem;
  position: relative;
}
.sidebar-link.sub.active {
  background: var(--color-primary-light);
  color: var(--color-primary-text);
  font-weight: var(--fw-medium);
}
.sidebar-link.sub.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  border-radius: 0 2px 2px 0;
  background: var(--color-primary);
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   ICON STYLING
   ═══════════════════════════════════════════════════════════════ */
.sidebar-link .sidebar-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 150ms ease;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.sidebar-link:hover .sidebar-icon { opacity: 0.85; }
.sidebar-link.active .sidebar-icon { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   COLLAPSIBLE GROUPS (details / summary)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-group summary::-webkit-details-marker { display: none; }
.sidebar-group summary::marker { display: none; }
.sidebar-group summary {
  user-select: none; list-style: none; cursor: pointer;
  font-weight: var(--fw-medium);
}
/* Chevron via pseudo-element */
.sidebar-group summary::after {
  content: '';
  margin-left: auto;
  width: 16px; height: 16px;
  background: currentColor;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  mask-size: 16px;
  opacity: 0.4;
  transition: transform 200ms ease, opacity 150ms ease;
  flex-shrink: 0;
}
.sidebar-group summary:hover::after { opacity: 0.7; }
.sidebar-group[open] > summary::after { transform: rotate(180deg); }

/* Smooth expand/collapse via max-height transition (CSS-only) */
.sidebar-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.2s ease;
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding-left: calc(var(--space-2) + 2px);
  border-left: 1px solid var(--border);
  margin-left: var(--space-5);
}
.sidebar-group[open] > .sidebar-sub {
  max-height: 600px; /* accommodates all sub-link lists */
  opacity: 1;
  margin: 1px 0;
}

/* ═══════════════════════════════════════════════════════════════
   SPACER (pushes bottom section down)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-spacer { flex: 1; }

/* ═══════════════════════════════════════════════════════════════
   BOTTOM SECTION (user info + actions + logout)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-bottom {
  padding: var(--space-2) var(--space-2) var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
/* Subtle shadow gradient atop bottom section */
.sidebar-bottom::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.02));
  pointer-events: none;
}
[data-bs-theme="dark"] .sidebar-bottom::before {
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.08));
}
.sidebar-bottom .sidebar-link {
  font-size: var(--font-size-xs);
  padding: 0 var(--space-3);
  min-height: 2.125rem; /* 34px */
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
  width: auto;
  gap: var(--space-2);
}
.sidebar-bottom .sidebar-link:first-child {
  width: auto;
  flex: 1;
  justify-content: flex-start;
  color: var(--muted-foreground);
  font-size: var(--font-size-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--fw-medium);
  padding: 0 var(--space-3);
  min-height: 32px;
}
.sidebar-bottom .sidebar-link .sidebar-icon {
  width: 14px; height: 14px;
  flex-shrink: 0;
}

/* Bottom actions row (theme toggle) */
.sidebar-bottom-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-2) 0 var(--space-1);
}

/* ═══════════════════════════════════════════════════════════════
   THEME TOGGLE — reference-style pill with active highlight
   ═══════════════════════════════════════════════════════════════ */
.sidebar-theme-toggle {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  margin: 0;
}
.sidebar-theme-toggle .theme-icon {
  width: 26px;
  height: 26px;
  padding: 5px;
  border-radius: 9999px;
  transition: background 150ms, color 150ms;
}
/* Light mode: sun active, moon muted */
.sidebar-theme-toggle .theme-icon-sun {
  color: var(--color-primary-fg);
  background: var(--color-primary);
}
.sidebar-theme-toggle .theme-icon-moon {
  color: var(--muted-foreground);
  background: transparent;
}
/* Dark mode: moon active, sun muted */
[data-bs-theme="dark"] .sidebar-theme-toggle .theme-icon-moon {
  color: var(--color-primary-fg);
  background: var(--color-primary);
}
[data-bs-theme="dark"] .sidebar-theme-toggle .theme-icon-sun {
  color: var(--muted-foreground);
  background: transparent;
}
.sidebar-theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ═══════════════════════════════════════════════════════════════
   BADGE (notification / count indicator)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  font-size: 0.625rem;
  font-weight: var(--fw-medium);
  line-height: 1;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--primary-foreground);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR COLLAPSE / OPEN STATE TRANSITIONS
   ═══════════════════════════════════════════════════════════════ */
.admin-layout.sidebar-closed .admin-sidebar { transform: translateX(-100%); }
.admin-layout .admin-sidebar { transform: translateX(0); transition: transform var(--transition-base); }
.admin-layout.sidebar-closed.sidebar-reveal .admin-sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }

/* ═══════════════════════════════════════════════════════════════
   FLOATING PANEL (reference-style — appears when sidebar is collapsed)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-floating-panel {
  position: fixed;
  top: calc(3.5rem + var(--space-3));
  left: var(--space-4);
  z-index: calc(var(--z-sticky) + 2);
  display: none;
  align-items: center;
  gap: var(--space-1);
  padding: 3px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  box-shadow: var(--shadow-lg);
}
.admin-layout.sidebar-closed .sidebar-floating-panel {
  display: flex;
}
.admin-layout.sidebar-closed.sidebar-reveal .sidebar-floating-panel {
  display: none;
}
/* Hide the panel on mobile when sidebar-open overlay is active */
@media (max-width: 1024px) {
  .admin-layout.sidebar-open .sidebar-floating-panel {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   FLOATING PANEL BUTTON (clean icon button matching reference)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-panel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 150ms, background 150ms;
}
.sidebar-panel-btn:hover {
  background: var(--card);
  color: var(--foreground);
}
.sidebar-panel-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.sidebar-panel-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════════════
   HOVER ZONE — invisible strip on far left edge to reveal sidebar
   ═══════════════════════════════════════════════════════════════ */
.sidebar-hover-zone {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  z-index: calc(var(--z-sticky) + 3);
  cursor: default;
  pointer-events: auto;
}
/* Hide hover zone when sidebar is not collapsed */
.admin-layout:not(.sidebar-closed) .sidebar-hover-zone,
.admin-layout.sidebar-closed.sidebar-reveal .sidebar-hover-zone {
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — collapse at 1024px with backdrop overlay
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .admin-layout .page-wrapper { padding-left: 0; }
  .admin-sidebar { transform: translateX(-100%); }
  .admin-layout.sidebar-open .admin-sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  /* Hide floating panel + hover zone on mobile — use overlay instead */
  .sidebar-floating-panel,
  .sidebar-hover-zone {
    display: none !important;
  }
  /* Sidebar backdrop overlay when open on mobile */
  .admin-layout.sidebar-open .admin-sidebar-col::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: -1;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
}



/* ══════════════════════════════════════════════════════════════════
   LEGACY FRONTEND HEADER — keep for member area
   ══════════════════════════════════════════════════════════════════ */
.frontend-header {
  position: sticky;
  top: 0;
  left: 0;
  z-index: var(--z-sticky);
  width: 100%;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--transition-base);
}
.frontend-header.is-scrolled { box-shadow: var(--shadow-sm); }
.frontend-header .navbar {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  min-height: 48px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}
.brand-logo .brand-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--primary-foreground);
  font-size: 0.65rem;
  font-weight: var(--fw-bold);
  flex-shrink: 0;
}
.brand-logo .brand-text {
  font-weight: var(--fw-bold);
  font-size: var(--font-size-base);
  color: var(--foreground);
  letter-spacing: -0.01em;
}

.nav-link-slide {
  position: relative;
  color: var(--muted-foreground) !important;
  padding: var(--space-1) 0 !important;
  margin: 0 var(--space-2);
  font-weight: var(--fw-medium);
  font-size: 0.8125rem;
  line-height: 1.5;
  transition: color var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}
.nav-link-slide:hover { color: var(--foreground) !important; }
.nav-link-slide.active { color: var(--foreground) !important; font-weight: var(--fw-semibold); }

.nav-search {
  position: relative;
  max-width: 260px;
  width: 100%;
}
.nav-search .search-input {
  width: 100%;
  height: 34px;
  padding: 0 var(--space-2) 0 var(--space-7);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-size: var(--font-size-sm);
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.nav-search .search-input::placeholder { color: var(--muted-foreground); }
.nav-search .search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235,0.15);
}
.nav-search .search-icon {
  position: absolute;
  left: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--muted-foreground);
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════
   THEME TOGGLE (shared across sidebar + topnav)
   ══════════════════════════════════════════════════════════════════ */
.btn-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.btn-icon-svg:hover {
  background: var(--muted);
  color: var(--foreground);
  border-color: var(--ring);
}
.btn-icon-svg svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}



/* ══════════════════════════════════════════════════════════════════
   ADMIN TOPBAR (inner page header)
   ══════════════════════════════════════════════════════════════════ */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.admin-topbar h1 {
  font-size: var(--font-size-sm);
  font-weight: var(--fw-semibold);
  color: var(--foreground);
  margin: 0;
  letter-spacing: -0.01em;
}
.admin-topbar-actions { display: flex; align-items: center; gap: var(--space-2); }
