/* ============================================================
   OminiSis Enterprise — Sidebar CSS
   ============================================================ */

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
  transition: width var(--trans-slow);
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  height: 80px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.brand-icon { flex-shrink: 0; }

.brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--trans-base), width var(--trans-base);
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--sidebar-text);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.brand-version {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.sidebar-collapse-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-muted);
  cursor: pointer;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--trans-fast);
}

.sidebar-collapse-btn:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
  border-color: var(--border-default);
}

/* Collapsed sidebar */
.app.sidebar-collapsed .brand-text { opacity: 0; width: 0; overflow: hidden; }
.app.sidebar-collapsed .brand-name { display: none; }
.app.sidebar-collapsed .brand-version { display: none; }
.app.sidebar-collapsed .sidebar-collapse-btn { transform: rotate(180deg); }
.app.sidebar-collapsed .tenant-info { display: none; }
.app.sidebar-collapsed .tenant-switch-btn { display: none; }
.app.sidebar-collapsed .sidebar-search { display: none; }
.app.sidebar-collapsed .nav-section-label { display: none; }
.app.sidebar-collapsed .nav-label { display: none; }
.app.sidebar-collapsed .nav-badge { display: none; }
.app.sidebar-collapsed .nav-item { justify-content: center; padding: 10px; }
.app.sidebar-collapsed .nav-item .nav-icon { margin: 0; }
.app.sidebar-collapsed .system-health span { display: none; }

/* Tenant Selector */
.tenant-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--trans-fast);
  flex-shrink: 0;
}

.tenant-selector:hover { background: var(--sidebar-hover); }

.tenant-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--grad-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.tenant-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.tenant-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.tenant-plan {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.tenant-switch-btn {
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
  transition: color var(--trans-fast);
}

.tenant-switch-btn:hover { color: var(--sidebar-text); }

/* Sidebar Search */
.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-search svg { color: var(--sidebar-text-muted); flex-shrink: 0; }

.sidebar-search input {
  flex: 1;
  background: none;
  border: none;
  font-size: 13px;
  color: var(--sidebar-text);
  outline: none;
  font-family: inherit;
}

.sidebar-search input::placeholder { color: var(--sidebar-text-muted); }

.sidebar-search kbd {
  background: var(--sidebar-hover);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  color: var(--sidebar-text-muted);
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

.nav-section { margin-bottom: 4px; }

.nav-section-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sidebar-text-muted);
  padding: 8px 10px 4px;
  transition: opacity var(--trans-base);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--trans-fast);
  color: var(--sidebar-text-muted);
  position: relative;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%; bottom: 25%;
  width: 3px;
  background: var(--sidebar-active-border);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.nav-badge-ai {
  background: rgba(99,102,241,0.2);
  color: var(--brand-primary);
  border: 1px solid rgba(99,102,241,0.3);
}

.nav-badge-new {
  background: rgba(16,185,129,0.2);
  color: var(--brand-success);
  border: 1px solid rgba(16,185,129,0.3);
}

.nav-badge-admin {
  background: rgba(239,68,68,0.2);
  color: var(--brand-danger);
  border: 1px solid rgba(239,68,68,0.3);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.system-health {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.health-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-dot-ok {
  background: var(--brand-success);
  box-shadow: 0 0 6px rgba(16,185,129,0.5);
  animation: pulse 3s ease-in-out infinite;
}

/* Nav item tooltip for collapsed state */
.app.sidebar-collapsed .nav-item {
  position: relative;
}

.app.sidebar-collapsed .nav-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
