/* ══════════════════════════════════════════════════════════════════════════════
   GB Capital — Premium Sidebar
   Shared across all portals. Always dark background in both modes.
   Features: glass morphism, smooth animations, collapsible groups,
   inline search, user profile, notification badges, mini mode
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar Shell ────────────────────────────────────────────────────────── */
.gb-sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 200px;
  background: linear-gradient(180deg, var(--portal-primary, #043839) 0%, #0a0e16 60%, #06090f 100%);
  border-right: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .3s cubic-bezier(.4,0,.2,1), width .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
}

/* Always dark — both light and dark mode */
html[data-theme="light"] .gb-sidebar {
  background: linear-gradient(180deg, var(--portal-primary, #043839) 0%, #0a0e16 60%, #06090f 100%) !important;
  border-right-color: rgba(255,255,255,.06) !important;
}

/* Mobile: off-screen by default */
@media (max-width: 768px) {
  .gb-sidebar { transform: translateX(-200px); }
  .gb-sidebar.open { transform: translateX(0); }
}

/* ── Sidebar Overlay (mobile) ─────────────────────────────────────────────── */
.gb-sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}
@media (max-width: 768px) {
  .gb-sidebar.open ~ .gb-sb-overlay { display: block; }
}

/* ── Logo Area ────────────────────────────────────────────────────────────── */
.gb-sb-header {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.gb-sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.gb-sb-logo img {
  height: 24px;
  width: auto;
  opacity: .9;
  transition: opacity .15s;
}
.gb-sb-logo:hover img { opacity: 1; }
.gb-sb-portal-name {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--portal-accent, #308384);
  margin-top: 8px;
  padding-left: 2px;
}

/* ── Sidebar Search ───────────────────────────────────────────────────────── */
.gb-sb-search {
  padding: 12px 14px 8px;
  flex-shrink: 0;
}
.gb-sb-search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.8);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: all .15s;
}
.gb-sb-search-input::placeholder { color: rgba(255,255,255,.25); }
.gb-sb-search-input:focus {
  border-color: var(--portal-accent, #308384);
  background: rgba(255,255,255,.06);
  box-shadow: 0 0 0 3px rgba(var(--portal-accent-rgb, 48,131,132), .12);
}
.gb-sb-search-wrap {
  position: relative;
}
.gb-sb-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: rgba(255,255,255,.25);
  pointer-events: none;
}

/* Keep search light-mode safe */
html[data-theme="light"] .gb-sb-search-input {
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.1) !important;
  color: rgba(255,255,255,.8) !important;
}
html[data-theme="light"] .gb-sb-search-input::placeholder { color: rgba(255,255,255,.25) !important; }
html[data-theme="light"] .gb-sb-search-input:focus {
  border-color: var(--portal-accent, #308384) !important;
}

/* ── Navigation ───────────────────────────────────────────────────────────── */
.gb-sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.gb-sb-nav::-webkit-scrollbar { width: 4px; }
.gb-sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }
.gb-sb-nav::-webkit-scrollbar-track { background: transparent; }

/* ── Standalone Nav Item (Dashboard) ──────────────────────────────────────── */
.gb-sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  margin: 2px 8px;
  border-radius: 8px;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s cubic-bezier(.4,0,.2,1);
  position: relative;
  border-left: 3px solid transparent;
}
.gb-sb-item:hover {
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.06);
}
.gb-sb-item.active {
  color: var(--portal-accent, #308384);
  background: rgba(var(--portal-accent-rgb, 48,131,132), .1);
  border-left-color: var(--portal-accent, #308384);
  font-weight: 700;
}
.gb-sb-item.active i,
.gb-sb-item.active svg { opacity: 1; }
.gb-sb-item i,
.gb-sb-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .5;
  transition: opacity .15s;
}
.gb-sb-item:hover i,
.gb-sb-item:hover svg { opacity: .85; }

/* Badge (notification count) */
.gb-sb-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--portal-accent, #308384);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Light mode: sidebar items stay light-on-dark */
html[data-theme="light"] .gb-sb-item { color: rgba(255,255,255,.55) !important; }
html[data-theme="light"] .gb-sb-item:hover { color: rgba(255,255,255,.9) !important; background: rgba(255,255,255,.06) !important; }
html[data-theme="light"] .gb-sb-item.active { color: var(--portal-accent, #308384) !important; background: rgba(var(--portal-accent-rgb, 48,131,132), .1) !important; }

/* ── Collapsible Group ────────────────────────────────────────────────────── */
.gb-sb-group {
  margin: 2px 0;
}
.gb-sb-group-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: rgba(255,255,255,.35);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  transition: color .15s;
}
.gb-sb-group-btn:hover { color: rgba(255,255,255,.55); }
.gb-sb-group-btn i,
.gb-sb-group-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: .5;
}
.gb-sb-group-label { flex: 1; }
.gb-sb-chevron {
  width: 12px;
  height: 12px;
  transition: transform .2s cubic-bezier(.4,0,.2,1);
  opacity: .4;
}
.gb-sb-group.collapsed .gb-sb-chevron { transform: rotate(-90deg); }

/* Group items container — smooth collapse */
.gb-sb-group-items {
  max-height: 500px;
  overflow: hidden;
  transition: max-height .25s cubic-bezier(.4,0,.2,1), opacity .2s;
  opacity: 1;
}
.gb-sb-group.collapsed .gb-sb-group-items {
  max-height: 0;
  opacity: 0;
}

/* Light mode group styling */
html[data-theme="light"] .gb-sb-group-btn { color: rgba(255,255,255,.35) !important; }
html[data-theme="light"] .gb-sb-group-btn:hover { color: rgba(255,255,255,.55) !important; }

/* ── Sidebar Footer ───────────────────────────────────────────────────────── */
.gb-sb-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

/* ── User Profile (bottom of sidebar) ─────────────────────────────────────── */
.gb-sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 4px;
  border-radius: 10px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  transition: background .15s;
  cursor: pointer;
}
.gb-sb-user:hover {
  background: rgba(255,255,255,.04);
}
.gb-sb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--portal-accent, #308384);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
}
.gb-sb-avatar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a7a5e;
  border: 2px solid #0a0e16;
}
.gb-sb-user-info {
  flex: 1;
  min-width: 0;
}
.gb-sb-user-name {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gb-sb-user-role {
  font-size: 10px;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Light mode: user area stays dark */
html[data-theme="light"] .gb-sb-user-name { color: rgba(255,255,255,.85) !important; }
html[data-theme="light"] .gb-sb-user-role { color: rgba(255,255,255,.35) !important; }
html[data-theme="light"] .gb-sb-user:hover { background: rgba(255,255,255,.04) !important; }

/* ── Quick Action Button ──────────────────────────────────────────────────── */
.gb-sb-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 16px);
  margin: 4px 8px 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px dashed rgba(255,255,255,.12);
  background: transparent;
  color: rgba(255,255,255,.4);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.gb-sb-action-btn:hover {
  border-color: var(--portal-accent, #308384);
  color: var(--portal-accent, #308384);
  background: rgba(var(--portal-accent-rgb, 48,131,132), .06);
}
html[data-theme="light"] .gb-sb-action-btn { color: rgba(255,255,255,.4) !important; border-color: rgba(255,255,255,.12) !important; }
html[data-theme="light"] .gb-sb-action-btn:hover { color: var(--portal-accent) !important; border-color: var(--portal-accent) !important; }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.gb-sb-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 6px 18px;
}

/* ── Section Label ────────────────────────────────────────────────────────── */
.gb-sb-section-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,.25);
  padding: 14px 18px 4px;
}

/* ── Sidebar Mini Mode ────────────────────────────────────────────────────── */
.gb-sidebar.mini {
  width: 60px;
}
.gb-sidebar.mini .gb-sb-header { padding: 16px 10px; justify-content: center; }
.gb-sidebar.mini .gb-sb-logo span,
.gb-sidebar.mini .gb-sb-portal-name,
.gb-sidebar.mini .gb-sb-search,
.gb-sidebar.mini .gb-sb-group-label,
.gb-sidebar.mini .gb-sb-chevron,
.gb-sidebar.mini .gb-sb-user-info,
.gb-sidebar.mini .gb-sb-action-btn span,
.gb-sidebar.mini .gb-sb-item span { display: none; }
.gb-sidebar.mini .gb-sb-item { justify-content: center; padding: 10px; margin: 2px 6px; }
.gb-sidebar.mini .gb-sb-group-btn { justify-content: center; padding: 8px; }
.gb-sidebar.mini .gb-sb-avatar { width: 28px; height: 28px; font-size: 10px; }
.gb-sidebar.mini .gb-sb-user { justify-content: center; padding: 8px 6px; }
.gb-sidebar.mini .gb-sb-badge { position: absolute; top: 2px; right: 2px; min-width: 14px; height: 14px; font-size: 8px; }

/* Tooltip on hover in mini mode */
.gb-sidebar.mini .gb-sb-item[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,.85);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 300;
  pointer-events: none;
}

/* ── Glow effect on active item ───────────────────────────────────────────── */
.gb-sb-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: linear-gradient(180deg, var(--portal-accent, #308384), transparent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--portal-accent, #308384);
}

/* ── Transition for main content when sidebar is present ──────────────────── */

/* ── Override old sidebar/layout system ───────────────────────────────────── */
/* When gb-sidebar is present, disable the old sidebar styles */
.app-layout { display: block !important; }

/* Hide old sidebar overlay when new sidebar is used */
.gb-sidebar ~ .sidebar-overlay { display: none !important; }

/* Ensure old .sidebar class doesn't interfere */
.gb-sidebar.sidebar { width: 200px !important; }

